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:
@@ -4,9 +4,9 @@ from PySide6.QtQml import QQmlApplicationEngine
|
||||
from PySide6.QtCore import QObject, Slot, Signal
|
||||
|
||||
from artemis.utils.constants import Constants, Messages
|
||||
from artemis.utils.sys_utils import open_directory, pack_db, unpack_db
|
||||
from artemis.utils.sys_utils import open_directory, make_tar, unpack_tar
|
||||
from artemis.utils.sql_utils import ArtemisDatabase, ArtemisSignal
|
||||
from artemis.utils.path_utils import check_data_dir
|
||||
from artemis.utils.path_utils import DATA_DIR
|
||||
from artemis.utils.network_utils import NetworkManager
|
||||
from artemis.utils.generic_utils import generate_filter_query
|
||||
from artemis.utils.path_utils import normalize_dialog_path
|
||||
@@ -69,8 +69,6 @@ class UIArtemis(QObject):
|
||||
|
||||
self.network_manager = NetworkManager(self)
|
||||
|
||||
check_data_dir()
|
||||
|
||||
|
||||
def _connect(self):
|
||||
# QML > Python connections
|
||||
@@ -277,7 +275,7 @@ class UIArtemis(QObject):
|
||||
"""
|
||||
try:
|
||||
dest_path = normalize_dialog_path(save_path)
|
||||
pack_db(dest_path, self.loaded_db.db_dir)
|
||||
make_tar(dest_path, self.loaded_db.db_dir)
|
||||
self.dialog_popup(
|
||||
Messages.DIALOG_TYPE_INFO,
|
||||
Messages.GENERIC_SUCCESS,
|
||||
@@ -300,7 +298,8 @@ class UIArtemis(QObject):
|
||||
"""
|
||||
try:
|
||||
origin_path = normalize_dialog_path(tar_path)
|
||||
unpack_db(origin_path, str(uuid.uuid4()))
|
||||
save_path = DATA_DIR / str(uuid.uuid4())
|
||||
unpack_tar(origin_path, save_path)
|
||||
self.dialog_popup(
|
||||
Messages.DIALOG_TYPE_INFO,
|
||||
Messages.GENERIC_SUCCESS,
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import os
|
||||
|
||||
from PySide6.QtQml import QQmlApplicationEngine
|
||||
from PySide6.QtCore import QObject, Signal, Slot
|
||||
|
||||
from artemis.utils.path_utils import *
|
||||
from artemis.utils.path_utils import DATA_DIR
|
||||
from artemis.utils.generic_utils import *
|
||||
from artemis.utils.sql_utils import ArtemisDatabase
|
||||
from artemis.utils.constants import Constants
|
||||
from artemis.utils.sys_utils import delete_dir
|
||||
|
||||
|
||||
class UIdbmanager(QObject):
|
||||
@@ -67,7 +70,7 @@ class UIdbmanager(QObject):
|
||||
self._parent.lock_menu.emit(True)
|
||||
self._parent.clear_list.emit()
|
||||
self._parent.clear_signal_page.emit()
|
||||
delete_db_dir(db_dir_name)
|
||||
delete_dir(DATA_DIR / db_dir_name)
|
||||
self.load_local_db_list()
|
||||
|
||||
|
||||
@@ -85,10 +88,10 @@ class UIdbmanager(QObject):
|
||||
return a dictionary containing only the valid ones with a summary
|
||||
"""
|
||||
valid_db_list = []
|
||||
db_dirs = next(os.walk(Constants.DB_DIR))[1]
|
||||
db_dirs = next(os.walk(DATA_DIR))[1]
|
||||
|
||||
for db_dir_name in db_dirs:
|
||||
if valid_db(db_dir_name):
|
||||
if self._valid_db(db_dir_name):
|
||||
database = ArtemisDatabase(db_dir_name)
|
||||
database.load()
|
||||
valid_db_list.append(
|
||||
@@ -103,3 +106,22 @@ class UIdbmanager(QObject):
|
||||
)
|
||||
|
||||
return valid_db_list
|
||||
|
||||
|
||||
def _valid_db(self, db_dir_name):
|
||||
""" Checks if db_dir_name is a valid db dir containing a `data.sqlite` file.
|
||||
Db must be valid as well and should be properly initialized and loaded with
|
||||
no errors.
|
||||
|
||||
Args:
|
||||
db_dir_name (str): name of the db folder
|
||||
"""
|
||||
if os.path.exists(DATA_DIR / db_dir_name / Constants.SQL_NAME):
|
||||
try:
|
||||
database = ArtemisDatabase(db_dir_name)
|
||||
database.load()
|
||||
return True
|
||||
except:
|
||||
return False # Invalid or corrupted DB
|
||||
else:
|
||||
return False # The dir is not containing a data.sqlite file
|
||||
|
||||
@@ -3,9 +3,9 @@ from PySide6.QtCore import QObject, Slot, Signal, QUrl, QSaveFile, QDir, QIODevi
|
||||
from PySide6.QtNetwork import QNetworkReply, QNetworkRequest, QNetworkAccessManager
|
||||
|
||||
from artemis.utils.config_utils import *
|
||||
from artemis.utils.sys_utils import delete_file, match_hash, unpack_db
|
||||
from artemis.utils.sys_utils import delete_file, delete_dir, match_hash, unpack_tar
|
||||
from artemis.utils.constants import Messages
|
||||
from artemis.utils.sys_utils import delete_db_dir
|
||||
from artemis.utils.path_utils import DATA_DIR
|
||||
|
||||
|
||||
class UIDownloader(QObject):
|
||||
@@ -42,7 +42,7 @@ class UIDownloader(QObject):
|
||||
the attributes of the UpdatesController class
|
||||
"""
|
||||
url_file = QUrl(self._parent.network_manager.remote_db_url)
|
||||
dest_path = QDir(Constants.DB_DIR)
|
||||
dest_path = QDir(DATA_DIR)
|
||||
self.dest_file = dest_path.filePath(url_file.fileName())
|
||||
self.file = QSaveFile(self.dest_file)
|
||||
|
||||
@@ -97,8 +97,8 @@ class UIDownloader(QObject):
|
||||
|
||||
if match_hash(self.dest_file, self._parent.network_manager.remote_db_hash):
|
||||
self._label_progress.setProperty("text", "Unpacking archive...")
|
||||
delete_db_dir('SigID')
|
||||
unpack_db(self.dest_file, 'SigID')
|
||||
delete_dir(DATA_DIR / 'SigID')
|
||||
unpack_tar(self.dest_file, DATA_DIR / 'SigID')
|
||||
delete_file(self.dest_file)
|
||||
self._parent.load_db('SigID')
|
||||
self.close_ui.emit()
|
||||
|
||||
@@ -4,6 +4,7 @@ from PySide6.QtCore import QObject, Signal, Slot
|
||||
from artemis.utils.path_utils import *
|
||||
from artemis.utils.generic_utils import *
|
||||
from artemis.utils.sql_utils import ArtemisSignal
|
||||
from artemis.utils.sys_utils import delete_file
|
||||
|
||||
|
||||
class UIsignaleditor(QObject):
|
||||
|
||||
Reference in New Issue
Block a user