Import parallel scripts
@@ -7,6 +7,7 @@ import PytoClasses
import mainthread
from importlib.machinery import SourceFileLoader
import os
+import sys
__PyContentViewController__ = PytoClasses.PyContentViewController
def __console__():
@@ -32,11 +33,15 @@ def runScriptAtPath(path):
path: The path of the script.
"""
os.system = PytoClasses.Python.shared.system
+ directory = os.path.expanduser(os.path.dirname(path))
+ sys.path.insert(0, directory)
try:
SourceFileLoader('main', path).load_module()
except Exception as e:
print(e)
+ sys.path.remove(directory)
+
PytoClasses.PyContentViewController.shared.dismissKeyboard()
PytoClasses.Python.shared.isScriptRunning = False
