Commit a3bc3bc3 authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Improves the change config function in utils

Showing with 7 additions and 6 deletions
+7 -6
......@@ -27,6 +27,7 @@ HARDWARE_CONFIG = {
},
'rx' : {'model': 'ohmpi_card_3_15',
'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V
'sampling_rate': 10., # ms
'nb_samples': 20, # Max value 10 # was named integer before...
},
'mux': {'model' : 'dummy_mux', # 'ohmpi_i2c_mux64_v1.01',
......
......@@ -21,14 +21,14 @@ def get_platform():
return platform, on_pi
def change_config(config_file, verbose=True):
cwd = os.getcwd()
pwd = os.path.dirname(os.path.abspath(__file__))
try:
shutil.copyfile(f'{cwd}/OhmPi/config.py', f'{cwd}/OhmPi/config_tmp.py')
shutil.copyfile(f'{cwd}/OhmPi/{config_file}', f'{cwd}/OhmPi/config.py')
shutil.copyfile(f'{pwd}/config.py', f'{pwd}/config_tmp.py')
shutil.copyfile(f'{pwd}/{config_file}', f'{pwd}/config.py')
if verbose:
print(f'Changed to {cwd}/OhmPi/{config_file}:\n')
with open(f'{cwd}/OhmPi/config.py', mode='r') as f:
print(f'Changed to {pwd}/{config_file}:\n')
with open(f'{pwd}/config.py', mode='r') as f:
print(f.read())
except Exception as error:
print(f'Could not change config file to {cwd}/OhmPi/{config_file}:\n{error}')
\ No newline at end of file
print(f'Could not change config file to {pwd}/{config_file}:\n{error}')
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment