Minor fix of logging
This commit is contained in:
11
.gitignore
vendored
11
.gitignore
vendored
@ -1,11 +1,16 @@
|
|||||||
/src/__pycache__
|
/src/__pycache__
|
||||||
/res
|
|
||||||
/.venv
|
/.venv
|
||||||
|
/.vscode
|
||||||
|
|
||||||
|
/res
|
||||||
!/res/examples
|
!/res/examples
|
||||||
!/res/examples/*
|
!/res/examples/*
|
||||||
!/res/examples_git/
|
!/res/examples_git/
|
||||||
!/res/examples_git/*
|
!/res/examples_git/*
|
||||||
|
|
||||||
/doc
|
/doc
|
||||||
/.vscode
|
|
||||||
/conf
|
/conf
|
||||||
!/conf/conf.json
|
/conf/*
|
||||||
|
!/conf/db.json
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ def save_preset(filters, params, preset_name):
|
|||||||
new_filt = []
|
new_filt = []
|
||||||
for i, filter in enumerate(filt):
|
for i, filter in enumerate(filt):
|
||||||
new_filt.append(filt[filter])
|
new_filt.append(filt[filter])
|
||||||
|
log.print_message("Saving filters as:", preset_name)
|
||||||
|
|
||||||
# Store preset to database
|
# Store preset to database
|
||||||
store_to_db(new_filt, preset_name)
|
store_to_db(new_filt, preset_name)
|
||||||
@ -45,14 +46,14 @@ def store_to_db(preset, preset_name):
|
|||||||
preset = json.loads(preset)
|
preset = json.loads(preset)
|
||||||
|
|
||||||
# If database doesn't exist, create it
|
# 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")
|
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)
|
json.dump(preset, db)
|
||||||
else:
|
else:
|
||||||
# If database exists, load it and check if preset already exists
|
# If database exists, load it and check if preset already exists
|
||||||
try:
|
try:
|
||||||
with open("db.json", 'r') as db:
|
with open("conf/db.json", 'r') as db:
|
||||||
db_presets = json.load(db)
|
db_presets = json.load(db)
|
||||||
|
|
||||||
# Empty file is an error, so we don't read it
|
# 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)
|
db_presets.update(preset)
|
||||||
|
|
||||||
# Finally write the updated entries to db file
|
# 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)
|
json.dump(db_presets, db, indent=4)
|
||||||
|
|
||||||
|
|
||||||
@ -91,10 +92,11 @@ def parse_conf(preset_name, filters, params, config_file):
|
|||||||
if attribute != "name":
|
if attribute != "name":
|
||||||
params[i][attribute] = value
|
params[i][attribute] = value
|
||||||
parse_params(params[i])
|
parse_params(params[i])
|
||||||
|
|
||||||
log.print_message("Loaded preset:", preset_name,
|
log.print_message("Loaded preset:", preset_name,
|
||||||
"from file:", config_file)
|
"from file:", config_file)
|
||||||
else:
|
else:
|
||||||
log.print_message("Preset not found")
|
log.print_message("Warning: Preset not found in config file")
|
||||||
|
|
||||||
|
|
||||||
def parse_params(params):
|
def parse_params(params):
|
||||||
|
@ -22,7 +22,7 @@ import filters as flt
|
|||||||
import config_parser as cp
|
import config_parser as cp
|
||||||
import log
|
import log
|
||||||
|
|
||||||
class app:
|
class fingerprint_app:
|
||||||
'''Main class for the application.
|
'''Main class for the application.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@ -58,6 +58,7 @@ class app:
|
|||||||
self.params[filter_index][key] = value
|
self.params[filter_index][key] = value
|
||||||
|
|
||||||
cp.parse_params(self.params[filter_index])
|
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:
|
if self.args.database:
|
||||||
cp.save_preset(self.filters, self.params, self.args.database[0])
|
cp.save_preset(self.filters, self.params, self.args.database[0])
|
||||||
@ -724,4 +725,4 @@ class app:
|
|||||||
self.write_stl_header()
|
self.write_stl_header()
|
||||||
|
|
||||||
|
|
||||||
app()
|
fingerprint_app()
|
||||||
|
Reference in New Issue
Block a user