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


Python env.hosts方法代码示例

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


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

示例1: upload_release

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def upload_release():
    """
    Uploads sources and documentation to AWS instance.
    """
    # Create and upload the sources
    sources = "ngas_src-{0}.tar.gz".format(ngas_revision())
    if os.path.exists(sources):
        os.unlink(sources)
    create_sources_tarball(sources)
    try:
        upload_to(env.hosts[0], sources)
    finally:
        os.unlink(sources)

    # Generate a PDF documentation and upload it too
    local("make -C %s/doc latexpdf" % (repo_root()))
    upload_to(env.hosts[0], '%s/doc/_build/latex/ngas.pdf' % (repo_root())) 
开发者ID:ICRAR,项目名称:ngas,代码行数:19,代码来源:hl.py

示例2: test_tracking_does_not_break_deploy

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def test_tracking_does_not_break_deploy(self):
        mock_core = Mendel("some_name", slack_url="some_url")
        env.hosts = "127.0.0.1"
        mock_core.build = MagicMock()
        mock_core.upload = MagicMock()
        mock_core.install = MagicMock()
        mock_core._start_or_restart = MagicMock()
        mock_core._track_event_graphite = MagicMock()
        mock_core._track_event_api = MagicMock()
        self.assertRaises(ValueError, mock_core.deploy)
        mock_core.build.assert_called_with()
        mock_core.upload.assert_called_with()
        mock_core.install.assert_called_with()
        mock_core._start_or_restart.assert_called_with()
        mock_core._track_event_graphite.assert_called_with('deployed')
        mock_core._track_event_api.assert_called_with('deployed') 
开发者ID:sproutsocial,项目名称:mendel,代码行数:18,代码来源:test_core.py

示例3: build

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def build(self):
        """
        [advanced]\tbuilds new application bundle for your service using maven (if java)
        or setup.py (if python).

        if using java, it is highly recommended that you use the
        maven-assembly-plugin as a standard, it makes bundling files together into
        archives straightforward.

        Note: only builds once, no matter how many hosts!
        """
        if not self._is_already_built():
            if self._project_type == "java":
                local('mvn clean -U package')
            elif self._project_type == "python":
                if self._bundle_type == "tgz":
                    local('python setup.py sdist')
                else:
                    raise Exception("Unsupported bundle type: {} for project type: {}".format(self._bundle_type, self._project_type))
            else:
                raise Exception("Unsupported project type: %s" % self._project_type)
            self._mark_as_built() 
开发者ID:sproutsocial,项目名称:mendel,代码行数:24,代码来源:core.py

示例4: setup_server

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def setup_server(stage="production"):
    """
    Install app in selected server(s).
    """
    set_stage(stage)
    set_user(superuser=True)
    execute(Server.deps, hosts=env.hosts)
    execute(Server.user, hosts=env.hosts)
    execute(Server.group, hosts=env.hosts)
    execute(Server.create_db, hosts=env.hosts)
    execute(Server.git, hosts=env.hosts)
    execute(Server.add_remote, hosts=env.hosts)
    execute(Server.web_server, hosts=env.hosts)
    execute(Server.gunicorn, hosts=env.hosts)
    execute(Server.supervisor, hosts=env.hosts)
    execute(Server.letsencrypt, hosts=env.hosts)
    execute(Server.var, hosts=env.hosts)
    execute(Server.pip_cache, hosts=env.hosts)
    execute(Server.fix_permissions, hosts=env.hosts) 
开发者ID:vicobits,项目名称:suarm,代码行数:21,代码来源:actions.py

示例5: set_stage

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def set_stage(stage='production'):
    servers = get_server_config()
    if stage in servers.keys():
        env.stage = stage
        env.project = get_value(env.stage, "project")
        env.domain = get_value(env.stage, "domain")
        env.passwd = get_value(env.stage, "password", default="11002299338844775566")
        env.urls = get_value(env.stage, "urls")
        env.db_engine = get_value(env.stage, "db_engine", default=DB_POSTGRESQL)
        env.hosts = [get_value(env.stage, "ipv4")]
        env.web_server = get_value(env.stage, "web_server", default=WS_NGINX)
        env.ipv4 = get_value(env.stage, "ipv4")
        env.https = get_value(env.stage, "https", default=True)
        if env.https and not has_key(env.stage, "email"):
            sys.exit('\n\n[https] activated for [%s] server, [email] value is needed to continue...\n' % stage)
        else:
            env.email = get_value(env.stage, "email")

    else:
        sys.exit("[%s] server doesn't registered into config file" % stage) 
开发者ID:vicobits,项目名称:suarm,代码行数:22,代码来源:config.py

示例6: start_edit_fontello_fonts

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def start_edit_fontello_fonts():
    """Prepare to edit the fontello fonts in Fontello."""
    assert are_local(env.hosts), "Meant to be run locally"
    import requests
    font_dir = join(
        env.projectpath, 'assembl', 'static', 'css', 'fonts')
    config_file = join(font_dir, 'config.json')
    id_file = join(font_dir, 'fontello.id')
    r = requests.post("http://fontello.com",
                    files={'config': open(config_file)})
    if not r.ok:
        raise RuntimeError("Could not get the ID")
    fid = r.text
    with open(id_file, 'w') as f:
        f.write(fid)
    if are_local(env.hosts):
        import webbrowser
        webbrowser.open('http://fontello.com/' + fid) 
开发者ID:conversence,项目名称:idealoom,代码行数:20,代码来源:fabfile.py

