system_config
This module is used to locate files on the current PC regardless of OS, user, etc. Useful for finding application documents like the configuration .toml files and program icon at the Photologic-Experiment-Rig-Files directory under the users documents folder.
1""" 2This module is used to locate files on the current PC regardless of OS, user, etc. 3Useful for finding application documents like the configuration .toml files and program icon at the 4Photologic-Experiment-Rig-Files directory under the users documents folder. 5""" 6 7import os 8import platform 9 10 11def get_documents_dir(): 12 """ 13 This method grabs the documents directory for the current user of the PC in use. 14 """ 15 current_os = platform.system() 16 17 if current_os == "Windows": 18 return os.path.join(os.getenv("USERPROFILE"), "Documents") 19 elif current_os == "Linux": 20 return os.path.join(os.getenv("HOME"), "Documents") 21 22 23def get_assets_path(): 24 """ 25 This method grabs the assets directory under the Photologic-Experiment-Rig-Files directory for current user of the PC in use. 26 Grabs documents folder first, then Photologic-Experiment-Rig-Files, then assets. Useful to grab rat.ico and config files. 27 """ 28 documents_dir = get_documents_dir() 29 30 assets_dir = os.path.join( 31 documents_dir, "Photologic-Experiment-Rig-Files", "assets" 32 ) 33 return assets_dir 34 35 36def get_rig_config(): 37 """ 38 utilizes previous methods to grab the rig configuration toml file. 39 """ 40 documents_dir = get_documents_dir() 41 42 toml_config_path = os.path.join( 43 documents_dir, "Photologic-Experiment-Rig-Files", "assets", "rig_config.toml" 44 ) 45 return toml_config_path 46 47 48def get_log_path(file_name: str): 49 """ 50 utilizes previous methods to grab the logfile directory. 51 """ 52 documents_dir = get_documents_dir() 53 54 log_dir = os.path.join(documents_dir, "Photologic-Experiment-Rig-Files", "logfiles") 55 56 logfile_path = os.path.join(log_dir, f"{file_name}.txt") 57 58 return logfile_path 59 60 61def get_valve_durations(): 62 """ 63 utilizes previous methods to grab the valve duration configurtion toml file. this is used to store durations long term for the Arduino. 64 """ 65 documents_dir = get_documents_dir() 66 67 log_dir = os.path.join(documents_dir, "Photologic-Experiment-Rig-Files", "assets") 68 69 durations_path = os.path.join(log_dir, "valve_durations.toml") 70 71 return durations_path
12def get_documents_dir(): 13 """ 14 This method grabs the documents directory for the current user of the PC in use. 15 """ 16 current_os = platform.system() 17 18 if current_os == "Windows": 19 return os.path.join(os.getenv("USERPROFILE"), "Documents") 20 elif current_os == "Linux": 21 return os.path.join(os.getenv("HOME"), "Documents")
This method grabs the documents directory for the current user of the PC in use.
24def get_assets_path(): 25 """ 26 This method grabs the assets directory under the Photologic-Experiment-Rig-Files directory for current user of the PC in use. 27 Grabs documents folder first, then Photologic-Experiment-Rig-Files, then assets. Useful to grab rat.ico and config files. 28 """ 29 documents_dir = get_documents_dir() 30 31 assets_dir = os.path.join( 32 documents_dir, "Photologic-Experiment-Rig-Files", "assets" 33 ) 34 return assets_dir
This method grabs the assets directory under the Photologic-Experiment-Rig-Files directory for current user of the PC in use. Grabs documents folder first, then Photologic-Experiment-Rig-Files, then assets. Useful to grab rat.ico and config files.
37def get_rig_config(): 38 """ 39 utilizes previous methods to grab the rig configuration toml file. 40 """ 41 documents_dir = get_documents_dir() 42 43 toml_config_path = os.path.join( 44 documents_dir, "Photologic-Experiment-Rig-Files", "assets", "rig_config.toml" 45 ) 46 return toml_config_path
utilizes previous methods to grab the rig configuration toml file.
49def get_log_path(file_name: str): 50 """ 51 utilizes previous methods to grab the logfile directory. 52 """ 53 documents_dir = get_documents_dir() 54 55 log_dir = os.path.join(documents_dir, "Photologic-Experiment-Rig-Files", "logfiles") 56 57 logfile_path = os.path.join(log_dir, f"{file_name}.txt") 58 59 return logfile_path
utilizes previous methods to grab the logfile directory.
62def get_valve_durations(): 63 """ 64 utilizes previous methods to grab the valve duration configurtion toml file. this is used to store durations long term for the Arduino. 65 """ 66 documents_dir = get_documents_dir() 67 68 log_dir = os.path.join(documents_dir, "Photologic-Experiment-Rig-Files", "assets") 69 70 durations_path = os.path.join(log_dir, "valve_durations.toml") 71 72 return durations_path
utilizes previous methods to grab the valve duration configurtion toml file. this is used to store durations long term for the Arduino.