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


Python config.load_shub_config函数代码示例

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


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

示例1: test_autocreate_empty_global_scrapinghub_yml

 def test_autocreate_empty_global_scrapinghub_yml(self):
     os.remove(self.globalpath)
     os.remove(self.globalscrapycfgpath)
     os.remove(self.netrcpath)
     load_shub_config()
     self.assertTrue(os.path.isfile(self.globalpath))
     with open(self.globalpath, 'r') as f:
         self.assertEqual(f.read(), "")
开发者ID:carlosp420,项目名称:shub,代码行数:8,代码来源:test_config.py

示例2: cli

def cli():
    global_conf = load_shub_config(load_local=False, load_env=False)
    if 'default' in global_conf.apikeys:
        raise AlreadyLoggedInException

    conf = load_shub_config()
    key = _get_apikey(
        suggestion=conf.apikeys.get('default'),
        endpoint=global_conf.endpoints.get('default'),
    )
    with update_yaml_dict(GLOBAL_SCRAPINGHUB_YML_PATH) as conf:
        conf.setdefault('apikeys', {})
        conf['apikeys']['default'] = key
开发者ID:scrapinghub,项目名称:shub,代码行数:13,代码来源:login.py

示例3: test_remove_key

 def test_remove_key(self):
     GLOBAL_SH_YML = textwrap.dedent("""
         apikeys:
             default: LOGGED_IN_KEY
     """)
     with self.runner.isolated_filesystem():
         with open('.scrapinghub.yml', 'w') as f:
             f.write(GLOBAL_SH_YML)
         conf = config.load_shub_config()
         self.assertIn('default', conf.apikeys)
         self.runner.invoke(logout.cli)
         conf = config.load_shub_config()
         self.assertNotIn('default', conf.apikeys)
开发者ID:bbotella,项目名称:shub,代码行数:13,代码来源:test_logout.py

示例4: build_cmd

def build_cmd(target, version, skip_tests, no_cache, filename='Dockerfile'):
    config = load_shub_config()
    create_scrapinghub_yml_wizard(config, target=target, image=True)
    client = utils.get_docker_client()
    project_dir = utils.get_project_dir()
    image = config.get_image(target)
    image_name = utils.format_image_name(image, version)
    if not os.path.exists(os.path.join(project_dir, filename)):
        raise shub_exceptions.NotFoundException(
            "Dockerfile is not found and it is required because project '{}' is configured "
            "to deploy Docker images. Please add a Dockerfile that will be used to build "
            "the image and retry this command. If you want to migrate an existing Scrapy project "
            "you can use `shub image init` command to create a Dockerfile.".format(target))
    if utils.is_verbose():
        build_progress_cls = _LoggedBuildProgress
    else:
        build_progress_cls = _BuildProgress
    click.echo("Building {}.".format(image_name))
    events = client.build(
        path=project_dir,
        tag=image_name,
        decode=True,
        dockerfile=filename,
        nocache=no_cache
    )
    build_progress = build_progress_cls(events)
    build_progress.show()
    click.echo("The image {} build is completed.".format(image_name))
    # Test the image content after building it
    if not skip_tests:
        test_cmd(target, version)
开发者ID:scrapinghub,项目名称:shub,代码行数:31,代码来源:build.py

示例5: push_cmd

def push_cmd(target, version, username, password, email, apikey, insecure, skip_tests):
    # Test the image content after building it
    if not skip_tests:
        test_cmd(target, version)

    client = utils.get_docker_client()
    config = load_shub_config()
    image = config.get_image(target)
    username, password = utils.get_credentials(
        username=username, password=password, insecure=insecure,
        apikey=apikey, target_apikey=config.get_apikey(target))

    if username:
        _execute_push_login(client, image, username, password, email)
    image_name = utils.format_image_name(image, version)
    click.echo("Pushing {} to the registry.".format(image_name))
    events = client.push(image_name, stream=True, decode=True,
                         insecure_registry=not bool(username))
    if utils.is_verbose():
        push_progress_cls = _LoggedPushProgress
    else:
        push_progress_cls = _PushProgress
    push_progress = push_progress_cls(events)
    push_progress.show()
    click.echo("The image {} pushed successfully.".format(image_name))
开发者ID:scrapinghub,项目名称:shub,代码行数:25,代码来源:push.py

示例6: deploy_cmd

