Exemple #1
0
def sh_mktemp(base_path, directory=True, **kwargs):
    with quiet():
        args = ['--tmpdir={0}'.format(base_path)]
        if directory:
            args.append('-d')

        args = ' '.join(args)
        return run_cmd('mktemp {0}'.format(args), **kwargs)
Exemple #2
0
def sh_mktemp(base_path, directory=True, **kwargs):
    with quiet():
        args = ['--tmpdir={0}'.format(base_path)]
        if directory:
            args.append('-d')

        args = ' '.join(args)
        return run_cmd('mktemp {0}'.format(args), **kwargs)
Exemple #3
0
def sh_listdir(path, **kwargs):
    with quiet():
        content = run_cmd('find {0} -maxdepth 1'.format(path), **kwargs)

    items = content.split('\n')
    items = [item.strip() for item in items]
    esc = lambda path: re.escape(path + '/' if not path.endswith('/') else path)
    items = [re.sub('^' + esc(path), '', item) for item in items]
    items = [item for item in items if item and not item == path]
    return items
Exemple #4
0
def sh_chown(path, user=None, group=None, recursive=False, **kwargs):
    if user:
        mask = '{0}'.format(user)
        if group:
            mask = '{0}:{1}'.format(mask, group)

    with quiet():
        extra_args = ''
        if recursive:
            extra_args = ' -R'
        return run_cmd('chown {0} {1} {2}'.format(extra_args, mask, path), capture=True, **kwargs)
Exemple #5
0
def sh_listdir(path, **kwargs):
    with quiet():
        content = run_cmd('find {0} -maxdepth 1'.format(path), **kwargs)

    items = content.split('\n')
    items = [item.strip() for item in items]
    esc = lambda path: re.escape(path + '/'
                                 if not path.endswith('/') else path)
    items = [re.sub('^' + esc(path), '', item) for item in items]
    items = [item for item in items if item and not item == path]
    return items
Exemple #6
0
def sh_chown(path, user=None, group=None, recursive=False, **kwargs):
    if user:
        mask = '{0}'.format(user)
        if group:
            mask = '{0}:{1}'.format(mask, group)

    with quiet():
        extra_args = ''
        if recursive:
            extra_args = ' -R'
        return run_cmd('chown {0} {1} {2}'.format(extra_args, mask, path),
                       capture=True,
                       **kwargs)
Exemple #7
0
def sh_copytree(src, dest, **kwargs):
    with quiet():
        return run_cmd('cp -r {0} {1}'.format(src, dest), capture=True, **kwargs)
Exemple #8
0
def sh_chmod(path, mask, **kwargs):
    with quiet():
        return run_cmd('chmod {0} {1}'.format(mask, path), capture=True, **kwargs)
Exemple #9
0
def sh_chmod(path, mask, **kwargs):
    with quiet():
        return run_cmd('chmod {0} {1}'.format(mask, path),
                       capture=True,
                       **kwargs)
Exemple #10
0
def sh_rmtree(path, **kwargs):
    with quiet():
        return run_cmd('find {0} -delete'.format(path), **kwargs)
Exemple #11
0
def sh_makedirs(path, user=None, group=None, **kwargs):
    with quiet():
        run_cmd('mkdir -p {0}'.format(path), **kwargs)

        mask = '{0}:{1}'.format(user or '', group or '')
        run_cmd('chown {0} {1}'.format(mask, path), **kwargs)
Exemple #12
0
def sh_ln(src, dest, symbolic=True, **kwargs):
    with quiet():
        sym = ' -s' if symbolic else ''
        return run_cmd('ln{0} {1} {2}'.format(sym, src, dest),
                       **kwargs).succeeded
Exemple #13
0
def sh_file_exists(path, **kwargs):
    with quiet():
        return run_cmd('test -f {0}'.format(path), **kwargs).succeeded
Exemple #14
0
def sh_copytree(src, dest, **kwargs):
    with quiet():
        return run_cmd('cp -r {0} {1}'.format(src, dest),
                       capture=True,
                       **kwargs)
Exemple #15
0
def sh_file_exists(path, **kwargs):
    with quiet():
        return run_cmd('test -f {0}'.format(path), **kwargs).succeeded
Exemple #16
0
def sh_rm(path, **kwargs):
    with quiet():
        return run_cmd('rm -f {0}'.format(path), **kwargs)
Exemple #17
0
def sh_ln(src, dest, symbolic=True, **kwargs):
    with quiet():
        sym = ' -s' if symbolic else ''
        return run_cmd('ln{0} {1} {2}'.format(sym, src, dest), **kwargs).succeeded
Exemple #18
0
def sh_rmtree(path, **kwargs):
    with quiet():
        return run_cmd('find {0} -delete'.format(path), **kwargs)
Exemple #19
0
def sh_makedirs(path, user=None, group=None, **kwargs):
    with quiet():
        run_cmd('mkdir -p {0}'.format(path), **kwargs)

        mask = '{0}:{1}'.format(user or '', group or '')
        run_cmd('chown {0} {1}'.format(mask, path), **kwargs)
Exemple #20
0
def sh_which(path, **kwargs):
    with quiet():
        return run_cmd('which {0}'.format(path), **kwargs)
Exemple #21
0
def sh_rm(path, **kwargs):
    with quiet():
        return run_cmd('rm -f {0}'.format(path), **kwargs)
Exemple #22
0
def sh_cat(path, **kwargs):
    with quiet():
        return run_cmd('cat {0}'.format(path), capture=True, **kwargs)
Exemple #23
0
def sh_which(path, **kwargs):
    with quiet():
        return run_cmd('which {0}'.format(path), **kwargs)
Exemple #24
0
def sh_cat(path, **kwargs):
    with quiet():
        return run_cmd('cat {0}'.format(path), capture=True, **kwargs)