Skip to content

Commit

Permalink
supports importing changes to command book while program is running
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjeffreyz committed May 28, 2022
1 parent 68d2aa3 commit f0e76fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/modules/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import git
import cv2
import inspect
import importlib
from os.path import splitext, basename
from src.common import config, utils
from src.detection import detection
Expand Down Expand Up @@ -168,7 +169,8 @@ def load_commands(self, file):
# Import the desired command book file
module_name = splitext(basename(file))[0]
target = '.'.join(['resources', 'command_books', module_name])
module = __import__(target, fromlist=[''])
module = importlib.import_module(target)
module = importlib.reload(module)

# Check if the 'step' function has been implemented
step_found = False
Expand Down Expand Up @@ -210,10 +212,8 @@ def load_commands(self, file):
config.gui.view.status.set_cb(basename(file))
config.routine.clear()
print(f" ~ Successfully loaded command book '{module_name}'.")
return True
else:
print(f" ! Command book '{module_name}' was not loaded.")
return False

def update_submodules(self, force=False):
print('\n[~] Retrieving latest submodules:')
Expand Down

0 comments on commit f0e76fa

Please sign in to comment.