tdf#147067 Jump to clicked spot if left mouse click with Option key
[LibreOffice.git] / bin / update / tools.py
blob2ec3d8cf7ae16b271b70e8de22b52ed8a0192c9c
1 import os
2 import hashlib
3 import subprocess
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)
11 if subprocess.call([
12 'msiexec', '/a', convert_to_native(compressed_file).replace('/', '\\'),
13 '/quiet',
14 'TARGETDIR=' + convert_to_native(uncompress_dir).replace('/', '\\')]) != 0:
15 raise Exception('msiexec failed')
17 return uncompress_dir
20 BUF_SIZE = 1048576
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):
27 sha512.update(data)
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',
35 'size': filesize,
36 'url': url + os.path.basename(mar_file)}
38 return data
41 def make_complete_mar_name(target_dir, filename_prefix):
42 filename = filename_prefix + "_complete.mar"
43 return os.path.join(target_dir, filename)