forked from f-klubben/stregsystemet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_utils.py
More file actions
32 lines (23 loc) · 977 Bytes
/
setup_utils.py
File metadata and controls
32 lines (23 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import debugpy
waitForDebugArg = "--waitForDebug"
debugPort = 5678
def check_for_debugger(args: list[str]) -> list[str]:
"""
Checks whether a debugger is expected and if so waits for it. Return the args not containing the waitForDebugArg.
"""
if waitForDebugArg in args:
listen_and_wait_for_debugger()
args.remove(waitForDebugArg)
return args
def listen_and_wait_for_debugger():
"""
Listens for a debugger to attach and waits until it does.
"""
attachDebuggerNotification = f"###\n Waiting for debugger on port {debugPort}! Either attach a debugger or run without the '{waitForDebugArg}' arg. \n###"
print(attachDebuggerNotification)
debugpy.listen(("localhost", debugPort))
debugpy.wait_for_client() # execution pauses until VS Code attaches
debuggerAttachedNotification = (
"###\n Debugger attached! Happy debugging d=====( ̄▽ ̄*)b \n###"
)
print(debuggerAttachedNotification)