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:
parent
ff4bd7fcbd
commit
3ef9283d6f
|
@ -1,2 +1,3 @@
|
|||
#!/bin/bash
|
||||
python -ic "from simulator import *"
|
||||
python -ic "from simulator import *
|
||||
def reload(): reload_sim(globals())"
|
||||
|
|
|
@ -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.")
|
||||
|
|
Loading…
Reference in New Issue