• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python operations.run函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中refabric.operations.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了run函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: configure

def configure():
    """
    Configure PureFTP
    """
    with sudo():
        # Echo configurations
        setup_config()

        for user in blueprint.get('users'):
            username, password = user['username'], user['password']
            if 'homedir' in user:
                user_home = user['homedir']
            else:
                user_home = os.path.join(ftp_root, username)

            passwd_path = '/etc/pure-ftpd/pureftpd.passwd'
            with settings(warn_only=True):
                if files.exists(passwd_path) and run('pure-pw show {}'.format(
                                                     username)).return_code == 0:
                    continue
            debian.mkdir(user_home, owner=ftp_user, group=ftp_group)
            prompts = {
                'Password: ': password,
                'Enter it again: ': password
            }
            with settings(prompts=prompts):
                run('pure-pw useradd {} -u {} -g {} -d {}'.format(username, ftp_user, ftp_group,
                                                                  user_home))
        run('pure-pw mkdb')
    restart()
开发者ID:5monkeys,项目名称:blues,代码行数:30,代码来源:pureftp.py


示例2: install

def install():
    with sudo():
        debian.apt_get('install', 'pure-ftpd', 'openssl')

        # Create ftp user
        user.create_service_user(ftp_user, groups=[ftp_group])

        # Create ftp root dir
        debian.mkdir(ftp_root, mode=1770, owner=ftp_user, group=ftp_group)

        # Set up symlinks
        debian.ln('/etc/pure-ftpd/conf/PureDB', '/etc/pure-ftpd/auth/PureDB')

        # Enable TLS
        run('echo 1 > /etc/pure-ftpd/conf/TLS')
        key_path = '/etc/ssl/private/pure-ftpd.pem'
        if not files.exists(key_path):
            prompts = {
                'Country Name (2 letter code) [AU]:': '',
                'State or Province Name (full name) [Some-State]:': '',
                'Locality Name (eg, city) []:': '',
                'Organization Name (eg, company) [Internet Widgits Pty Ltd]:': '',
                'Organizational Unit Name (eg, section) []:': '',
                'Common Name (e.g. server FQDN or YOUR name) []:': '',
                'Email Address []:': ''
            }
            with settings(prompts=prompts):
                run('openssl req -x509 -nodes -newkey rsa:2048 -keyout {0} -out {0}'.format(
                    key_path))
            debian.chmod(key_path, 600)
开发者ID:gelbander,项目名称:blues,代码行数:30,代码来源:pureftp.py


示例3: chmod

def chmod(location, mode=None, owner=None, group=None, recursive=False):
    if mode:
        run('chmod %s %s %s' % (recursive and '-R ' or '', mode,  location))
    if owner:
        chown(location, owner=owner, group=group, recursive=recursive)
    elif group:
        chgrp(location, group, recursive=recursive)
开发者ID:Sportamore,项目名称:blues,代码行数:7,代码来源:debian.py


示例4: add_apt_repository

def add_apt_repository(repository, accept=True, src=False):
    if src:
        run('add-apt-repository "{}" {}'.format(repository, '--yes' if accept else ''))
    else:
        # Add repository manually to sources.list due to ubuntu bug
        if not repository.startswith('deb '):
            repository = 'deb {}'.format(repository)
        fabric.contrib.files.append('/etc/apt/sources.list', repository, shell=True)
开发者ID:gelbander,项目名称:blues,代码行数:8,代码来源:debian.py


示例5: set_timezone

def set_timezone(timezone):
    """
    Set OS timezone

    :param timezone: Europe/Stockholm
    """
    with silent():
        run('ln -sf /usr/share/zoneinfo/{} /etc/localtime'.format(timezone))
开发者ID:Sportamore,项目名称:blues,代码行数:8,代码来源:debian.py


示例6: locale_gen

