当前位置: 首页>>代码示例>>Python>>正文


Python env.user方法代码示例

本文整理汇总了Python中fabric.api.env.user方法的典型用法代码示例。如果您正苦于以下问题:Python env.user方法的具体用法?Python env.user怎么用?Python env.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fabric.api.env的用法示例。


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

示例1: setup_supervisor

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def setup_supervisor():
    # We use supervisord to keep Crestify running in the background
    # Recover from crashes, and to start automatically on bootup
    # Also, using more than 1 gunicorn worker resulted in socket not being released, so only 1 worker will be used
    sudo('apt-get -y install supervisor')
    sudo('mkdir /var/log/crestify/')
    sudo(
        'cd /home/crestify/crestify && ../crestifyenv/bin/honcho export -s /bin/sh -a crestify supervisord /etc/supervisor/conf.d')
    fd = StringIO()
    get('/etc/supervisor/conf.d/crestify.conf', fd)
    content = fd.getvalue().splitlines()
    for n, i in enumerate(content):
        if i.startswith("environment="):
            content[n] = i + ",PATH=/home/crestify/crestifyenv/bin:%(ENV_PATH)s"
        if i.startswith("user="):
            content[n] = "user=crestify"
        if i.startswith("stopsignal="):
            content[n] = "stopsignal=TERM"  # Both Gunicorn and Celery use SIGTERM for graceful shutdown
    content = StringIO("\n".join(content))
    put(content, "/etc/supervisor/conf.d/crestify.conf", use_sudo=True)
    sudo('supervisorctl reread')
    sudo('supervisorctl update') 
开发者ID:dhamaniasad,项目名称:crestify,代码行数:24,代码来源:fabfile.py

示例2: run_command

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def run_command(self, hosts, parallel_pool_size=1):
        from fabric.api import execute, sudo, env, parallel
        if env.ssh_config_path and os.path.isfile(os.path.expanduser(env.ssh_config_path)):
            env.use_ssh_config = True
        env.forward_agent = True
        # pass `-E` to sudo to preserve environment for ssh agent forwarding
        env.sudo_prefix = "sudo -SE -p '%(sudo_prompt)s' "
        env.user = self.user_name
        env.password = self.password
        env.hosts = hosts
        env.warn_only = True

        def _task():
            result = sudo(self.command, user=self.user_as)
            return result

        task = _task
        if parallel_pool_size > 1:
            task = parallel(pool_size=parallel_pool_size)(_task)

        res = execute(task)
        return res 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:24,代码来源:utils.py

示例3: _setup_path

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def _setup_path():
    # using posixpath to ensure unix style slashes.
    # See bug-ticket: http://code.fabfile.org/attachments/61/posixpath.patch
    env.root = posixpath.join(env.home, 'www', env.deploy_env)
    env.log_dir = posixpath.join(env.home, 'www', env.deploy_env, 'log')
    env.releases = posixpath.join(env.root, 'releases')
    env.code_current = posixpath.join(env.root, 'current')
    env.code_root = posixpath.join(env.releases, env.deploy_metadata.timestamp)
    env.project_root = posixpath.join(env.code_root, env.project)
    env.project_media = posixpath.join(env.code_root, 'media')

    env.py3_virtualenv_current = posixpath.join(env.code_current, 'python_env-3.6')
    env.py3_virtualenv_root = posixpath.join(env.code_root, 'python_env-3.6')

    env.services = posixpath.join(env.code_root, 'services')
    env.db = '%s_%s' % (env.project, env.deploy_env)
    env.offline_releases = posixpath.join('/home/{}/releases'.format(env.user))
    env.offline_code_dir = posixpath.join('{}/{}'.format(env.offline_releases, 'offline'))
    env.airflow_home = posixpath.join(env.home, 'airflow')
    env.airflow_env = posixpath.join(env.airflow_home, 'env')
    env.airflow_code_root = posixpath.join(env.airflow_home, 'pipes') 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:23,代码来源:fabfile.py

示例4: localhost

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def localhost(skip_ssh=False):
    """
    Sets up a development environment to pretend that localhost is a remote server
    """
    if not skip_ssh:
        env.hosts = ['127.0.0.1']

    env.user = env.deploy_user = 'calthorpe'
    env.deploy_user = 'calthorpe'
    env.virtualenv_directory = '/srv/calthorpe_env'
    env.password = 'Calthorpe123'
    env.DATA_DUMP_PATH = '/srv/datadump'
    env.settings = 'dev'
    env.dev = True
    env.use_ssl = False
    env.client = 'default' 
