From f234ae030009f4da5d65e3d8fe33045ac10d5748 Mon Sep 17 00:00:00 2001 From: Daniel Wortmann Date: Wed, 29 May 2024 16:14:22 +0200 Subject: [PATCH] Bugfixes in default handling of CLI --- aiida_fleur/cmdline/util/__init__.py | 2 ++ aiida_fleur/cmdline/util/defaults.py | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/aiida_fleur/cmdline/util/__init__.py b/aiida_fleur/cmdline/util/__init__.py index dce99968..75623123 100755 --- a/aiida_fleur/cmdline/util/__init__.py +++ b/aiida_fleur/cmdline/util/__init__.py @@ -30,6 +30,8 @@ def cmd_defaults(): dict["fleur"]=get_code_interactive("fleur.fleur",dict["fleur"]) dict["inpgen"]=get_code_interactive("fleur.inpgen",dict["inpgen"]) + import os + HOME=os.getenv("HOME") try: os.mkdir(f"{HOME}/.aiida-fleur") except: diff --git a/aiida_fleur/cmdline/util/defaults.py b/aiida_fleur/cmdline/util/defaults.py index fac0a230..6cf7e195 100644 --- a/aiida_fleur/cmdline/util/defaults.py +++ b/aiida_fleur/cmdline/util/defaults.py @@ -99,18 +99,17 @@ def get_fept_film_structure(): # Codes def get_inpgen(): """Return a `Code` node of the latest added inpgen executable in the database.""" - try: - return get_default_dict()["inpgen"] - except: - return get_last_code('fleur.inpgen') - + inpgen=get_default_dict()["inpgen"] + if inpgen==None: + inpgen=get_last_code("fleur.inpgen") + return inpgen def get_fleur(): """Return a `Code` node of the latest added inpgen executable in the database.""" - try: - return get_default_dict()["fleur"] - except: - return get_last_code('fleur.fleur') + fleur=fleur=get_default_dict()["fleur"] + if fleur==None: + fleur=get_last_code('fleur.fleur') + return fleur