def locale_gen(locale, utf8=True):
    locale_gen_cmd = 'locale-gen {}'.format(locale)
    locale_gen_utf8_cmd = locale_gen_cmd + '.UTF-8'

    with sudo():
        run(locale_gen_cmd)
        if utf8:
            run(locale_gen_utf8_cmd)
开发者ID:Sportamore,项目名称:blues,代码行数:8,代码来源:debian.py


示例7: unmount

def unmount(mount_point):
    """
    Unmount mount point.

    :param str mount_point: Name of mount point to unmount
    """
    with sudo(), silent():
        info('Unmounting {}', mount_point)
        run('umount {}'.format(mount_point))
开发者ID:Sportamore,项目名称:blues,代码行数:9,代码来源:debian.py


示例8: build

    def build(self):
        # This is necessary since the app blueprint doesn't care about
        # package.json change detection and handling.
        self.install_requirements()

        with sudo_project(), cd(git_repository_path()), bash_profile(), \
                prefix('export STATIC_BASE={}'.format(static_base())):
            run('gulp build')
            debian.chgrp(static_base(), group='www-data',
                         recursive=True)
开发者ID:Sportamore,项目名称:blues,代码行数:10,代码来源:node.py


示例9: install

def install(install_java=True):
    with sudo():
        if install_java:
            from blues import java
            java.install()

        version = blueprint.get('version', '0.13.3')
        info('Downloading Metabase v%s' % version)
        run('mkdir -p /etc/metabase/ && cd /etc/metabase/ && curl -O '
            'http://downloads.metabase.com/v%s/metabase.jar' % version)
开发者ID:Sportamore,项目名称:blues,代码行数:10,代码来源:metabase.py


示例10: disable

def disable(user=None):
    """
    Removes the crontab for a single user
    """
    if not user:
        abort('Please specify user account')

    with sudo():
        info('Disabling crontab for {}...', user)
        run('crontab -r -u {}'.format(user))
开发者ID:Sportamore,项目名称:blues,代码行数:10,代码来源:cron.py


示例11: status

def status(user=None):
    """
    Dumps the crontab for a single user
    """
    if not user:
        abort('Please specify user account')

    info('Current crontab for {}:', user)
    with sudo(), hide_prefix():
        run('crontab -l -u {}'.format(user))
开发者ID:Sportamore,项目名称:blues,代码行数:10,代码来源:cron.py


示例12: configure

def configure():
    """
    Install crontab per termplate (user)
    """
    with sudo(), silent():
        with debian.temporary_dir(mode=555) as temp_dir:
            updates = blueprint.upload('./', temp_dir)
            for update in updates:
                user = os.path.basename(update)
                info('Installing new crontab for {}...', user)
                run('crontab -u {} {}'.format(user, os.path.join(temp_dir, user)))
开发者ID:5monkeys,项目名称:blues,代码行数:11,代码来源:cron.py


示例13: kill

def kill(sig, process, use_pkill=False):
    with sudo():
        with silent('warnings'):
            if use_pkill:
                output = run('pkill -{} {}'.format(sig, process))
            else:
                output = run('kill -{} {}'.format(sig, process))

        if output.return_code != 0:
            warn('No process got {} signal'.format(sig))
        else:
            info('Successfully sent {} signal to {}', sig, process)
开发者ID:Sportamore,项目名称:blues,代码行数:12,代码来源:debian.py


示例14: list

def list(*values):
    """
    List sysctl values, e.g. vm.swappiness,vm.panic_on_oom'
    """
    with sudo(), silent():
        if not values:
            for key in run('sysctl -a').split('\n'):
                info(key)

        else:
            for value in values:
                info(run('sysctl %s' % value))
开发者ID:Sportamore,项目名称:blues,代码行数:12,代码来源:sysctl.py


示例15: grep

def grep(needle, haystack, flags="i"):
    """
    Basic file grepping, case-insensitive by default
    """

    if not needle and haystack:
        abort('Missing arguments')

    with hide_prefix(), sudo():
        run('grep{} -e "{}" {}'.format(
            ' -{}'.format(flags) if flags else '',
            needle,
            haystack))
