Improved handling of partially missing parameters
This commit is contained in:
parent
b23d4751e1
commit
93d8723b98
|
@ -94,17 +94,21 @@ class ProxmoxAPI(object):
|
||||||
os.path.dirname(os.path.abspath(__file__)),
|
os.path.dirname(os.path.abspath(__file__)),
|
||||||
os.path.splitext(os.path.basename(__file__))[0]+".json"
|
os.path.splitext(os.path.basename(__file__))[0]+".json"
|
||||||
)
|
)
|
||||||
|
if not options.url or not options.username or not options.password:
|
||||||
if os.path.isfile(config_path):
|
if os.path.isfile(config_path):
|
||||||
with open(config_path, "r") as config_file:
|
with open(config_path, "r") as config_file:
|
||||||
config_data = json.load(config_file)
|
config_data = json.load(config_file)
|
||||||
|
if not options.url:
|
||||||
try:
|
try:
|
||||||
options.url = config_data["url"]
|
options.url = config_data["url"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
options.url = None
|
options.url = None
|
||||||
|
if not options.username:
|
||||||
try:
|
try:
|
||||||
options.username = config_data["username"]
|
options.username = config_data["username"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
options.username = None
|
options.username = None
|
||||||
|
if not options.password:
|
||||||
try:
|
try:
|
||||||
options.password = config_data["password"]
|
options.password = config_data["password"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
Reference in New Issue