forked from zietzm/Helmholtz_Test_Bench
Config file is now saved/loaded from an Appdata directory.
This commit is contained in:
@@ -13,15 +13,14 @@ import src.csv_logging as log
|
||||
from src.magnetometer import MagnetometerProxy
|
||||
from src.user_interface import HelmholtzGUI
|
||||
from src.socket_control import SocketInterfaceThread
|
||||
from src.utility import ui_print, save_dict_list_to_csv
|
||||
from src.utility import ui_print
|
||||
|
||||
|
||||
def program_start():
|
||||
""" Application entry point """
|
||||
print("Starting application")
|
||||
|
||||
config.CONFIG_FILE = 'config.ini' # set the config file path
|
||||
# ToDo: remember what the last config file was
|
||||
config.CONFIG_FILE = config.get_default_config_path() # set the config file path
|
||||
if not exists(config.CONFIG_FILE): # config file does not exist yet
|
||||
print("Config file not found, creating new from defaults.")
|
||||
config.reset_config_to_default() # create configuration object from defaults
|
||||
|
||||
+13
-5
@@ -1,6 +1,14 @@
|
||||
appdirs==1.4.4
|
||||
cycler==0.10.0
|
||||
future==0.18.2
|
||||
kiwisolver==1.3.2
|
||||
matplotlib==3.3.4
|
||||
numpy==1.19.3
|
||||
pyserial~=3.5
|
||||
future~=0.18.2
|
||||
pandas~=1.1.5
|
||||
matplotlib~=3.3.2
|
||||
scipy
|
||||
pandas==1.1.5
|
||||
Pillow==8.4.0
|
||||
pyparsing==2.4.7
|
||||
pyserial==3.5
|
||||
python-dateutil==2.8.2
|
||||
pytz==2021.3
|
||||
scipy==1.7.1
|
||||
six==1.16.0
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
# The configparser module is used for processing. Config files are of type .ini
|
||||
|
||||
# import packages:
|
||||
import pathlib
|
||||
import appdirs
|
||||
from configparser import ConfigParser
|
||||
from tkinter import messagebox
|
||||
|
||||
@@ -132,3 +134,9 @@ def reset_config_to_default(): # reset values in config object to defaults (set
|
||||
config.add_section("Supplies") # add section for PSU serial ports
|
||||
for key in g.default_psu_config.keys(): # go through dictionary of default serial ports
|
||||
config.set("Supplies", key, str(g.default_psu_config[key])) # set the value for each axis
|
||||
|
||||
|
||||
def get_default_config_path():
|
||||
config_folder = pathlib.Path(appdirs.user_config_dir(appname="helmholtz_test_bench", appauthor="IRS"))
|
||||
config_folder.mkdir(parents=True, exist_ok=True)
|
||||
return str(config_folder.joinpath("config.ini"))
|
||||
|
||||
Reference in New Issue
Block a user