Exemplo n.º 1
0
    def __init__(self, cmd, ubuntu_package=None, url=None,
                 cwd=None, use_temp_files=True, env=None):
        self.use_temp_files = use_temp_files
        self._outputs_processed = False

        self.env = env
        self.popen = None
        self.stdout = None
        self.stderr = None
        self._stdout_file = None
        self._stderr_file = None
        self.url = url
        self.ubuntu_package = ubuntu_package
        self.is_started = False
        self.oserror = None
        self.cmd_param = cmd
        self._thread = None
#        self.max_bytes_to_log = max_bytes_to_log
        self._stop_thread = False
        self.timeout_happened = False
        self.cwd = cwd
        cmd = split_command(cmd)
        self.cmd = cmd
        self.cmd_as_string = ' '.join(self.cmd)  # TODO: not perfect

        log.debug('param: "%s" ', self.cmd_param)
        log.debug('command: %s', self.cmd)
        log.debug('joined command: %s', self.cmd_as_string)

        if not len(cmd):
            raise EasyProcessError(self, 'empty command!')
Exemplo n.º 2
0
    def __init__(self, cmd, ubuntu_package=None, url=None, cwd=None, use_temp_files=True, env=None):
        self.use_temp_files = use_temp_files
        self._outputs_processed = False

        self.env = env
        self.popen = None
        self.stdout = None
        self.stderr = None
        self._stdout_file = None
        self._stderr_file = None
        self.url = url
        self.ubuntu_package = ubuntu_package
        self.is_started = False
        self.oserror = None
        self.cmd_param = cmd
        self._thread = None
#        self.max_bytes_to_log = max_bytes_to_log
        self._stop_thread = False
        self.timeout_happened = False
        self.cwd = cwd
        cmd = split_command(cmd)
        self.cmd = cmd
        self.cmd_as_string = ' '.join(self.cmd)  # TODO: not perfect

        log.debug('param: "%s" ', self.cmd_param)
        log.debug('command: %s', self.cmd)
        log.debug('joined command: %s', self.cmd_as_string)

        if not len(cmd):
            raise EasyProcessError(self, 'empty command!')
Exemplo n.º 3
0
    def __init__(
        self, cmd, cwd=None, use_temp_files=True, env=None,
    ):
        self.use_temp_files = use_temp_files
        self._outputs_processed = False

        self.env = env
        self.popen = None
        self.stdout = None
        self.stderr = None
        self._stdout_file = None
        self._stderr_file = None
        self.is_started = False
        self.oserror = None
        self.cmd_param = cmd
        self._thread = None
        self.timeout_happened = False
        self.cwd = cwd
        cmd = split_command(cmd)
        self.cmd = cmd
        # self.cmd_as_string = " ".join(self.cmd)
        self.enable_stdout_log = True
        self.enable_stderr_log = True

        # log.debug('param: "%s" ', self.cmd_param)
        log.debug("command: %s", self.cmd)
        # log.debug('joined command: %s', self.cmd_as_string)

        if not len(cmd):
            raise EasyProcessError(self, "empty command!")
Exemplo n.º 4
0
    def __init__(self,
                 cmd,
                 ubuntu_package=None,
                 url=None,
                 cwd=None,
                 use_temp_files=True,
                 env=None,
                 universal_newlines=False):
        self.use_temp_files = use_temp_files
        self.env = env
        self.universal_newlines = universal_newlines
        self._outputs_processed = False

        self.popen = None
        self.stdout = None
        self.stderr = None
        self._stdout_file = None
        self._stderr_file = None
        self.url = url
        self.ubuntu_package = ubuntu_package
        self.is_started = False
        self.oserror = None
        self.cmd_param = cmd
        self._thread = None
        #        self.max_bytes_to_log = max_bytes_to_log
        self._stop_thread = False
        self.timeout_happened = False
        self.cwd = cwd
        cmd = split_command(cmd)
        self.cmd = cmd
        self.cmd_as_string = ' '.join(self.cmd)  # TODO: not perfect

        log.debug('param: "%s" command: %s ("%s")' %
                  (self.cmd_param, self.cmd, self.cmd_as_string))

        if not len(cmd):
            raise EasyProcessError(self, 'empty command!')

        # if not Proc.config:
        #     conf_file = os.path.join(os.path.expanduser('~'), CONFIG_FILE)
        #     log.debug('reading config: %s' % (conf_file))
        #     Proc.config = ConfigParser.RawConfigParser()
        #     Proc.config.read(conf_file)

        self.alias = None
        # try:
        #     self.alias = Proc.config.get(SECTION_LINK, self.cmd[0])
        # except ConfigParser.NoSectionError:
        #     pass
        # except ConfigParser.NoOptionError:
        #     pass

        if self.alias:
            log.debug('alias found: %s' % (self.alias))
            self.cmd[0] = self.alias