示例7: compile_fontello_fonts

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def compile_fontello_fonts():
    """Compile the fontello fonts once you have edited them in Fontello. Run start_edit_fontello_fonts first."""
    from zipfile import ZipFile
    from io import BytesIO
    assert are_local(env.hosts), "Meant to be run locally"
    import requests
    font_dir = join(
        env.projectpath, 'assembl', 'static', 'css', 'fonts')
    config_file = join(font_dir, 'config.json')
    id_file = join(font_dir, 'fontello.id')
    assert os.path.exists(id_file)
    with open(id_file) as f:
        fid = f.read()
    r = requests.get("http://fontello.com/%s/get" % fid)
    if not r.ok:
        raise RuntimeError("Could not get the data")
    with ZipFile(BytesIO(r.content)) as data:
        for name in data.namelist():
            dirname, fname = split(name)
            dirname, subdir = split(dirname)
            if fname and (subdir == 'font' or fname == 'config.json'):
                with data.open(name) as fdata:
                    with open(join(font_dir, fname), 'wb') as ffile:
                        ffile.write(fdata.read()) 
开发者ID:conversence,项目名称:idealoom,代码行数:26,代码来源:fabfile.py

示例8: production

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def production():
    """
    Run as though on production.
    """
    env.settings = 'production'
    app_config.configure_targets(env.settings)
    env.hosts = app_config.SERVERS 
开发者ID:nprapps,项目名称:django-starter-kit,代码行数:9,代码来源:__init__.py

示例9: staging

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def staging():
    """
    Run as though on staging.
    """
    env.settings = 'staging'
    app_config.configure_targets(env.settings)
    env.hosts = app_config.SERVERS 
开发者ID:nprapps,项目名称:django-starter-kit,代码行数:9,代码来源:__init__.py

示例10: aws_deploy

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def aws_deploy():
    """Deploy NGAS on fresh AWS EC2 instances."""
    # This task doesn't have @parallel because its initial work
    # (actually *creating* the target host(s)) is serial.
    # After that it modifies the env.hosts to point to the target hosts
    # and then calls execute(prepare_install_and_check) which will be parallel
    create_aws_instances()
    execute(prepare_install_and_check) 
开发者ID:ICRAR,项目名称:ngas,代码行数:10,代码来源:hl.py

示例11: create_aws_instances

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def create_aws_instances():
    """
    Create AWS instances and let Fabric point to them

    This method creates AWS instances and points the fabric environment to them with
    the current public IP and username.
    """

    default_if_empty(env, 'AWS_KEY_NAME',      DEFAULT_AWS_KEY_NAME)
    default_if_empty(env, 'AWS_INSTANCE_NAME', default_instance_name)

    # Create the key pair and security group if necessary
    conn = connect()
    aws_create_key_pair(conn)
    sgid = check_create_aws_sec_group(conn)

    # Create the instance in AWS
    host_names = create_instances(conn, sgid)

    # Update our fabric environment so from now on we connect to the
    # AWS machine using the correct user and SSH private key
    env.hosts = host_names
    env.key_filename = key_filename(env.AWS_KEY_NAME)
    if env.AWS_AMI_NAME in ['CentOS', 'SLES']:
        env.user = 'root'
    else:
        env.user = 'ec2-user'

    # Instances have started, but are not usable yet, make sure SSH has started
    puts('Started the instance(s) now waiting for the SSH daemon to start.')
    execute(check_ssh, timeout=300) 
开发者ID:ICRAR,项目名称:ngas,代码行数:33,代码来源:aws.py

示例12: _new_release_dir

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def _new_release_dir(self):
        """
        generate a new release dir for the remote hosts, this needs to be the same across hosts
        to make it clearer that they all have the same release/build. yes this is semi-brittle,
        but for most situations it should be adequate. introducing amazon S3 to hold builds
        could make this less brittle. having CI would be even better but we're not there yet.
        """
        if self._release_dir is None:
            release_dir_args = (datetime.utcnow().strftime('%Y%m%d-%H%M%S'), getpass.getuser(), self._get_commit_hash())
            self._release_dir = '%s-%s-%s' % release_dir_args
        return self._release_dir 
开发者ID:sproutsocial,项目名称:mendel,代码行数:13,代码来源:core.py

示例13: _missing_hosts

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def _missing_hosts(self):
        return not bool(env.hosts) 
开发者ID:sproutsocial,项目名称:mendel,代码行数:4,代码来源:core.py

示例14: install

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def install(self):
        """
        [advanced]\tinstall latest build on the hosts you specify
        """
        try:
            bundle_file = self._get_bundle_name()
        except Exception as e:
            print red(e.message)
            sys.exit(1)

        self._install(bundle_file)
        print green('Successfully installed new release of %s service' % self._service_name) 
开发者ID:sproutsocial,项目名称:mendel,代码行数:14,代码来源:core.py

示例15: tail

# 需要导入模块: from fabric.state import env [as 别名]
# 或者: from fabric.state.env import hosts [as 别名]
def tail(self, log_name="output.log"):
        """
        [core]\t\twatch the logs
        """
        if len(env.hosts) > 1:
            print red("can only tail logs on one host at a time")
            sys.exit(1)
        sudo('tail -f /var/log/%s/%s' % (self._service_name, log_name), user=self._user, group=self._group) 
开发者ID:sproutsocial,项目名称:mendel,代码行数:10,代码来源:core.py


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