示例#1
0
def call(parameters):
    command = parameters["command"]
    cwd = parameters.get('cwd', None)
    out, err = processutil.call(command, cwd=cwd)

    logutil.info('Output', out)
    logutil.info('Error', err)
示例#2
0
def call(command, cwd=None):
    _install_package_if_not_exists(command)
    logutil.info('Execute', ' '.join(command))
    popen = Popen(command, stdout=PIPE, stderr=PIPE, env=_get_env(), cwd=cwd)
    out, err = popen.communicate()
    if popen.returncode != 0:
        logutil.error('Return Code', popen.returncode)
        logutil.error('Output', out.decode('utf8', errors='ignore'))
        logutil.error('Error', err.decode('utf8', errors='ignore'))

    return popen.returncode, out.decode('utf8', errors='ignore'), err.decode('utf8', errors='ignore')
示例#3
0
def call(command, cwd=None):
    _install_package_if_not_exists(command)
    logutil.info('Execute', ' '.join(command))
    popen = Popen(command, stdout=PIPE, stderr=PIPE, env=_get_env(), cwd=cwd)
    out, err = popen.communicate()
    if popen.returncode != 0:
        logutil.error('Return Code', popen.returncode)
        logutil.error('Output', out.decode('utf8', errors='ignore'))
        logutil.error('Error', err.decode('utf8', errors='ignore'))

    return popen.returncode, out.decode('utf8', errors='ignore'), err.decode('utf8', errors='ignore')
示例#4
0
def move(source_path, destination_path):
    logutil.info('fileutil', 'move: %s -> %s' % (source_path, destination_path))
    if not os.path.exists(source_path):
        logutil.info('fileutil', '%s is not exists' % source_path)
        return

    if is_on_same_disc(source_path, destination_path):
        body, _ = os.path.split(destination_path)
        if not os.path.exists(body):
            makedirs(body)

        shutil.move(source_path, destination_path)
        return

    copy(source_path, destination_path)
    if os.path.isdir(source_path):
        shutil.rmtree(source_path)
    else:
        os.remove(source_path)