Package: cmd-exec
1 OverviewThis python module offers a framework which allows to execute given command in a modular fashion.2 Installation2.1 Setting Environment VariableBefore executing command you should set environment variable called "APP_RUNNER_ROOT_PATH" to the
root directory of your python project.APP_RUNNER_ROOT_PATH = /path/to/PYTHON_PROJECT_DIRECTORY2.2 Setting Directory StructureNow we need to set the directory structure of our python project as shown below.- PYTHON_PROJECT_DIRECTORY
  + modules
  - resources
    + commands
    + configsFor details about directory structure please refer toDirectory Structure2.3 Main ConfigurationMain configuration is a yaml file which contains required configurations for command executor to run. Main configuration file name should be “main.config.yaml”.- PYTHON_PROJECT_DIRECTORY
  - resources
    - configs
        main.config.ymlMain configuration file should have following content.application:name:Test ApplicationFor details about main configuration please refer toMain Configuration2.4 Generating Module2.4.1 Setting Directory StructureApplication expects module complies with following directory structure and files.- PYTHON_PROJECT_DIRECTORY
  - modules
    - base
      - src
        + executor
      + commands
      base.settings.yaml2.4.2 Adding Module SettingsWe need to provide information about the module as shown below.base.settings.yamlname:basedescription:This is a test module.version:0.0.12.4.2 Adding CommandWe can define commands to be executed via a yaml file. System looks for yaml file “<COMMAND_ID>.yaml” in
“commands” directory in module’s root directory as shown below.- PYTHON_PROJECT_DIRECTORY
  - modules
    - base    
      - commands
          cmd1.yamlCommand yaml file should comply with following structure.id:cmd1title:Command 1module:sampleexecutor:class:TestCmdExecutormethod:runCommand2.4.3 Generating ExecutorWith above configuration command executor framework will search and find TestCmdExector class in sample module. Once
executor class is found, its given method "runCommand" will called.We need to provide TestCmdExecutor class in following directory.- PYTHON_PROJECT_DIRECTORY
  - modules
    - MODULE_NAME    
      - src
        - executor
            TestCmdExecutorTestCmdExecutor.pyfromcmd_exec.classes.MarkupBuilderimportMarkupBuilderfromcmd_exec.command.CmdResponseimportCmdResponsefromcmd_exec.command.CmdExecutorimportCmdExecutorfromcmd_exec.command.CmdRequestimportCmdRequestclassTestCmdExecutor(CmdExecutor):defrunCommand(self,request:CmdRequest)->CmdResponse:response:CmdResponse=CmdResponse(True,'view')builder:MarkupBuilder=MarkupBuilder()builder.addConstraintText("Hello World",20)text=builder.getMarkupText()response.setContent(text)returnresponseFor details about modules please refer toModules2.5 Initializing Command Executor FrameworkNow we are all set with setting environment to executing command. Lets generate a python script which will initiate
command executor framework to execute a command with following content.run-command.pyfromcmd_exec.app.CmdExecAppRunnerimportCmdExecAppRunnerCmdExecAppRunner.run()2.6 Executing CommandWe can now execute command via command executor framework by calling python script generated in previous step.
Run above python script along with passing argument to identify the command to be executed.pythonrun-command.py-cmdbase.cmd1For details about other feature please refer toCommand Executor User Manual