示例#1
0
文件: fs.py 项目: oxilion/zarafa-zsm
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)
示例#2
0
文件: fs.py 项目: oxilion/zarafa-zsm
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)
示例#3
0
文件: fs.py 项目: oxilion/zarafa-zsm
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
示例#4
0
文件: fs.py 项目: oxilion/zarafa-zsm
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)
示例#5
0
文件: fs.py 项目: oxilion/zarafa-zsm
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
示例#6
0
文件: fs.py 项目: oxilion/zarafa-zsm
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)
示例#7
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_copytree(src, dest, **kwargs):
    with quiet():
        return run_cmd('cp -r {0} {1}'.format(src, dest), capture=True, **kwargs)
示例#8
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_chmod(path, mask, **kwargs):
    with quiet():
        return run_cmd('chmod {0} {1}'.format(mask, path), capture=True, **kwargs)
示例#9
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_chmod(path, mask, **kwargs):
    with quiet():
        return run_cmd('chmod {0} {1}'.format(mask, path),
                       capture=True,
                       **kwargs)
示例#10
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_rmtree(path, **kwargs):
    with quiet():
        return run_cmd('find {0} -delete'.format(path), **kwargs)
示例#11
0
文件: fs.py 项目: oxilion/zarafa-zsm
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)
示例#12
0
文件: fs.py 项目: oxilion/zarafa-zsm
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
示例#13
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_file_exists(path, **kwargs):
    with quiet():
        return run_cmd('test -f {0}'.format(path), **kwargs).succeeded
示例#14
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_copytree(src, dest, **kwargs):
    with quiet():
        return run_cmd('cp -r {0} {1}'.format(src, dest),
                       capture=True,
                       **kwargs)
示例#15
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_file_exists(path, **kwargs):
    with quiet():
        return run_cmd('test -f {0}'.format(path), **kwargs).succeeded
示例#16
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_rm(path, **kwargs):
    with quiet():
        return run_cmd('rm -f {0}'.format(path), **kwargs)
示例#17
0
文件: fs.py 项目: oxilion/zarafa-zsm
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
示例#18
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_rmtree(path, **kwargs):
    with quiet():
        return run_cmd('find {0} -delete'.format(path), **kwargs)
示例#19
0
文件: fs.py 项目: oxilion/zarafa-zsm
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)
示例#20
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_which(path, **kwargs):
    with quiet():
        return run_cmd('which {0}'.format(path), **kwargs)
示例#21
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_rm(path, **kwargs):
    with quiet():
        return run_cmd('rm -f {0}'.format(path), **kwargs)
示例#22
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_cat(path, **kwargs):
    with quiet():
        return run_cmd('cat {0}'.format(path), capture=True, **kwargs)
示例#23
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_which(path, **kwargs):
    with quiet():
        return run_cmd('which {0}'.format(path), **kwargs)
示例#24
0
文件: fs.py 项目: oxilion/zarafa-zsm
def sh_cat(path, **kwargs):
    with quiet():
        return run_cmd('cat {0}'.format(path), capture=True, **kwargs)