Exemplo n.º 1
0
 def handle(self, *args, **options):
     if len(args):
         for slug in args:
             project_data = api.project(slug).get()
             p = tasks.make_api_project(project_data)
             log.info("Building %s" % p)
             tasks.update_docs(pk=p.pk)
Exemplo n.º 2
0
 def handle(self, *args, **options):
     docker = options.get('docker', False)
     for slug in options['projects']:
         project_data = api.project(slug).get()
         p = tasks.make_api_project(project_data)
         log.info("Building %s" % p)
         tasks.update_docs.run(pk=p.pk, docker=docker)
Exemplo n.º 3
0
 def get_project(project_pk):
     """
     Get project from API
     """
     project_data = api_v1.project(project_pk).get()
     project = make_api_project(project_data)
     return project
Exemplo n.º 4
0
 def handle(self, *args, **options):
     docker = options.get('docker', False)
     for slug in options['projects']:
         project_data = api.project(slug).get()
         p = tasks.make_api_project(project_data)
         log.info("Building %s", p)
         tasks.update_docs.run(pk=p.pk, docker=docker)
Exemplo n.º 5
0
 def get_project(project_pk):
     """
     Get project from API
     """
     project_data = api_v1.project(project_pk).get()
     project = make_api_project(project_data)
     return project
Exemplo n.º 6
0
 def handle(self, *args, **options):
     if len(args):
         for slug in args:
             project_data = api.project(slug).get()
             p = tasks.make_api_project(project_data)
             log.info("Building %s" % p)
             tasks.update_docs(pk=p.pk, docker=True)
Exemplo n.º 7
0
 def handle(self, *args, **options):
     docker = options.get('docker', False)
     for slug in options['projects']:
         project_data = api.project(slug).get()
         p = APIProject(**project_data)
         log.info("Building %s", p)
         # pylint: disable=no-value-for-parameter
         tasks.update_docs_task(p.pk, docker=docker)
Exemplo n.º 8
0
 def handle(self, *args, **options):
     docker = options.get('docker', False)
     for slug in options['projects']:
         project_data = api.project(slug).get()
         p = APIProject(**project_data)
         log.info("Building %s", p)
         update_docs = tasks.UpdateDocsTask()
         update_docs.run(pk=p.pk, docker=docker)
Exemplo n.º 9
0
def update_docs(pk, version_pk=None, build_pk=None, record=True, docker=False,
                search=True, force=False, intersphinx=True, localmedia=True,
                basic=False, **kwargs):
    """
    The main entry point for updating documentation.

    It handles all of the logic around whether a project is imported or we
    created it.  Then it will build the html docs and other requested parts.

    `pk`
        Primary key of the project to update

    `record`
        Whether or not to keep a record of the update in the database. Useful
        for preventing changes visible to the end-user when running commands
        from the shell, for example.

    """
    start_time = datetime.datetime.utcnow()
    try:
        project_data = api_v1.project(pk).get()
    except HttpClientError:
        log.exception(LOG_TEMPLATE.format(project=pk, version='', msg='Failed to get project data on build. Erroring.'))
    project = make_api_project(project_data)
    # Don't build skipped projects
    if project.skip:
        log.info(LOG_TEMPLATE.format(project=project.slug, version='', msg='Skipping'))
        return
    else:
        log.info(LOG_TEMPLATE.format(project=project.slug, version='', msg='Building'))
    version = ensure_version(project, version_pk)
    build = create_build(build_pk)
    results = {}

    # Build Servery stuff
    try:
        record_build(build=build, record=record, results=results, state='cloning')
        vcs_results = setup_vcs(version, build)
        if vcs_results:
            results.update(vcs_results)

        if project.documentation_type == 'auto':
            update_documentation_type(version)

        if docker or settings.DOCKER_ENABLE:
            record_build(build=build, record=record, results=results, state='building')
            docker = DockerEnvironment(version)
            build_results = docker.build()
            results.update(build_results)
        else:
            record_build(build=build, record=record, results=results, state='installing')
            setup_results = setup_environment(version)
            results.update(setup_results)

            record_build(build=build, record=record, results=results, state='building')
            build_results = build_docs(version, force, search, localmedia)
            results.update(build_results)

    except vcs_support_utils.LockTimeout, e:
        results['checkout'] = (423, "", "Version locked, retrying in 5 minutes.")
        log.info(LOG_TEMPLATE.format(project=version.project.slug,
                                     version=version.slug, msg="Unable to lock, will retry"))
        # http://celery.readthedocs.org/en/3.0/userguide/tasks.html#retrying
        # Should completely retry the task for us until max_retries is exceeded
        update_docs.retry(exc=e, throw=False)