From af169b95986c36f77a200b13f8f38cdcc3b923ae Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 21 Dec 2019 02:49:53 +0100 Subject: [PATCH] Replace IModule with AbstractModule Delete CommandRunner Set up API to delegate the module execution to the module itself Update SampleModule --- AbstractModule.py | 4 ---- CommandRunner.py | 18 ------------------ main.py | 3 +-- modules/sample/sampleModule.py | 9 ++------- 4 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 CommandRunner.py diff --git a/AbstractModule.py b/AbstractModule.py index fed48da..4dbdbf0 100644 --- a/AbstractModule.py +++ b/AbstractModule.py @@ -7,10 +7,6 @@ class AbstractModule(ABC): def __init__(self): super(AbstractModule, self).__init__() - @abstractmethod - def get_command(self): - pass - @abstractmethod def run(self): pass diff --git a/CommandRunner.py b/CommandRunner.py deleted file mode 100644 index 8249941..0000000 --- a/CommandRunner.py +++ /dev/null @@ -1,18 +0,0 @@ -class CommandRunner(object): - """docstring for CommandRunner.""" - - def __init__(self): - super(CommandRunner).__init__() - - def run(self, module): - print("REAL RUNNER") - print("Commands should be executed as subprocess.") - - -class CommandRunnerDebug(object): - def __init__(self): - super(CommandRunnerDebug).__init__() - - def run(self, module): - print("DEBUG RUNNER") - print(module.get_command()) diff --git a/main.py b/main.py index 2ffc019..9f8f1dd 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,3 @@ -from CommandRunner import CommandRunnerDebug as Runner from PyInquirer import prompt import importlib import os @@ -46,4 +45,4 @@ modules = load_modules() selected_modules = open_module_selection(modules) for answer in selected_modules['modules']: - Runner().run(modules[answer]) + modules[answer].run() diff --git a/modules/sample/sampleModule.py b/modules/sample/sampleModule.py index 34e81e3..6a5b385 100644 --- a/modules/sample/sampleModule.py +++ b/modules/sample/sampleModule.py @@ -8,10 +8,5 @@ class SampleModule(AbstractModule): super(SampleModule, self).__init__() def run(self): - pass - - def get_command(self): - return [ - "command 1", - "command 2" - ] + print("Command 1") + print("Command 2")