def deploy_cmd(target, version, debug, egg, build_egg, verbose, keep_log,
               conf=None):
    tmpdir = None
    try:
        if build_egg:
            egg, tmpdir = _build_egg()
            click.echo("Writing egg to %s" % build_egg)
            shutil.copyfile(egg, build_egg)
        else:
            conf = conf or load_shub_config()
            targetconf = conf.get_target_conf(target)
            version = version or targetconf.version
            auth = (targetconf.apikey, '')

            if egg:
                click.echo("Using egg: %s" % egg)
                egg = egg
            else:
                click.echo("Packing version %s" % version)
                egg, tmpdir = _build_egg()

            _upload_egg(targetconf.endpoint, egg, targetconf.project_id,
                        version, auth, verbose, keep_log, targetconf.stack,
                        targetconf.requirements_file, targetconf.eggs)
            click.echo("Run your spiders at: "
                       "https://app.scrapinghub.com/p/%s/"
                       "" % targetconf.project_id)
    finally:
        if tmpdir:
            if debug:
                click.echo("Output dir not removed: %s" % tmpdir)
            else:
                shutil.rmtree(tmpdir, ignore_errors=True)
开发者ID:scrapinghub,项目名称:shub,代码行数:33,代码来源:deploy.py

示例7: list_targets

def list_targets(ctx, param, value):
    if not value:
        return
    conf = load_shub_config()
    for name in conf.projects:
        click.echo(name)
    ctx.exit()
开发者ID:pawelmhm,项目名称:shub,代码行数:7,代码来源:deploy.py

示例8: test_envvar_precedence

 def test_envvar_precedence(self):
     _old_environ = dict(os.environ)
     os.environ['SHUB_APIKEY'] = 'key_env'
     conf = load_shub_config()
     self.assertEqual(conf.get_apikey('shproj'), 'key_env')
     os.environ.clear()
     os.environ.update(_old_environ)
开发者ID:carlosp420,项目名称:shub,代码行数:7,代码来源:test_config.py

示例9: cli

def cli():
    global_conf = load_shub_config(load_local=False, load_env=False)
    if 'default' not in global_conf.apikeys:
        click.echo("You are not logged in.")
        return 0

    with update_config() as conf:
        del conf['apikeys']['default']
开发者ID:jsargiot,项目名称:shub,代码行数:8,代码来源:logout.py

示例10: cli

def cli():
    global_conf = load_shub_config(load_local=False, load_env=False)
    if 'default' not in global_conf.apikeys:
        click.echo("You are not logged in.")
        return 0

    with update_yaml_dict(GLOBAL_SCRAPINGHUB_YML_PATH) as conf:
        del conf['apikeys']['default']
开发者ID:scrapinghub,项目名称:shub,代码行数:8,代码来源:logout.py

示例11: test_scrapinghub_ymls_read

 def test_scrapinghub_ymls_read(self):
     conf = load_shub_config()
     self.assertEqual(conf.get_apikey('shproj'), 'key')
     self.assertEqual(
         conf.get_endpoint('externalproj'),
         'local_ext_endpoint',
     )
     self.assertEqual(conf.get_apikey('externalproj'), 'key_ext')
     with self.assertRaises(BadParameterException):
         conf.get_project_id('ext2')
开发者ID:carlosp420,项目名称:shub,代码行数:10,代码来源:test_config.py

示例12: test_cmd

def test_cmd(target, version):
    config = load_shub_config()
    image = config.get_image(target)
    version = version or config.get_version()
    image_name = utils.format_image_name(image, version)
    docker_client = utils.get_docker_client()
    for check in [_check_image_size,
                  _check_start_crawl_entry,
                  _check_shub_image_info_entry]:
        check(image_name, docker_client)
开发者ID:scrapinghub,项目名称:shub,代码行数:10,代码来源:test.py

示例13: _check_conf

 def _check_conf():
     conf = load_shub_config()
     self.assertEqual(
         conf.get_target('default'),
         (222, 'scrapycfg_endpoint', 'key'),
     )
     self.assertEqual(
         conf.get_target('ext2'),
         (333, 'ext2_endpoint', 'ext2_key'),
     )
     self.assertEqual(conf.get_version(), 'ext2_ver')
开发者ID:jsargiot,项目名称:shub,代码行数:11,代码来源:test_config.py

示例14: _check_conf

 def _check_conf():
     conf = load_shub_config()
     self.assertEqual(
         conf.get_target('123'),
         (123, 'dotsc_endpoint', 'netrc_key'),
     )
     self.assertEqual(conf.projects['ext2'], 'ext2/333')
     self.assertEqual(
         conf.get_target('ext2'),
         (333, 'ext2_endpoint', 'ext2_key'),
     )
开发者ID:carlosp420,项目名称:shub,代码行数:11,代码来源:test_config.py

示例15: list_cmd_full

def list_cmd_full(target, silent, version):
    config = load_shub_config()
    image = config.get_image(target)
    version = version or config.get_version()
    image_name = utils.format_image_name(image, version)
    target_conf = config.get_target_conf(target)
    metadata = list_cmd(image_name,
                        target_conf.project_id,
                        target_conf.endpoint,
                        target_conf.apikey)
    for spider in metadata.get('spiders', []):
        click.echo(spider)
开发者ID:scrapinghub,项目名称:shub,代码行数:12,代码来源:list.py


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