Minor fix of logging

master
Rostislav Lán 2 years ago
parent 13fc747d63
commit ff792776ff

11
.gitignore vendored

@ -1,11 +1,16 @@
/src/__pycache__
/res
/.venv
/.vscode
/res
!/res/examples
!/res/examples/*
!/res/examples_git/
!/res/examples_git/*
/doc
/.vscode
/conf
!/conf/conf.json
/conf/*
!/conf/db.json

@ -26,6 +26,7 @@ def save_preset(filters, params, preset_name):
new_filt = []
for i, filter in enumerate(filt):
new_filt.append(filt[filter])
log.print_message("Saving filters as:", preset_name)
# Store preset to database
store_to_db(new_filt, preset_name)
@ -45,14 +46,14 @@ def store_to_db(preset, preset_name):
preset = json.loads(preset)
# If database doesn't exist, create it
if not exists("db.json"):
if not exists("conf/db.json"):
log.print_message("Storing preset to database")
with open("db.json", 'w') as db:
with open("conf/db.json", 'w') as db:
json.dump(preset, db)
else:
# If database exists, load it and check if preset already exists
try:
with open("db.json", 'r') as db:
with open("conf/db.json", 'r') as db:
db_presets = json.load(db)
# Empty file is an error, so we don't read it
@ -67,7 +68,7 @@ def store_to_db(preset, preset_name):
db_presets.update(preset)
# Finally write the updated entries to db file
with open("db.json", 'w') as db:
with open("conf/db.json", 'w') as db:
json.dump(db_presets, db, indent=4)
@ -91,10 +92,11 @@ def parse_conf(preset_name, filters, params, config_file):
if attribute != "name":
params[i][attribute] = value
parse_params(params[i])
log.print_message("Loaded preset:", preset_name,
"from file:", config_file)
else:
log.print_message("Preset not found")
log.print_message("Warning: Preset not found in config file")
def parse_params(params):

@ -22,7 +22,7 @@ import filters as flt
import config_parser as cp
import log
class app:
class fingerprint_app:
'''Main class for the application.
'''
@ -58,7 +58,8 @@ class app:
self.params[filter_index][key] = value
cp.parse_params(self.params[filter_index])
# If database flag is set, save filters to database as a new preset
# If database flag is set, save filters to database as a new preset
if self.args.database:
cp.save_preset(self.filters, self.params, self.args.database[0])
@ -724,4 +725,4 @@ class app:
self.write_stl_header()
app()
fingerprint_app()

Loading…
Cancel
Save