diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..e7e9d11 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/linux-tools.iml b/.idea/linux-tools.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/linux-tools.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6649a8c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c0de9cb --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CommandRunner.py b/CommandRunner.py new file mode 100644 index 0000000..8249941 --- /dev/null +++ b/CommandRunner.py @@ -0,0 +1,18 @@ +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/IModule.py b/IModule.py new file mode 100644 index 0000000..bdc3bbb --- /dev/null +++ b/IModule.py @@ -0,0 +1,8 @@ +class IModule(object): + """docstring for Module.""" + + def __init__(self): + super(IModule, self).__init__() + + def get_command(self): + raise NotImplementedError diff --git a/main.py b/main.py index e69de29..3b30b96 100644 --- a/main.py +++ b/main.py @@ -0,0 +1,29 @@ +from CommandRunner import CommandRunnerDebug as Runner +import importlib +import os + + +def get_modules(): + modules = [] + for folder in os.listdir("./modules"): + # skipping sample module + if folder == "sample": + continue + + print("Module found: " + folder) + curr_module = importlib.import_module('.' + folder, package="modules") + print("Try to load module: " + folder) + modules.append(curr_module.get_module()) + print("Module loaded successfully: " + folder) + return modules + + +print("Loading modules: \n") + +modules = get_modules() + +print("\nRunning all modules \n") + +cmdRunner = Runner() +for module in modules: + cmdRunner.run(module) diff --git a/modules/sample/__init__.py b/modules/sample/__init__.py new file mode 100644 index 0000000..c1980aa --- /dev/null +++ b/modules/sample/__init__.py @@ -0,0 +1,5 @@ +from .sampleModule import SampleModule + + +def get_module(): + return SampleModule() diff --git a/modules/sample/sampleModule.py b/modules/sample/sampleModule.py new file mode 100644 index 0000000..5fdd363 --- /dev/null +++ b/modules/sample/sampleModule.py @@ -0,0 +1,14 @@ +from IModule import IModule + + +class SampleModule(IModule): + """docstring for SampleModule.""" + + def __init__(self): + super(SampleModule, self).__init__() + + def get_command(self): + return [ + "command 1", + "command 2" + ]