Print errors on code ran from Swift
-from pyto import Python
+from pyto import Python, PyOutputHelper, ConsoleViewController
from time import sleep
from console import run_script
import threading
+import traceback
import stopit
def raise_exception(script, exception):
@@ -31,7 +32,9 @@ while True:
if code == Python.shared.codeToRun:
Python.shared.codeToRun = None
except:
- pass
+ error = traceback.format_exc()
+ PyOutputHelper.printError(error, script=None)
+ Python.shared.codeToRun = None
if Python.shared.scriptToRun != None:
@@ -53,4 +56,7 @@ while True:
if Python.shared.scriptsToInterrupt.count != 0:
Python.shared.scriptsToInterrupt = []
+ if ConsoleViewController.isPresentingView:
+ sleep(0.02)
+ else:
sleep(0.2)
