Read-only ops are separated in different standard and OS dependent folders from read-write ones (fixed #43), bump Nuitka 2.3

This commit is contained in:
Marco Dalla Tiezza
2024-06-04 19:25:12 +02:00
parent 16e2668fe9
commit 4e7ebcc2f5
16 changed files with 139 additions and 89 deletions

View File

@@ -6,7 +6,7 @@ import hashlib
from shutil import rmtree, copyfile, make_archive, unpack_archive
from pathlib import Path
from artemis.utils.constants import Constants, Messages
from artemis.utils.constants import Messages
def is_windows():
@@ -46,29 +46,38 @@ def open_directory(directory, timeout=3):
return
def delete_db_dir(db_dir_name):
"""Delete the db folder"""
db_dir = Constants.DB_DIR / db_dir_name
if os.path.exists(db_dir):
rmtree(db_dir)
def copy_file(src_file_path, dst_file_path):
copyfile(src_file_path, dst_file_path)
def delete_dir(dir_path):
if os.path.exists(dir_path):
rmtree(dir_path)
def delete_file(file_path):
if os.path.exists(file_path):
os.remove(file_path)
def pack_db(save_path, db_dir):
make_archive(save_path, 'tar', db_dir.resolve().as_posix())
def make_tar(save_path, origin_path):
""" Create a tar archive from a folder
Args:
save_path: destination path where new tar is saved
origin_path: directory path of the folder to be archived
"""
make_archive(save_path, 'tar', origin_path.resolve().as_posix())
def unpack_db(tar_path, db_dir_name):
db_dir = Constants.DB_DIR / db_dir_name
unpack_archive(tar_path, db_dir, 'tar')
def unpack_tar(tar_path, destination_path):
""" Unpack a tar archive in a folder
Args:
tar_path: path of the tar to be unpacked
destination_path: path where the tar is extracted
"""
unpack_archive(tar_path, destination_path, 'tar')
def match_hash(data, reference_hash):