aboutsummaryrefslogtreecommitdiffstats
path: root/src/generate_configuration.py
diff options
context:
space:
mode:
authorJoshua Shreve <j.a.shreve@gmail.com>2021-08-21 15:54:57 -0400
committerJoshua Shreve <j.a.shreve@gmail.com>2021-08-21 15:54:57 -0400
commit4c179f900053db8acb072cf6eb6e73b40293fea7 (patch)
treea4a043b49629cb897544128e73c27163d231f36c /src/generate_configuration.py
parent1f6206c9fe3bc7b85dd624550020452567921400 (diff)
parent3a74bee2fcd1561f5cf23a4f57fe41062203313e (diff)
Merge branch 'pr/30'
Diffstat (limited to 'src/generate_configuration.py')
-rw-r--r--src/generate_configuration.py30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/generate_configuration.py b/src/generate_configuration.py
index ee70e3b..79ef5b3 100644
--- a/src/generate_configuration.py
+++ b/src/generate_configuration.py
@@ -1,3 +1,6 @@
+import sys
+import getopt
+import os
import json
@@ -383,23 +386,18 @@ shape_config = {
####################################
def save_config():
- print("Saving Configuration")
- with open('run_config.json', mode='w') as fid:
- json.dump(shape_config, fid, indent=4)
-
-def update_config(fname, fname_out=None):
- if fname_out is None:
- fname_out == "updated_config.json"
- # Open existing config, update with any new parameters, and save to updated_config.json
- with open(fname, mode='r') as fid:
- last_shape_config = json.load(fid)
- shape_config.update(last_shape_config)
-
- with open(fname_out, mode='w') as fid:
+ # Check to see if the user has specified an alternate config
+ opts, args = getopt.getopt(sys.argv[1:], "", ["config="]);
+ for opt, arg in opts:
+ if opt in ('--config'):
+ # If a config file was specified, set the config_name and save_dir
+ shape_config['save_dir'] = arg
+ shape_config['config_name'] = arg
+
+ # Write the config to ./configs/<config_name>.json
+ with open(os.path.join(r"..", "configs", shape_config['config_name'] + '.json'), mode='w') as fid:
json.dump(shape_config, fid, indent=4)
if __name__ == '__main__':
- save_config()
- from dactyl_manuform import *
- run() \ No newline at end of file
+ save_config() \ No newline at end of file