Fix small issues, improve error handling and documentation
This commit is contained in:
@@ -4,6 +4,7 @@ import logging
|
||||
import sys
|
||||
|
||||
from client import command as cmd
|
||||
from httplib.exceptions import UnhandledHTTPCode
|
||||
|
||||
|
||||
def main():
|
||||
@@ -15,7 +16,7 @@ def main():
|
||||
|
||||
arguments = parser.parse_args()
|
||||
|
||||
logging.basicConfig(level=logging.ERROR - (10 * arguments.verbose), format="[%(levelname)s] %(message)s")
|
||||
logging.basicConfig(level=logging.INFO - (10 * arguments.verbose), format="[%(levelname)s] %(message)s")
|
||||
logging.debug("Arguments: %s", arguments)
|
||||
|
||||
command = cmd.create(arguments.command, arguments.URI, arguments.port)
|
||||
@@ -24,7 +25,10 @@ def main():
|
||||
|
||||
try:
|
||||
main()
|
||||
except UnhandledHTTPCode as e:
|
||||
print(f"[{e.status_code}] {e.cause}:\r\n{e.headers}")
|
||||
sys.exit(2)
|
||||
except Exception as e:
|
||||
print("[ABRT] Internal error: " + str(e), file=sys.stderr)
|
||||
logging.debug("Internal error", exc_info=e)
|
||||
sys.exit(70)
|
||||
sys.exit(1)
|
||||
|
Reference in New Issue
Block a user