New logic for local sigid search
This commit is contained in:
@@ -8,15 +8,19 @@
|
|||||||
### Added
|
### Added
|
||||||
- Possibility to navigate Artemis just with the keyboard [#50](https://github.com/AresValley/Artemis/issues/50)
|
- Possibility to navigate Artemis just with the keyboard [#50](https://github.com/AresValley/Artemis/issues/50)
|
||||||
- **Windows:** automatic updates have been implemented. When a software update is available, Artemis will download the new version and install the updates automatically
|
- **Windows:** automatic updates have been implemented. When a software update is available, Artemis will download the new version and install the updates automatically
|
||||||
|
- Multiple sigID databases can be conserved. In the case of autoload, the latest local version will be loaded
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Improved readability of labels for filter ranges for frequency, bandwidth, and ACF
|
- Improved readability of labels for filter ranges for frequency, bandwidth, and ACF
|
||||||
- Improved Update manager and Downloader functionalities
|
- Improved Update manager and Downloader functionalities
|
||||||
- OS dependent temporary folders are now used for database download and artemis updates
|
- OS dependent temporary folders are now used for database download and artemis updates
|
||||||
|
- The logic for searching the last sigID database has changed, now the discriminant is no longer the folder name but is reported as a signature in the database itself (-1 in the editable field, see documentation)
|
||||||
|
- Old sigID databases are not deleted anymore when a new version is downloaded. This is to avoid removing databases with user changes or additions
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Added a database load check to avoid (non critical) exceptions when applying filters without having loaded a database.
|
- Added a database load check to avoid (non critical) exceptions when applying filters without having loaded a database.
|
||||||
- Fixed a potential issue involing the forcibly closure of downloader window but the downloader instance keeps running
|
- Fixed a potential issue involing the forcibly closure of downloader window but the downloader instance keeps running
|
||||||
|
- With the new logic in the latest sigID database search, manually imported sigID databases are officially recognized as proper ones
|
||||||
|
|
||||||
## [4.0.3] - 2024-06-10
|
## [4.0.3] - 2024-06-10
|
||||||
|
|
||||||
|
|||||||
@@ -345,10 +345,13 @@ class UIArtemis(QObject):
|
|||||||
|
|
||||||
|
|
||||||
def autoload_db(self):
|
def autoload_db(self):
|
||||||
sig_id_path = DATA_DIR / 'SigID' / Constants.SQL_NAME
|
""" This will autoload the latest local sigID DB, if present
|
||||||
|
according to the user settings
|
||||||
|
"""
|
||||||
|
sig_id_db = self.dbmanager.get_latest_local_sigid_db()
|
||||||
autoload = CONFIGURE_QT.value("Database", "autoload", 0)
|
autoload = CONFIGURE_QT.value("Database", "autoload", 0)
|
||||||
if sig_id_path.exists() and int(autoload):
|
if sig_id_db is not None and int(autoload):
|
||||||
self.load_db('SigID')
|
self.load_db(sig_id_db.db_dir_name)
|
||||||
|
|
||||||
|
|
||||||
def dialog_popup(self, message_type, title, message):
|
def dialog_popup(self, message_type, title, message):
|
||||||
|
|||||||
@@ -49,8 +49,22 @@ class UIdbmanager(QObject):
|
|||||||
def load_local_db_list(self):
|
def load_local_db_list(self):
|
||||||
""" Scan for all the valid DBs in the data folder and show them on the list
|
""" Scan for all the valid DBs in the data folder and show them on the list
|
||||||
"""
|
"""
|
||||||
|
db_param = []
|
||||||
valid_db_list = self.scan_db_dir()
|
valid_db_list = self.scan_db_dir()
|
||||||
self.populate_db_list.emit(valid_db_list)
|
|
||||||
|
for db in valid_db_list:
|
||||||
|
db_param.append(
|
||||||
|
{
|
||||||
|
'name': db.name,
|
||||||
|
'db_dir_name': db.db_dir_name,
|
||||||
|
'documents_n': db.stats['documents'],
|
||||||
|
'signals_n': db.stats['signals'],
|
||||||
|
'images_n': db.stats['images'],
|
||||||
|
'audio_n': db.stats['audio']
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.populate_db_list.emit(db_param)
|
||||||
|
|
||||||
|
|
||||||
def load_db(self, db_dir_name):
|
def load_db(self, db_dir_name):
|
||||||
@@ -85,7 +99,7 @@ class UIdbmanager(QObject):
|
|||||||
|
|
||||||
def scan_db_dir(self):
|
def scan_db_dir(self):
|
||||||
""" Scans the data directory for valid databases and
|
""" Scans the data directory for valid databases and
|
||||||
return a dictionary containing only the valid ones with a summary
|
return a dictionary containing only the (already loaded) valid ones
|
||||||
"""
|
"""
|
||||||
valid_db_list = []
|
valid_db_list = []
|
||||||
db_dirs = next(os.walk(DATA_DIR))[1]
|
db_dirs = next(os.walk(DATA_DIR))[1]
|
||||||
@@ -94,20 +108,25 @@ class UIdbmanager(QObject):
|
|||||||
if self._valid_db(db_dir_name):
|
if self._valid_db(db_dir_name):
|
||||||
database = ArtemisDatabase(db_dir_name)
|
database = ArtemisDatabase(db_dir_name)
|
||||||
database.load()
|
database.load()
|
||||||
valid_db_list.append(
|
valid_db_list.append(database)
|
||||||
{
|
|
||||||
'name': database.name,
|
|
||||||
'db_dir_name': database.db_dir_name,
|
|
||||||
'documents_n': database.stats['documents'],
|
|
||||||
'signals_n': database.stats['signals'],
|
|
||||||
'images_n': database.stats['images'],
|
|
||||||
'audio_n': database.stats['audio']
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
return valid_db_list
|
return valid_db_list
|
||||||
|
|
||||||
|
|
||||||
|
def get_latest_local_sigid_db(self):
|
||||||
|
""" Return the newest valid local sigID database.
|
||||||
|
Returns None if no valid sigID database is found.
|
||||||
|
"""
|
||||||
|
valid_dbs = self._parent.dbmanager.scan_db_dir()
|
||||||
|
sig_id_dbs = [db for db in valid_dbs if db.editable == -1]
|
||||||
|
|
||||||
|
if len(sig_id_dbs) != 0:
|
||||||
|
sig_id_latest = max(sig_id_dbs, key=lambda x: x.version)
|
||||||
|
return sig_id_latest
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _valid_db(self, db_dir_name):
|
def _valid_db(self, db_dir_name):
|
||||||
""" Checks if db_dir_name is a valid db dir containing a `data.sqlite` file.
|
""" 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
|
Db must be valid as well and should be properly initialized and loaded with
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class ArtemisDatabase(Database):
|
|||||||
""" Create new db in the data folder.
|
""" Create new db in the data folder.
|
||||||
The name of folder containing the new db has a unique id as name (db_dir_name).
|
The name of folder containing the new db has a unique id as name (db_dir_name).
|
||||||
"""
|
"""
|
||||||
meta = [name, datetime.now(), 0, 0]
|
meta = [name, datetime.now(), 1, 1]
|
||||||
os.makedirs(self.db_dir)
|
os.makedirs(self.db_dir)
|
||||||
os.makedirs(self.media_dir)
|
os.makedirs(self.media_dir)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import uuid
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from packaging.version import Version
|
from packaging.version import Version
|
||||||
@@ -15,7 +16,6 @@ class UpdateManager:
|
|||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
self.sigid_db_path = DATA_DIR / 'SigID' / Constants.SQL_NAME
|
|
||||||
|
|
||||||
self.db_update = None
|
self.db_update = None
|
||||||
self.art_update = None
|
self.art_update = None
|
||||||
@@ -45,7 +45,7 @@ class UpdateManager:
|
|||||||
"""
|
"""
|
||||||
latest_json = self.fetch_remote_json(Constants.LATEST_VERSION_URL, show_popup)
|
latest_json = self.fetch_remote_json(Constants.LATEST_VERSION_URL, show_popup)
|
||||||
if latest_json:
|
if latest_json:
|
||||||
local_db = self._load_local_db()
|
local_db = self._parent.dbmanager.get_latest_local_sigid_db()
|
||||||
remote_db = latest_json['sigID_DB']
|
remote_db = latest_json['sigID_DB']
|
||||||
|
|
||||||
self.remote_db_version = remote_db['version']
|
self.remote_db_version = remote_db['version']
|
||||||
@@ -104,16 +104,6 @@ class UpdateManager:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _load_local_db(self):
|
|
||||||
""" Loads the local database if exists
|
|
||||||
"""
|
|
||||||
if os.path.exists(self.sigid_db_path):
|
|
||||||
local_db = ArtemisDatabase('SigID')
|
|
||||||
local_db.load()
|
|
||||||
return local_db
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def download_db(self):
|
def download_db(self):
|
||||||
""" Open the downloader and download the sigID database in the
|
""" Open the downloader and download the sigID database in the
|
||||||
TMP_DIR folder. After a succesfull download the callback function
|
TMP_DIR folder. After a succesfull download the callback function
|
||||||
@@ -133,9 +123,9 @@ class UpdateManager:
|
|||||||
"""
|
"""
|
||||||
latest_db_tar_path = TMP_DIR / self.remote_db_file_name
|
latest_db_tar_path = TMP_DIR / self.remote_db_file_name
|
||||||
if match_hash(latest_db_tar_path, self.remote_db_hash):
|
if match_hash(latest_db_tar_path, self.remote_db_hash):
|
||||||
delete_dir(DATA_DIR / 'SigID')
|
db_dir_name = str(uuid.uuid4())
|
||||||
unpack_tar(latest_db_tar_path, DATA_DIR / 'SigID')
|
unpack_tar(latest_db_tar_path, DATA_DIR / db_dir_name)
|
||||||
self._parent.load_db('SigID')
|
self._parent.load_db(db_dir_name)
|
||||||
self._show_popup_db_download_complete()
|
self._show_popup_db_download_complete()
|
||||||
else:
|
else:
|
||||||
self._show_popup_db_hash_failed()
|
self._show_popup_db_hash_failed()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"sigID_DB": {
|
"sigID_DB": {
|
||||||
"version": 61,
|
"version": 61,
|
||||||
"url": "https://github.com/AresValley/Artemis-DB/releases/download/v61/v61.tar",
|
"url": "https://github.com/AresValley/Artemis-DB/releases/download/v61/v61.tar",
|
||||||
"sha256_hash": "c65d2ab65e9420cd7789190c100abef2f1575ea15489776c2d97b5b09cdc8410",
|
"sha256_hash": "da4d0f56924940f90b86349bf7a22a478bcf08e969d8de2bcb34e2939e74c885",
|
||||||
"total_bytes": 244449280
|
"total_bytes": 244449280
|
||||||
},
|
},
|
||||||
"windows": {
|
"windows": {
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ A simple integer to denote the database version.
|
|||||||
|
|
||||||
This field should serve as a writing protection on the database.
|
This field should serve as a writing protection on the database.
|
||||||
|
|
||||||
|
* **-1**: reserved to sigID database. This is the primary way to distinguish a valid sigID database
|
||||||
* **0**: read-only database
|
* **0**: read-only database
|
||||||
* **1**: database can be edited with no restrictions
|
* **1**: database can be edited with no restrictions
|
||||||
|
|
||||||
!!! example "Experimental"
|
|
||||||
This feature is experimental and not yet implemented.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user