當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。