Added configuration file handler and updated apps

This commit is contained in:
2021-11-18 07:23:23 -05:00
parent 19d85aebfe
commit 5d1e98eee6
3 changed files with 46 additions and 38 deletions

View File

@ -19,7 +19,7 @@ from PySide2.QtCore import QObject, Slot, Signal, QThread, QDir
from MainWindow import Ui_MainWindow
config_file = "vcones.yaml"
from utils.configs import *
##############################################################################
# audio stuff
@ -67,6 +67,8 @@ def roydistance(lat1, lon1, lat2, lon2):
# log
##############################################################################
cfg = ConfigurationFile(__file__)
if not os.path.isdir("logs"):
mkdir("logs")
@ -558,17 +560,15 @@ class ConesWindow(MainWindow):
self.save_list(5)
def save_config(self):
with open(config_file, 'w') as f:
config = {}
if gpsd_host != "localhost":
config['gpsd_host'] = gpsd_host
config['lists'] = []
for i in range(0, 6):
if self.labels[i].text() != "":
self.save_list(i)
config['lists'].append( self.labels[i].text() )
f.write(yaml.dump(config))
f.close()
config = {}
if gpsd_host != "localhost":
config['gpsd_host'] = gpsd_host
config['lists'] = []
for i in range(0, 6):
if self.labels[i].text() != "":
self.save_list(i)
config['lists'].append( self.labels[i].text() )
cfg.write_config(config)
def save_log(self):
if self.num_points:
@ -592,12 +592,9 @@ if __name__ == '__main__':
window = ConesWindow()
window.show()
config = []
if os.path.isfile(config_file):
with open(config_file) as f:
config = yaml.load(f, Loader=yaml.FullLoader)
if 'gpsd_host' in config:
gpsd_host = config['gpsd_host']
config = cfg.read_config()
if 'gpsd_host' in config:
gpsd_host = config['gpsd_host']
if len(sys.argv[1:]):
window.load_cones(sys.argv[1:])