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


Python env.password方法代码示例

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


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

示例1: run_command

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [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

示例2: localhost

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [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

示例3: __init__

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def __init__(self, user_name, password, command, user_as=None):
        """
        :param user_name: Username to login with
        :param password: Password of the user
        :param command: command to execute (This command will be executed using sudo. )
        """
        self.user_name = user_name
        self.password = password
        self.command = command
        self.user_as = user_as 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:12,代码来源:utils.py

示例4: check_status

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def check_status():
    env.user = 'ansible'
    env.sudo_user = 'root'
    env.password = getpass('Enter the password for the ansbile user: ')

    execute(check_servers.ping)
    execute(check_servers.postgresql)
    execute(check_servers.elasticsearch) 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:10,代码来源:fabfile.py

示例5: local_prod

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def local_prod():
    """
    Sets up a production environment to pretend that localhost is a remote server
    """
    env.hosts = ['localhost']
    env.user = 'calthorpe'
    env.deploy_user = 'calthorpe'
    env.virtualenv_directory = '/srv/calthorpe_env'
    env.password = 'Calthorpe123'
    env.DATA_DUMP_PATH = '/srv/datadump'
    env.dev = False
    env.client = 'default'
    env.settings = 'production' 
开发者ID:CalthorpeAnalytics,项目名称:urbanfootprint,代码行数:15,代码来源:__init__.py

示例6: psql

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def psql(command, user=None, host=None, database_name=None, port=None, password=None):

    if not user:
        user = os.environ.get('DATABASE_USERNAME')

    if not password:
        password = os.environ.get('DATABASE_PASSWORD')

    if not host:
        host = os.environ.get('DATABASE_HOST')

    if not database_name:
        database_name = os.environ.get('DATABASE_NAME')

    if not port:
        port = os.environ.get('DATABASE_PORT')

    full_command = """PGPASSWORD={password} psql -U {user} -h {host} -p {port} -d {database_name} -c "{command}" """.format(
        password=password,
        user=user,
        host=host,
        port=port,
        database_name=database_name,
        command=command
    )

    return run(full_command) 
开发者ID:CalthorpeAnalytics,项目名称:urbanfootprint,代码行数:29,代码来源:methods.py

示例7: setup_databases

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def setup_databases():
    """
        Create production postgres database using local_settings for the DB
    """

    logger.info("confirming Postgres knows about username:{user} password:{pwd}".format(
        user=env.deploy_user,
        pwd=env.password))
    fabtools.icanhaz.postgres.user(
        env.deploy_user,
        env.password,
        superuser=True,
        createdb=True,
        createrole=True,
        login=True)

    run_as_pg("""psql -U postgres -h {host} -c "ALTER USER {user} password '{pwd}';" """.format(
        user=env.deploy_user,
        pwd=env.password,
        host=os.environ['DATABASE_HOST']
    ))

    run_as_pg("""psql -U postgres -h {host} -c "ALTER USER {user} SUPERUSER;" """.format(
        user=env.deploy_user,
        host=os.environ['DATABASE_HOST']
    ))

    database_name = os.environ['DATABASE_NAME']
    fabtools.icanhaz.postgres.database(database_name, env.deploy_user)
    # the following two lines below should be enabled for postgis 2.0 (also remove template_postgis from above lines)
    psql("CREATE EXTENSION IF NOT EXISTS POSTGIS")
    psql("CREATE EXTENSION IF NOT EXISTS DBLINK")

    psql("ALTER DATABASE {database_name} SET search_path = '$user',public,postgis;".format(database_name=database_name)) 
开发者ID:CalthorpeAnalytics,项目名称:urbanfootprint,代码行数:36,代码来源:methods.py

示例8: db_pass

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def db_pass():
    """
    Prompts for the database password if unknown.
    """
    if not env.db_pass:
        env.db_pass = getpass("Enter the database password: ")
    return env.db_pass 
开发者ID:keithadavidson,项目名称:ansible-mezzanine,代码行数:9,代码来源:fabfile.py

示例9: remote_server

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def remote_server():
    env.hosts = ['127.0.0.1']
    env.user = prompt('Enter user name: ')
    env.password = getpass('Enter password: ') 
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:6,代码来源:6_4_install_python_package_remotely.py

示例10: remote_server

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def remote_server():
    env.hosts = ['127.0.0.1']
    env.user = prompt('Enter user name: ')
    env.password = getpass('Enter your system password: ') 
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:6,代码来源:6_7_configure_Apache_for_hosting_website_remotely.py

示例11: remote_server

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def remote_server():
    env.hosts = ['127.0.0.1']
    env.password = getpass('Enter your system password: ')
    env.home_folder = '/tmp' 
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:6,代码来源:6_6_transfer_file_over_ssh.py

示例12: remote_server

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def remote_server():
    env.hosts = ['127.0.0.1']
    env.user = prompt('Enter your system username: ')
    env.password = getpass('Enter your system user password: ')
    env.mysqlhost = 'localhost'
    env.mysqluser = prompt('Enter your db username: ')
    env.mysqlpassword = getpass('Enter your db user password: ')
    env.db_name = '' 
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:10,代码来源:6_5_run_mysql_command_remotely.py

示例13: create_db

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def create_db():
    """Create a MySQL DB for App version"""
    if not env.db_name:
        db_name = prompt("Enter the DB name:")
    else:
        db_name = env.db_name
    run('echo "CREATE DATABASE %s default character set utf8 collate utf8_unicode_ci;"|mysql --batch --user=%s --password=%s --host=%s'\
         % (db_name, env.mysqluser, env.mysqlpassword, env.mysqlhost), pty=True) 
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:10,代码来源:6_5_run_mysql_command_remotely.py

示例14: svn_co_admin

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def svn_co_admin():

    print green('Checkout the mall admin repo via svn.')

    # Create necessary directory.
    run('mkdir -p '+svn_sw_dir+' 2>/dev/null >/dev/null')
    run('mkdir -p '+svn_admin_path+' 2>/dev/null >/dev/null')

    # Check out.
    with cd(svn_sw_dir):
        run('svn co --username '+svn_admin_username+' --password '+svn_admin_password+' '+svn_admin_url+' '+svn_admin_path+'')

    print green('Checkout finished!')

# Checkout the mall api repo via svn function. 
开发者ID:dbarobin,项目名称:python-auto-deploy,代码行数:17,代码来源:auto_deploy_app_v_final.py

示例15: svn_co_api

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import password [as 别名]
def svn_co_api():

    print green('Checkout the mall api repo via svn.')

    # Create necessary directory.
    run('mkdir -p '+svn_sw_dir+' 2>/dev/null >/dev/null')
    run('mkdir -p '+svn_api_path+' 2>/dev/null >/dev/null')

    # Check out.
    with cd(svn_sw_dir):
        run('svn co --username '+svn_api_username+' --password '+svn_api_password+' '+svn_api_url+' '+svn_api_path+'')

    print green('Checkout finished!')

# Update the mall admin repo via svn function. 
开发者ID:dbarobin,项目名称:python-auto-deploy,代码行数:17,代码来源:auto_deploy_app_v_final.py


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