Exemple #1
0
    def __init__(self, cmd, *, cwd=None, cin=None):
        '''
        Initialize a new command

        :param cmd: Commandline of command to launch
        :param cwd: Launch *cmd* inside some other current working directory
        :param cin: Send data via stdin into *cmd*
        '''
        if isinstance(cmd, str):
            cmd = split(cmd)

        if cwd is not None:
            cwd = joined(cwd)

        self._log = getLogger(self.__class__.__name__)
        self._data = dict(cmd=cmd,
                          cwd=cwd,
                          cin=cin,
                          stdout='',
                          stderr='',
                          code=None,
                          exc=None)

        self._log.debug('command initialized: %s', self.repr)
def test_joined_relative():
    res = joined('/test', 'test', 'test', '..')
    assert res == path.realpath(path.join(path.sep, 'test', 'test'))
def test_joined_empty():
    res = joined('')
    assert res == path.realpath('.')
def test_joined_leading():
    res = joined('/test', '/test', '/test')
    assert res == path.realpath(path.join(path.sep, 'test', 'test', 'test'))
def test_joined_join():
    res = joined('test', 'test', 'test')
    assert res == path.realpath(path.join('test', 'test', 'test'))
def test_joined_expanduser():
    res = joined('~')
    assert res == environ.get('HOME')
def test_joined_expandvars():
    res = joined('$HOME')
    assert res == environ.get('HOME')
def test_joined_realpath():
    res = joined('test')
    assert res == path.realpath('test')