"certificate": ""
}
-with open(config_file) as conf:
- read = json.loads(conf.read())
-
-config = default | read
+try:
+ with open(config_file) as conf:
+ read = json.loads(conf.read())
+ config = default | read
+except Exception as e:
+ print(e)
+ config=default
config["filename"]=args.filename
config["data_directory"]=os.path.abspath(os.path.join(real_dir, os.path.expanduser(config["data_directory"])))
if (not config["prescriber"].endswith(".json")): config["prescriber"]=config["prescriber"]+".json"
else:
if(not os.path.isabs(args.prescriber)):
- args.prescriber=os.path.join(config["config_directory"], args.prescriber)
+ args.prescriber=os.path.join(config["prescriber_directory"], args.prescriber)
if(os.path.isfile(args.prescriber)):
config["prescriber"]=args.prescriber
else:
- config["prescriber"]=os.path.join(config["config_directory"], config["prescriber"])
+ config["prescriber"]=os.path.join(config["prescriber_directory"], config["prescriber"])
print("File "+args.prescriber+" not found.")
os.makedirs(config["data_directory"], exist_ok=True)
def write_to(self, file):
with open(file, "w") as f:
- del self.file
+ try:
+ del self.file
+ except Exception as e:
+ print(e)
f.write(self.get_json())
self.file=file
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
- with open(config_file) as f:
- self.config=json.loads(f.read())
- self.config=self.config|config
+ try:
+ with open(config_file) as f:
+ self.config=json.loads(f.read())
+ except Exception as e:
+ print(e)
+ self.config=config
self.setWindowTitle("MedScript")
self.setGeometry(200, 200, 300, 200)
toolbar.addSeparator()
self.input_template=QComboBox(self)
templates=os.listdir(config["template_directory"])
- templates.remove(os.path.basename(config["template"]))
- templates.insert(0, os.path.basename(config["template"]))
+ try:
+ templates.remove(os.path.basename(config["template"]))
+ templates.insert(0, os.path.basename(config["template"]))
+ except Exception as e:
+ print(e)
self.input_template.addItems(templates)
toolbar.addWidget(self.input_template)
spacer=QWidget(self)