开发者ID:CalthorpeAnalytics,项目名称:urbanfootprint,代码行数:18,代码来源:__init__.py

示例5: configure_env

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def configure_env():
    ''' Configures the fabric env. '''
    config = get_config()
    stage = get_stage()
    stage_config = get_stage_config(stage)
    env.user = stage_config.get('user') or config['user']
    env.port = stage_config.get('port') or config['port']
    env.cwd = stage_config.get('cwd') or config['cwd']
    env.key_filename = stage_config.get(
        'key_filename') or config['key_filename']
    env.hosts = [stage_config['host']]
    ssh_forward_agent = stage_config.get(
        'ssh_forward_agent') or config['ssh_forward_agent']

    env.forward_agent = (
        ssh_forward_agent and
        str(ssh_forward_agent).lower() == 'true'
    )

    # If Verbose logging is turned on show verbose logs.
    verbose_logging = stage_config.get('verbose_logging') or config[
        'verbose_logging']

    if str(verbose_logging).lower() == 'true':
        set_verbose_logging() 
开发者ID:kabirbaidhya,项目名称:boss,代码行数:27,代码来源:init.py

示例6: check_server_status

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def check_server_status():
    """
    Checks if server is running for env.host. Retries connecting to server
    until server is up or till RETRY_TIMEOUT is reached

    Parameters:
        client - client that executes the query

    Returns:
        True or False
    """
    if len(get_coordinator_role()) < 1:
        warn('No coordinator defined.  Cannot verify server status.')
    with closing(PrestoClient(get_coordinator_role()[0], env.user)) as client:
        node_id = lookup_string_config('node.id', os.path.join(constants.REMOTE_CONF_DIR, 'node.properties'), env.host)

        try:
            return query_server_for_status(client, node_id)
        except RetryError:
            return False 
开发者ID:prestodb,项目名称:presto-admin,代码行数:22,代码来源:server.py

示例7: collect_node_information

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def collect_node_information():
    with closing(PrestoClient(get_coordinator_role()[0], env.user)) as client:
        with settings(hide('warnings')):
            error_message = check_presto_version()
        if error_message:
            external_ip = 'Unknown'
            is_running = False
        else:
            with settings(hide('warnings', 'aborts', 'stdout')):
                try:
                    external_ip = get_ext_ip_of_node(client)
                except:
                    external_ip = 'Unknown'
                try:
                    is_running = service('status')
                except:
                    is_running = False
        return external_ip, is_running, error_message 
开发者ID:prestodb,项目名称:presto-admin,代码行数:20,代码来源:server.py

示例8: setup_vhost

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def setup_vhost():
    """ Setup a test website """
    print ("Preparing the Apache vhost setup...")
    print ("Setting up the document root...")
    if exists(WWW_DOC_ROOT):
        sudo("rm -rf %s" %WWW_DOC_ROOT)
    sudo("mkdir -p %s" %WWW_DOC_ROOT)
    sudo("chown -R %s.%s %s" %(env.user, env.user, WWW_DOC_ROOT))
    put(local_path="index.html", remote_path=WWW_DOC_ROOT)
    sudo("chown -R %s.%s %s" %(WWW_USER, WWW_GROUP, WWW_DOC_ROOT))
    print ("Setting up the vhost...")
    sudo("chown -R %s.%s %s" %(env.user, env.user, APACHE_SITES_PATH))
    put(local_path="vhost.conf", remote_path=APACHE_SITES_PATH)
    sudo("chown -R %s.%s %s" %('root', 'root', APACHE_SITES_PATH))
    sudo("%s restart" %APACHE_INIT_SCRIPT)
    print ("Setup complete. Now open the server path http://abc.remote-server.org/ in your web browser.") 
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:18,代码来源:6_7_configure_Apache_for_hosting_website_remotely.py

示例9: __action

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def __action(**kwargs):
    redata = kwargs['redata']
    jdata = kwargs['jdata']
    if ShouldRun(redata, jdata):
        env.gateway = redata['data']['gateway']
        env.host_string = redata['data']['host_string']
        env.user = redata['data']['username']
        env.key = redata['data']['sshkey']
        env.disable_known_hosts = True
        env.warn_only = True
        env.abort_on_prompts = True
        env.shell = "/bin/sh -c"
        try:
            results = run_cmd(redata['data']['cmd'])
            if results.succeeded:
                return True
            else:
                raise Exception(
                    'Command Execution Failed: {0} - {1}'.format(results.return_code, results))
        except:
            raise Exception(
                'Command failed to execute') 