Exemplo n.º 5
0
def test_split():
    # list -> list
    assert split_command([str("x"), str("y")]) == ["x", "y"]
    assert split_command([str("x"), u("y")]) == ["x", "y"]
    assert split_command([str("x"), OMEGA]) == ["x", OMEGA]

    # str -> list
    assert split_command(str("x y")) == ["x", "y"]
    assert split_command(u("x y")) == ["x", "y"]
    if six.PY3:
        assert split_command(u("x ") + OMEGA) == ["x", OMEGA]
    else:
        with pytest.raises(EasyProcessUnicodeError):
            split_command(u("x ") + OMEGA)

    # split windows paths #12
    assert (split_command("c:\\temp\\a.exe someArg",
                          posix=False) == ["c:\\temp\\a.exe", "someArg"], )
Exemplo n.º 6
0
    def test_split(self):
        #list -> list
        eq_(split_command([str('x'),str('y')]),['x','y'])
        eq_(split_command([str('x'),u('y')]),['x','y'])
        eq_(split_command([str('x'),OMEGA]),['x',OMEGA])

        #str -> list
        eq_(split_command(str('x y')),['x','y'])
        eq_(split_command(u('x y')),['x','y'])
        if six.PY3:        
            eq_(split_command(u('x ')+OMEGA), ['x',OMEGA])
        else:
            self.assertRaises(EasyProcessUnicodeError, lambda :split_command(u('x ')+OMEGA))
Exemplo n.º 7
0
    def test_split(self):
        #list -> list
        eq_(split_command([str('x'), str('y')]), ['x', 'y'])
        eq_(split_command([str('x'), u('y')]), ['x', 'y'])
        eq_(split_command([str('x'), OMEGA]), ['x', OMEGA])

        #str -> list
        eq_(split_command(str('x y')), ['x', 'y'])
        eq_(split_command(u('x y')), ['x', 'y'])
        if six.PY3:
            eq_(split_command(u('x ') + OMEGA), ['x', OMEGA])
        else:
            self.assertRaises(EasyProcessUnicodeError,
                              lambda: split_command(u('x ') + OMEGA))
Exemplo n.º 8
0
    def __init__(self, cmd, ubuntu_package=None, url=None, cwd=None, use_temp_files=True):
        self.use_temp_files = use_temp_files
        self._outputs_processed = False

        self.popen = None
        self.stdout = None
        self.stderr = None
        self._stdout_file = None
        self._stderr_file = None
        self.url = url
        self.ubuntu_package = ubuntu_package
        self.is_started = False
        self.oserror = None
        self.cmd_param = cmd
        self._thread = None
#        self.max_bytes_to_log = max_bytes_to_log
        self._stop_thread = False
        self.timeout_happened = False
        self.cwd = cwd
        cmd = split_command(cmd)
        self.cmd = cmd
        self.cmd_as_string = ' '.join(self.cmd)  # TODO: not perfect

        log.debug('param: "%s" ' % (self.cmd_param))
        log.debug('command: %s' % ( self.cmd))
        log.debug('joined command: %s' % ( self.cmd_as_string))

        if not len(cmd):
            raise EasyProcessError(self, 'empty command!')

        if not Proc.config:
            conf_file = os.path.join(os.path.expanduser('~'), CONFIG_FILE)
            log.debug('reading config: %s' % (conf_file))
            Proc.config = ConfigParser.RawConfigParser()
            Proc.config.read(conf_file)

        self.alias = None
        try:
            self.alias = Proc.config.get(SECTION_LINK, self.cmd[0])
        except ConfigParser.NoSectionError:
            pass
        except ConfigParser.NoOptionError:
            pass

        if self.alias:
            log.debug('alias found: %s' % (self.alias))
            self.cmd[0] = self.alias