5 from path
import convert_to_native
8 def uncompress_file_to_dir(compressed_file
, uncompress_dir
):
9 os
.makedirs(uncompress_dir
, exist_ok
=True)
12 'msiexec', '/a', convert_to_native(compressed_file
).replace('/', '\\'),
14 'TARGETDIR=' + convert_to_native(uncompress_dir
).replace('/', '\\')]) != 0:
15 raise Exception('msiexec failed')
23 def get_hash(file_path
):
24 sha512
= hashlib
.sha512()
25 with
open(file_path
, 'rb') as f
:
26 while data
:= f
.read(BUF_SIZE
):
28 return sha512
.hexdigest()
31 def get_file_info(mar_file
, url
):
32 filesize
= os
.path
.getsize(mar_file
)
33 data
= {'hash': get_hash(mar_file
),
34 'hash_function': 'sha512',
36 'url': url
+ os
.path
.basename(mar_file
)}
41 def make_complete_mar_name(target_dir
, filename_prefix
):
42 filename
= filename_prefix
+ "_complete.mar"
43 return os
.path
.join(target_dir
, filename
)