[config] improve --config-status
- remove 'Not Present' output - add debug logs for exceptions - use correct type when reporting invalid data
This commit is contained in:
@@ -155,13 +155,15 @@ def status():
|
|||||||
with open(path, encoding="utf-8") as fp:
|
with open(path, encoding="utf-8") as fp:
|
||||||
_load(fp.read())
|
_load(fp.read())
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
status = "Not Present"
|
status = ""
|
||||||
except OSError:
|
except OSError as exc:
|
||||||
|
log.debug("%s: %s", exc.__class__.__name__, exc)
|
||||||
status = "Inaccessible"
|
status = "Inaccessible"
|
||||||
except ValueError:
|
except ValueError as exc:
|
||||||
status = "Invalid JSON"
|
log.debug("%s: %s", exc.__class__.__name__, exc)
|
||||||
|
status = "Invalid " + _type.upper()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
log.debug(exc)
|
log.debug("%s: %s", exc.__class__.__name__, exc)
|
||||||
status = "Unknown"
|
status = "Unknown"
|
||||||
else:
|
else:
|
||||||
status = "OK"
|
status = "OK"
|
||||||
@@ -169,7 +171,6 @@ def status():
|
|||||||
paths.append((path, status))
|
paths.append((path, status))
|
||||||
|
|
||||||
fmt = f"{{:<{max(len(p[0]) for p in paths)}}} : {{}}\n".format
|
fmt = f"{{:<{max(len(p[0]) for p in paths)}}} : {{}}\n".format
|
||||||
|
|
||||||
for path, status in paths:
|
for path, status in paths:
|
||||||
stdout_write(fmt(path, status))
|
stdout_write(fmt(path, status))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user