list.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:shub-image 作者: scrapinghub 项目源码 文件源码
def _run_list_cmd(project, image_name, project_settings):
    """Run `scrapy list` command inside the image container."""

    client = utils.get_docker_client()
    # FIXME we should pass some value for SCRAPY_PROJECT_ID anyway
    # to handle `scrapy list` cmd properly via sh_scrapy entrypoint
    project = str(project) if project else ''
    job_settings = json.dumps(project_settings)
    container = client.create_container(
        image=image_name,
        command=['list-spiders'],
        environment={'SCRAPY_PROJECT_ID': project,
                     'JOB_SETTINGS': job_settings})
    if 'Id' not in container:
        raise shub_exceptions.ShubException(
            "Create container error:\n %s" % container)

    client.start(container)
    statuscode = client.wait(container=container['Id'])

    return statuscode, client.logs(
            container=container['Id'],
            stdout=True, stderr=True if statuscode else False,
            stream=False, timestamps=False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号