Beispiel #1
0
 def __init__(self, command, precursor=None, path=None):
     """
     @param precursor: Precursor to the command line (eg. 'source /etc/profile')
     @param path: The path to change directory to before execution
     """
     PosixCommand.__init__(self, command)
     self.precursor = precursor
     self.path = path
Beispiel #2
0
 def test_posix_command_from_command_line(self):
     executable = 'command'
     args = ['-arg', 'value', '--extra=something']
     commandLine = "%s %s" % (executable, ' '.join(args))
     posixCommand = PosixCommand(commandLine)
     self.assertEqual(posixCommand.executable, executable)
     self.assertEqual(posixCommand.args, [executable]+args)
Beispiel #3
0
 def getCommandLine(self):
     """Insert the precursor and change directory commands
     """
     commandLine = self.precursor + self.sep if self.precursor else ''
     commandLine += self.cd + ' ' + self.path + self.sep if self.path else ''
     commandLine += PosixCommand.getCommandLine(self)
     return commandLine
Beispiel #4
0
    def execute(self,
                processProtocol,
                command,
                env={},
                path=None,
                uid=None,
                gid=None,
                usePTY=0,
                childFDs=None):
        posixCommand = (command if isinstance(command, PosixCommand) else
                        PosixCommand(command))

        process = self.reactor.spawnProcess(processProtocol,
                                            posixCommand.executable,
                                            posixCommand.args, env, path, uid,
                                            gid, usePTY, childFDs)

        return defer.succeed(process)
Beispiel #5
0
 def test_posix_command_fix_args(self):
     executable = 'command'
     args = ['-arg', 'value', '--extra=something']
     posixCommand = PosixCommand(executable, args)
     self.assertEqual(posixCommand.executable, executable)
     self.assertEqual(posixCommand.args, [executable]+args)
Beispiel #6
0
 def test_posix_command_from_args(self):
     args = ['command', '-arg', 'value', '--extra=something']
     posixCommand = PosixCommand(args)
     self.assertEqual(posixCommand.executable, args[0])
     self.assertEqual(posixCommand.args, args)