simulator: Add a function for reloading the simulator

This lets me update the doors.py file without needing to exit the Python
interpreter.

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
Anna Schumaker 2015-04-23 08:35:09 -04:00
parent ff4bd7fcbd
commit 3ef9283d6f
2 changed files with 16 additions and 3 deletions

View File

@ -1,2 +1,3 @@
#!/bin/bash
python -ic "from simulator import *"
python -ic "from simulator import *
def reload(): reload_sim(globals())"

View File

@ -1,4 +1,5 @@
import importlib
import os
import sys
#######################################################
@ -9,7 +10,18 @@ import sys
sys.path.insert(0, os.path.join(os.getcwd(), "simulator"))
print("Welcome to the Workantile Door System Simulator!")
import doors
from doors import *
def reload_sim(namespace):
importlib.reload(GPIO)
importlib.reload(request)
importlib.reload(serial)
importlib.reload(doors)
namespace.update(doors.__dict__)
print("")
print("Welcome to the Workantile Door System Simulator!")
print("Hint: call reload() to reload the simulator with updated code.")