开发者ID:Runbook,项目名称:runbook,代码行数:24,代码来源:__init__.py

示例10: check

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def check(**kwargs):
    ''' Login over SSH and execute shell command '''
    jdata = kwargs['jdata']
    logger = kwargs['logger']

    env.gateway = jdata['data']['gateway']
    env.host_string = jdata['data']['host_string']
    env.user = jdata['data']['username']
    env.key = jdata['data']['sshkey']
    env.shell = "/bin/sh -c"
    env.disable_known_hosts = True
    env.warn_only = True
    env.abort_on_prompts = True
    try:
        results = run_cmd(jdata['data']['cmd'])
        logger.debug("execute-shell-command: requested command" +
                     " returned with exit code {0}".format(results.return_code))
        if results.succeeded:
            return True
        else:
            return False
    except:
        return None 
开发者ID:Runbook,项目名称:runbook,代码行数:25,代码来源:__init__.py

示例11: check

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def check(**kwargs):
    ''' Login over SSH and execute shell command '''
    jdata = kwargs['jdata']
    logger = kwargs['logger']

    env.gateway = jdata['data']['gateway']
    env.host_string = jdata['data']['host_string']
    env.user = jdata['data']['username']
    env.key = jdata['data']['sshkey']
    env.shell = "/bin/sh -c"
    env.disable_known_hosts = True
    env.warn_only = True
    env.abort_on_prompts = True
    results = run_cmd("uptime")
    if results.succeeded:
        data = results.split()
        load = float(data[-3].rstrip(","))
    else:
        return None

    logger.debug("load-average: 1 minute load average is {0}".format(load))
    if load < float(jdata['data']['threshold']):
        return True
    else:
        return False 
开发者ID:Runbook,项目名称:runbook,代码行数:27,代码来源:__init__.py

示例12: _get_vagrant_connection

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def _get_vagrant_connection():
    local('vagrant up')
    result = local('vagrant ssh-config', capture=True)
    hostname = re.findall(r'HostName\s+([^\n]+)', result)[0]
    port = re.findall(r'Port\s+([^\n]+)', result)[0]
    env.hosts = ['%s:%s' % (hostname, port)]
    env.user = re.findall(r'User\s+([^\n]+)', result)[0]
    env.key_filename = re.findall(r'IdentityFile\s+([^\n]+)', result)[0].lstrip("\"").rstrip("\"") 
开发者ID:dhamaniasad,项目名称:crestify,代码行数:10,代码来源:fabfile.py

示例13: create_database

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def create_database():
    # Create the user and database for Crestify. User and db name can be changed given you change
    # SQLALCHEMY_DATABASE_URI in the config
    create_user_command = "CREATE ROLE crestify WITH PASSWORD 'crestify' LOGIN;"
    create_db_cmd = "CREATE DATABASE crestify OWNER postgres ENCODING 'UTF8' TEMPLATE template0 LC_CTYPE 'en_US.UTF8' LC_COLLATE 'en_US.UTF8'"
    with cd('/var/lib/postgresql'):
        with settings(sudo_user="postgres"):
            sudo('psql -c "{}"'.format(create_user_command))
            sudo('psql -c "{}"'.format(create_db_cmd)) 
开发者ID:dhamaniasad,项目名称:crestify,代码行数:11,代码来源:fabfile.py

示例14: create_marvin_engines_prefix

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def create_marvin_engines_prefix():
    sudo("mkdir -p /opt/marvin/engines")
    sudo("chown {user}:{user} /opt/marvin/engines".format(user=env.user))
    sudo("mkdir -p /var/log/marvin/engines")
    sudo("chown {user}:{user} /var/log/marvin/engines".format(user=env.user))
    sudo("mkdir -p /var/run/marvin/engines")
    sudo("chown {user}:{user} /var/run/marvin/engines".format(user=env.user)) 
开发者ID:marvin-ai,项目名称:marvin-python-toolbox,代码行数:9,代码来源:fabfile.py

示例15: production

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import user [as 别名]
def production():
    global SERVER_ENV, UWSGI_ENV, DB_DIR, DB_FILE
    env.hosts = ['haoli-normal-06-vpn-dns']
    env.user = 'haoli'
    SERVER_ENV = 'production'
    UWSGI_ENV = 'production'
    DB_DIR = config.ProductionConfig.DB_DIR
    DB_FILE = config.ProductionConfig.DB_FILE

#development Env 
开发者ID:sibosend,项目名称:openvpn-admin-ui,代码行数:12,代码来源:fabfile.py


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