コード例 #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)
コード例 #2
0
def test_joined_relative():
    res = joined('/test', 'test', 'test', '..')
    assert res == path.realpath(path.join(path.sep, 'test', 'test'))
コード例 #3
0
def test_joined_empty():
    res = joined('')
    assert res == path.realpath('.')
コード例 #4
0
def test_joined_leading():
    res = joined('/test', '/test', '/test')
    assert res == path.realpath(path.join(path.sep, 'test', 'test', 'test'))
コード例 #5
0
def test_joined_join():
    res = joined('test', 'test', 'test')
    assert res == path.realpath(path.join('test', 'test', 'test'))
コード例 #6
0
def test_joined_expanduser():
    res = joined('~')
    assert res == environ.get('HOME')
コード例 #7
0
def test_joined_expandvars():
    res = joined('$HOME')
    assert res == environ.get('HOME')
コード例 #8
0
def test_joined_realpath():
    res = joined('test')
    assert res == path.realpath('test')