|
|
@ -39,9 +39,11 @@ class DebugScriptRunner(object): |
|
|
|
assert nsmClient |
|
|
|
self.nsmClient = nsmClient |
|
|
|
self.absoluteScriptFilePath = os.path.join(self.nsmClient.ourPath, "debugscript.py") |
|
|
|
|
|
|
|
logger.info(f"{self.nsmClient.ourClientNameUnderNSM}: Using script file: {self.absoluteScriptFilePath}") |
|
|
|
|
|
|
|
def _createEmptyDebugScript(self): |
|
|
|
assert self.absoluteScriptFilePath |
|
|
|
print(f"{self.nsmClient.ourClientNameUnderNSM}: Script file not found. Initializing: {self.absoluteScriptFilePath}") |
|
|
|
logger.info(f"{self.nsmClient.ourClientNameUnderNSM}: Script file not found. Initializing: {self.absoluteScriptFilePath}") |
|
|
|
text = ("""#! /usr/bin/env python3""" |
|
|
|
"\n" |
|
|
@ -54,14 +56,14 @@ class DebugScriptRunner(object): |
|
|
|
) |
|
|
|
|
|
|
|
with open(self.absoluteScriptFilePath, "w", encoding="utf-8") as f: |
|
|
|
f.write(text) |
|
|
|
|
|
|
|
f.write(text) |
|
|
|
|
|
|
|
def run(self): |
|
|
|
if not os.path.exists(self.absoluteScriptFilePath): |
|
|
|
if not os.path.exists(self.nsmClient.ourPath): |
|
|
|
os.makedirs(self.nsmClient.ourPath) |
|
|
|
os.makedirs(self.nsmClient.ourPath) |
|
|
|
self._createEmptyDebugScript() |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
exec(compile(open(self.absoluteScriptFilePath).read(), filename=self.absoluteScriptFilePath, mode="exec"), globals(), self.apilocals) |
|
|
|
except Exception as e: |
|
|
|