def execute(executor, *args, **kwargs): ls_command = Command('ls') for arg in args: ls_command.add_argument(arg) ls = type(executor)(reference=executor) ls.add_command(ls_command) return ls()
__author__ = 'wenychan' from Command import Command from LocalExecutor import LocalExec from RemoteExecutor import RemoteExec command = Command('echo') command.add_argument('${text}') dict = {} dict['text'] = 'aaaaaaaa' command.set_substitution_dict(dict) command1 = Command('ls -a') command2 = Command('echo') command2.add_argument('${text}') dict = {} dict['text'] = 'bbbbbbbbbbb' command2.set_substitution_dict(dict) ins = LocalExec(command) ins.add_command(command1) ins.insert_command_at(1, command2) # ins.show_commands() ins.add_command("python aaa.py") print print ins2 = LocalExec([command1, command2]) # ins2.show_commands() print