开发者ID:Sportamore,项目名称:blues,代码行数:13,代码来源:shell.py


示例16: configure

def configure():
    """
    Install incrontab per template (i.e. user)
    """
    with sudo(), silent():
        updates = blueprint.upload('./', '/etc')

        users = [os.path.basename(update) for update in updates]
        put(StringIO('\n'.join(users)), '/etc/incron.allow', use_sudo=True)

        for user in users:
            info('Installing new incrontab for {}...', user)
            run('incrontab -u {} {}'.format(user, os.path.join('/etc/incron.usertables', user)))
开发者ID:Sportamore,项目名称:blues,代码行数:13,代码来源:incron.py


示例17: phys_pages

def phys_pages():
    """
    Get _PHYS_PAGES
    """
    c = fabric.context_managers
    with c.settings(c.hide('running', 'stdout')):
        return int(run('getconf _PHYS_PAGES').strip())
开发者ID:Sportamore,项目名称:blues,代码行数:7,代码来源:debian.py


示例18: add_fstab

def add_fstab(filesystem=None, mount_point=None, type='auto', options='rw', dump='0', pazz='0'):
    """
    Add mount point configuration to /etc/fstab.
    If mount point already mounted on different file system then unmount.

    :param str filesystem: The partition or storage device to be mounted
    :param str mount_point: The mount point where <filesystem> is mounted to
    :param str type: The file system type (Default: auto)
    :param str options: Mount options of the filesystem (Default: rw)
    :param str dump: Used by the dump utility to decide when to make a backup, 0|1 (Default: 0)
    :param str pazz: Used by fsck to decide which order filesystems are to be checked (Default: 0)
    """
    with sudo():
        fstab_line = '{fs} {mount} {type} {options} {dump} {pazz}'.format(
            fs=filesystem,
            mount=mount_point,
            type=type,
            options=options,
            dump=dump,
            pazz=pazz
        )
        validate_boot_options(options)

        # Add mount to /etc/fstab if not already there (?)
        with silent():
            output = run('cat /etc/fstab')
            fstab = output.stdout
            if fstab_line not in fstab.split('\n'):  # TODO: Handle comments
                info('Adding fstab: {} on {}', filesystem, mount_point)
                fabric.contrib.files.append('/etc/fstab', fstab_line, use_sudo=True)

        # Unmount any previous mismatching mount point
        mounted_file_system = get_mount(mount_point)
        if mounted_file_system and mounted_file_system != filesystem:
            unmount(mount_point)
开发者ID:Sportamore,项目名称:blues,代码行数:35,代码来源:debian.py


示例19: groupadd

def groupadd(name, gid=None, gid_min=None, gid_max=None, system=False):
    group = get_group(name)
    if not group:
        options = []
        if gid:
            options.append("-g '%s'" % gid)
        if gid_min:
            options.append("-K GID_MIN='%s'" % gid_min)
        if gid_max:
            options.append("-K GID_MAX='%s'" % gid_max)
        if system:
            options.append('-r')
        run("groupadd %s '%s'" % (' '.join(options), name))
    else:
        if gid is not None and group.get('gid') != gid:
            groupmod(name, gid)
开发者ID:Sportamore,项目名称:blues,代码行数:16,代码来源:debian.py


示例20: get_group

def get_group(name):
    group_data = run("cat /etc/group | egrep '^%s:' ; true" % name)
    if group_data:
        name, _, gid, members = group_data.split(':', 4)
        return dict(name=name, gid=gid, members=tuple(m.strip() for m in members.split(',') if m.strip()))
    else:
        return None
开发者ID:Sportamore,项目名称:blues,代码行数:7,代码来源:debian.py



注:本文中的refabric.operations.run函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python references.references_check函数代码示例发布时间:2022-05-26
下一篇:
Python blueprints.get函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap