Logging and debug improvements
This commit is contained in:
1 parent
b05d9bca2d
commit
268cf439e7
2 files changed
+14
-12
No files matched your search
Vendored
+3
-3
@@ -16,7 +16,7 @@
|
|||||||
"type": "python",
|
"type": "python",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "main.py",
|
"program": "main.py",
|
||||||
"args": ["--debug", "-vv"],
|
"args": ["--no-run-check", "-vv"],
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"justMyCode": false
|
"justMyCode": false
|
||||||
},
|
},
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
"type": "python",
|
"type": "python",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "main.py",
|
"program": "main.py",
|
||||||
"args": ["--debug", "-vvv"],
|
"args": ["--no-run-check", "-vvv"],
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"justMyCode": false
|
"justMyCode": false
|
||||||
},
|
},
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"type": "python",
|
"type": "python",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "main.py",
|
"program": "main.py",
|
||||||
"args": ["--debug", "-vvv", "--debug-ws"],
|
"args": ["--no-run-check", "-vvv", "--debug-ws"],
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"justMyCode": false
|
"justMyCode": false
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class ParsedArgs(argparse.Namespace):
|
|||||||
log: bool
|
log: bool
|
||||||
idle: bool
|
idle: bool
|
||||||
tray: bool
|
tray: bool
|
||||||
debug: bool
|
no_run_check: bool
|
||||||
game: Optional[str]
|
game: Optional[str]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -32,7 +32,7 @@ class ParsedArgs(argparse.Namespace):
|
|||||||
1: logging.WARNING,
|
1: logging.WARNING,
|
||||||
2: logging.INFO,
|
2: logging.INFO,
|
||||||
3: logging.DEBUG,
|
3: logging.DEBUG,
|
||||||
}.get(self._verbose, logging.DEBUG)
|
}[min(self._verbose, 3)]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def debug_ws(self) -> int:
|
def debug_ws(self) -> int:
|
||||||
@@ -65,13 +65,13 @@ parser = argparse.ArgumentParser(
|
|||||||
)
|
)
|
||||||
parser.add_argument("--version", action="version", version=f"v{__version__}")
|
parser.add_argument("--version", action="version", version=f"v{__version__}")
|
||||||
parser.add_argument("-v", dest="_verbose", action="count", default=0)
|
parser.add_argument("-v", dest="_verbose", action="count", default=0)
|
||||||
parser.add_argument("--debug", dest="debug", action="store_true")
|
parser.add_argument("--no-run-check", dest="no_run_check", action="store_true")
|
||||||
parser.add_argument("--debug-ws", dest="_debug_ws", action="store_true")
|
parser.add_argument("--debug-ws", dest="_debug_ws", action="store_true")
|
||||||
parser.add_argument("--debug-gql", dest="_debug_gql", action="store_true")
|
parser.add_argument("--debug-gql", dest="_debug_gql", action="store_true")
|
||||||
parser.add_argument("-g", "--game", default=None)
|
parser.add_argument("-g", "--game", default=None)
|
||||||
parser.add_argument("--idle", action="store_true")
|
parser.add_argument("--idle", action="store_true")
|
||||||
parser.add_argument("--tray", action="store_true")
|
parser.add_argument("--tray", action="store_true")
|
||||||
parser.add_argument("-l", "--log", action="store_true")
|
parser.add_argument("--log", action="store_true")
|
||||||
options: ParsedArgs = parser.parse_args(namespace=ParsedArgs())
|
options: ParsedArgs = parser.parse_args(namespace=ParsedArgs())
|
||||||
# check if we're not already running
|
# check if we're not already running
|
||||||
try:
|
try:
|
||||||
@@ -79,7 +79,7 @@ try:
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
# we're not on Windows - continue
|
# we're not on Windows - continue
|
||||||
exists = False
|
exists = False
|
||||||
if exists and not options.debug:
|
if exists and not options.no_run_check:
|
||||||
# already running - exit
|
# already running - exit
|
||||||
sys.exit()
|
sys.exit()
|
||||||
# handle logging stuff
|
# handle logging stuff
|
||||||
@@ -104,13 +104,15 @@ signal.signal(signal.SIGTERM, lambda *_: client.close())
|
|||||||
try:
|
try:
|
||||||
loop.run_until_complete(client.run())
|
loop.run_until_complete(client.run())
|
||||||
except CaptchaRequired:
|
except CaptchaRequired:
|
||||||
|
msg = "Your login attempt was denied by CAPTCHA.\nPlease try again in +12 hours."
|
||||||
|
logger.exception(msg)
|
||||||
client.prevent_close()
|
client.prevent_close()
|
||||||
client.print(
|
client.print(msg)
|
||||||
"Your login attempt was denied by CAPTCHA.\nPlease try again in +12 hours."
|
|
||||||
)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
|
msg = "Fatal error encountered:\n"
|
||||||
|
logger.exception(msg)
|
||||||
client.prevent_close()
|
client.prevent_close()
|
||||||
client.print("Fatal error encountered:\n")
|
client.print(msg)
|
||||||
client.print(traceback.format_exc())
|
client.print(traceback.format_exc())
|
||||||
finally:
|
finally:
|
||||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
|
|||||||
Reference in new issue
Block a user