예제 #1
0
def build_docs(project, version, pdf, record, touch):
    """
    A helper function for the celery task to do the actual doc building.
    """
    if not project.conf_file(version.slug):
        return ('','Conf file not found.',-1)

    html_builder = builder_loading.get('html')()
    if touch:
        html_builder.touch(version)
    html_builder.clean(version)
    html_output = html_builder.build(version)
    successful = (html_output[0] == 0)
    if not 'no targets are out of date.' in html_output[1]:
        if record:
            Build.objects.create(
                project=project,
                success=successful,
                output=html_output[1],
                error=html_output[2],
                version=version
            )

        if pdf:
            pdf_builder = builder_loading.get('pdf')()
            pdf_builder.build(version)
    if successful:
        move_docs(project, version)
        if version:
            version.active = True
            version.built = True
            version.save()
    return html_output
예제 #2
0
def build_docs(project, version, pdf, record, touch):
    """
    A helper function for the celery task to do the actual doc building.
    """
    if not project.conf_file(version.slug):
        return ('', 'Conf file not found.', -1)

    html_builder = builder_loading.get('html')()
    if touch:
        html_builder.touch(version)
    html_builder.clean(version)
    html_output = html_builder.build(version)
    successful = (html_output[0] == 0)
    if not 'no targets are out of date.' in html_output[1]:
        if record:
            Build.objects.create(project=project,
                                 success=successful,
                                 output=html_output[1],
                                 error=html_output[2],
                                 version=version)

        if pdf:
            pdf_builder = builder_loading.get('pdf')()
            pdf_builder.build(version)
    if successful:
        move_docs(project, version)
        if version:
            version.active = True
            version.built = True
            version.save()
    return html_output
예제 #3
0
def build_docs(version_pk, pdf, man, epub, dash, record, force):
    """
    This handles the actual building of the documentation and DB records
    """
    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)
    project = version.project

    if not project.conf_file(version.slug):
        return ('', 'Conf file not found.', -1)

    with project.repo_lock(getattr(settings, 'REPO_LOCK_SECONDS', 30)):

        html_builder = builder_loading.get(project.documentation_type)(version)
        if force:
            html_builder.force()
        html_builder.clean()
        html_results = html_builder.build()
        if html_results[0] == 0:
            html_builder.move()

        fake_results = (999, "Project Skipped, Didn't build",
                        "Project Skipped, Didn't build")
        # Only build everything else if the html build changed.
        if html_builder.changed and not project.skip:
            if pdf:
                pdf_builder = builder_loading.get('sphinx_pdf')(version)
                latex_results, pdf_results = pdf_builder.build()
                # Always move pdf results even when there's an error.
                #if pdf_results[0] == 0:
                pdf_builder.move()
            else:
                pdf_results = latex_results = fake_results
            if man:
                man_builder = builder_loading.get('sphinx_man')(version)
                man_results = man_builder.build()
                if man_results[0] == 0:
                    man_builder.move()
            else:
                man_results = fake_results
            if epub:
                epub_builder = builder_loading.get('sphinx_epub')(version)
                epub_results = epub_builder.build()
                if epub_results[0] == 0:
                    epub_builder.move()
            else:
                epub_results = fake_results
            # Disable dash building for now.
            dash = False
            if dash:
                dash_builder = builder_loading.get('sphinx_dash')(version)
                dash_results = dash_builder.build()
                if dash_results[0] == 0:
                    dash_builder.move()
            else:
                dash_results = fake_results

    return (html_results, latex_results, pdf_results, man_results,
            epub_results, dash_results)
예제 #4
0
def build_docs(version_pk, pdf, man, epub, dash, record, force):
    """
    This handles the actual building of the documentation and DB records
    """
    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)
    project = version.project

    if not project.conf_file(version.slug):
        return ('', 'Conf file not found.', -1)

    with project.repo_lock(getattr(settings, 'REPO_LOCK_SECONDS', 30)):

        html_builder = builder_loading.get(project.documentation_type)(version)
        if force:
            html_builder.force()
        html_builder.clean()
        html_results = html_builder.build()
        if html_results[0] == 0:
            html_builder.move()

        fake_results = (999, "Project Skipped, Didn't build",
                        "Project Skipped, Didn't build")
        # Only build everything else if the html build changed.
        if html_builder.changed and not project.skip:
            if pdf:
                pdf_builder = builder_loading.get('sphinx_pdf')(version)
                latex_results, pdf_results = pdf_builder.build()
                # Always move pdf results even when there's an error.
                #if pdf_results[0] == 0:
                pdf_builder.move()
            else:
                pdf_results = latex_results = fake_results
            if man:
                man_builder = builder_loading.get('sphinx_man')(version)
                man_results = man_builder.build()
                if man_results[0] == 0:
                    man_builder.move()
            else:
                man_results = fake_results
            if epub:
                epub_builder = builder_loading.get('sphinx_epub')(version)
                epub_results = epub_builder.build()
                if epub_results[0] == 0:
                    epub_builder.move()
            else:
                epub_results = fake_results
            # Disable dash building for now.
            dash = False
            if dash:
                dash_builder = builder_loading.get('sphinx_dash')(version)
                dash_results = dash_builder.build()
                if dash_results[0] == 0:
                    dash_builder.move()
            else:
                dash_results = fake_results

    return (html_results, latex_results, pdf_results, man_results,
            epub_results, dash_results)
예제 #5
0
def build_docs(project,
               version,
               pdf,
               man,
               epub,
               record,
               force,
               update_output={}):
    """
    This handles the actual building of the documentation and DB records
    """
    if not project.conf_file(version.slug):
        return ('', 'Conf file not found.', -1)

    html_builder = builder_loading.get(project.documentation_type)(version)
    if force:
        html_builder.force()
    html_builder.clean()
    html_output = html_builder.build()
    successful = (html_output[0] == 0)
    if successful:
        html_builder.move()
        if version:
            version.active = True
            version.built = True
            version.save()
    if html_builder.changed:
        if record:
            output_data = error_data = ''
            for key in [
                    'checkout', 'venv', 'sphinx', 'requirements', 'install'
            ]:
                data = update_output.get(key, None)
                if data:
                    output_data += data[1]
                    error_data += data[2]
            Build.objects.create(project=project,
                                 success=successful,
                                 setup=output_data,
                                 setup_error=error_data,
                                 output=html_output[1],
                                 error=html_output[2],
                                 version=version)
        #XXX:dc: all builds should have their output checked
        if pdf:
            pdf_builder = builder_loading.get('sphinx_pdf')(version)
            pdf_builder.build()
            #PDF Builder is oddly 2-steped, and stateful for now
            #pdf_builder.move(version)
        if man:
            man_builder = builder_loading.get('sphinx_man')(version)
            man_builder.build()
            man_builder.move()
        if epub:
            epub_builder = builder_loading.get('sphinx_epub')(version)
            epub_builder.build()
            epub_builder.move()
    return html_output
예제 #6
0
def build_docs(project, version, pdf, man, epub, record, force, update_output={}):
    """
    This handles the actual building of the documentation and DB records
    """
    if not project.conf_file(version.slug):
        return ("", "Conf file not found.", -1)

    html_builder = builder_loading.get(project.documentation_type)(version)
    if force:
        html_builder.force()
    html_builder.clean()
    html_output = html_builder.build()
    successful = html_output[0] == 0
    if successful:
        html_builder.move()
        if version:
            version.active = True
            version.built = True
            version.save()
    if html_builder.changed:
        if record:
            output_data = error_data = ""
            for key in ["checkout", "venv", "sphinx", "requirements", "install"]:
                data = update_output.get(key, None)
                if data:
                    output_data += data[1]
                    error_data += data[2]
            Build.objects.create(
                project=project,
                success=successful,
                setup=output_data,
                setup_error=error_data,
                output=html_output[1],
                error=html_output[2],
                version=version,
            )
        # XXX:dc: all builds should have their output checked
        if pdf:
            pdf_builder = builder_loading.get("sphinx_pdf")(version)
            pdf_builder.build()
            # PDF Builder is oddly 2-steped, and stateful for now
            # pdf_builder.move(version)
        if man:
            man_builder = builder_loading.get("sphinx_man")(version)
            man_builder.build()
            man_builder.move()
        if epub:
            epub_builder = builder_loading.get("sphinx_epub")(version)
            epub_builder.build()
            epub_builder.move()
    return html_output
예제 #7
0
def build_docs(project, version, pdf, man, epub, record, force, update_output={}):
    """
    This handles the actual building of the documentation and DB records
    """
    if not project.conf_file(version.slug):
        return ('', 'Conf file not found.', -1)

    html_builder = builder_loading.get(project.documentation_type)(version)
    if force:
        html_builder.force()
    html_builder.clean()
    html_output = html_builder.build()
    successful = (html_output[0] == 0)
    if successful:
        html_builder.move()
        if version:
            version.active = True
            version.built = True
            version.save()
    if html_builder.changed:
        if record:
            output_data = error_data = ''
            for key in ['checkout', 'venv', 'sphinx', 'requirements', 'install']:
                data = update_output.get(key, None)
                if data:
                    output_data += data[1]
                    error_data += data[2]
            Build.objects.create(
                project=project,
                success=successful,
                setup=output_data,
                setup_error=error_data,
                output=html_output[1],
                error=html_output[2],
                version=version
            )
        #XXX:dc: all builds should have their output checked
        if pdf:
            pdf_builder = builder_loading.get('sphinx_pdf')(version)
            pdf_builder.build()
            # We are using the rst2pdf builder this time
            pdf_builder.move()
        if man:
            man_builder = builder_loading.get('sphinx_man')(version)
            man_result = man_builder.build()
            man_builder.move()
        if epub:
            epub_builder = builder_loading.get('sphinx_epub')(version)
            epub_result = epub_builder.build()
            epub_builder.move()
    return html_output
예제 #8
0
def build_docs(project, build, version, pdf, man, epub, record, force, update_output={}):
    """
    This handles the actual building of the documentation and DB records
    """
    if not project.conf_file(version.slug):
        return ('', 'Conf file not found.', -1)

    html_builder = builder_loading.get(project.documentation_type)(version)
    if force:
        html_builder.force()
    html_builder.clean()
    html_output = html_builder.build()
    successful = (html_output[0] == 0)
    if successful:
        html_builder.move()
        if version:
            version_data = api.version(version.pk).get()
            version_data['active'] = True
            version_data['built'] = True
            #Need to delete this because a bug in tastypie breaks on the users list.
            del version_data['project']
            try:
                api.version(version.pk).put(version_data)
            except Exception, e:
                log.error("Unable to post a new version", exc_info=True)
예제 #9
0
def build_docs(project,
               build,
               version,
               pdf,
               man,
               epub,
               record,
               force,
               update_output={}):
    """
    This handles the actual building of the documentation and DB records
    """
    if not project.conf_file(version.slug):
        return ('', 'Conf file not found.', -1)

    html_builder = builder_loading.get(project.documentation_type)(version)
    if force:
        html_builder.force()
    html_builder.clean()
    html_output = html_builder.build()
    successful = (html_output[0] == 0)
    if successful:
        html_builder.move()
        if version:
            version_data = api.version(version.pk).get()
            version_data['active'] = True
            version_data['built'] = True
            #Need to delete this because a bug in tastypie breaks on the users list.
            del version_data['project']
            try:
                api.version(version.pk).put(version_data)
            except Exception, e:
                log.error("Unable to post a new version", exc_info=True)
예제 #10
0
def build_docs(project, version, pdf, man, epub, record, force):
    """
    This handles the actual building of the documentation and DB records
    """
    if not project.conf_file(version.slug):
        return ('', 'Conf file not found.', -1)

    html_builder = builder_loading.get(project.documentation_type)(version)
    if force:
        html_builder.force()
    html_builder.clean()
    html_output = html_builder.build()
    successful = (html_output[0] == 0)
    if successful:
        html_builder.move()
        if version:
            version.active = True
            version.built = True
            version.save()
    if html_builder.changed:
        if record:
            Build.objects.create(
                project=project,
                success=successful,
                output=html_output[1],
                error=html_output[2],
                version=version
            )
        #XXX:dc: all builds should have their output checked
        if pdf:
            pdf_builder = builder_loading.get('sphinx_pdf')(version)
            pdf_builder.build()
            #PDF Builder is oddly 2-steped, and stateful for now
            #pdf_builder.move(version)
        if man:
            man_builder = builder_loading.get('sphinx_man')(version)
            man_builder.build()
            man_builder.move()
        if epub:
            epub_builder = builder_loading.get('sphinx_epub')(version)
            epub_builder.build()
            epub_builder.move()
    return html_output
예제 #11
0
         data = update_output.get(key, None)
         if data:
             output_data += data[1]
             error_data += data[2]
     #Update build.
     build['success'] = successful
     build['setup'] = output_data
     build['setup_error'] = error_data
     build['output'] = html_output[1]
     build['error'] = html_output[2]
     build['state'] = 'finished'
     build['project'] = '/api/v1/project/%s/' % project.pk
     build['version'] = '/api/v1/version/%s/' % version.pk
     api.build(build['id']).put(build)
 if pdf and not project.skip:
     pdf_builder = builder_loading.get('sphinx_pdf')(version)
     latex_results, pdf_results = pdf_builder.build()
     if record:
         api.build.post(
             dict(
                 project='/api/v1/project/%s/' % project.pk,
                 version='/api/v1/version/%s/' % version.pk,
                 success=pdf_results[0] == 0,
                 type='pdf',
                 setup=latex_results[1],
                 setup_error=latex_results[2],
                 output=pdf_results[1],
                 error=pdf_results[2],
             ))
     #PDF Builder is oddly 2-steped, and stateful for now
     #pdf_builder.move(version)
예제 #12
0
def build_docs(version, force, pdf, man, epub, dash, search, localmedia):
    """
    This handles the actual building of the documentation
    """

    project = version.project
    results = {}

    if 'sphinx' in project.documentation_type:
        try:
            project.conf_file(version.slug)
        except ProjectImportError:
            results['html'] = (999, 'Conf file not found.', '')
            return results

    with project.repo_nonblockinglock(version=version,
                                      max_lock_age=getattr(
                                          settings, 'REPO_LOCK_SECONDS', 30)):
        html_builder = builder_loading.get(project.documentation_type)(version)
        if force:
            html_builder.force()
        #html_builder.clean()
        if 'sphinx' in project.documentation_type:
            html_builder.append_conf()
        results['html'] = html_builder.build()
        if results['html'][0] == 0:
            html_builder.move()

        fake_results = (999, "Project Skipped, Didn't build",
                        "Project Skipped, Didn't build")
        if 'sphinx' in project.documentation_type:
            # Search builder. Creates JSON from docs and sends it to the server.
            if search:
                try:
                    search_builder = builder_loading.get('sphinx_search')(
                        version)
                    results['search'] = search_builder.build()
                    if results['search'][0] == 0:
                        # Copy json for safe keeping
                        search_builder.move()
                except:
                    log.error(LOG_TEMPLATE.format(project=project.slug,
                                                  version=version.slug,
                                                  msg="JSON Build Error"),
                              exc_info=True)
            # Local media builder for singlepage HTML download archive
            if localmedia:
                try:
                    localmedia_builder = builder_loading.get(
                        'sphinx_singlehtmllocalmedia')(version)
                    results['localmedia'] = localmedia_builder.build()
                    if results['localmedia'][0] == 0:
                        localmedia_builder.move()
                except:
                    log.error(LOG_TEMPLATE.format(
                        project=project.slug,
                        version=version.slug,
                        msg="Local Media HTML Build Error"),
                              exc_info=True)

            # Optional build steps
            if version.project.slug not in HTML_ONLY and not project.skip:
                if pdf:
                    pdf_builder = builder_loading.get('sphinx_pdf')(version)
                    results['pdf'] = pdf_builder.build()
                    # Always move pdf results even when there's an error.
                    #if pdf_results[0] == 0:
                    pdf_builder.move()
                else:
                    results['pdf'] = fake_results
                if epub:
                    epub_builder = builder_loading.get('sphinx_epub')(version)
                    results['epub'] = epub_builder.build()
                    if results['epub'][0] == 0:
                        epub_builder.move()
                else:
                    results['epub'] = fake_results
    return results
예제 #13
0
def build_docs(version_pk, pdf, man, epub, dash, search, record, force):
    """
    This handles the actual building of the documentation and DB records
    """
    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)
    project = version.project

    if not project.conf_file(version.slug):
        return ('', 'Conf file not found.', -1)

    with project.repo_lock(getattr(settings, 'REPO_LOCK_SECONDS', 30)):

        html_builder = builder_loading.get(project.documentation_type)(version)
        if force:
            html_builder.force()
        html_builder.clean()
        html_results = html_builder.build()
        if html_results[0] == 0:
            html_builder.move()

        fake_results = (999, "Project Skipped, Didn't build",
                        "Project Skipped, Didn't build")
        # Only build everything else if the html build changed.
        if html_builder.changed and not project.skip:
            if dash:
                dash_builder = builder_loading.get('sphinx_dash')(version)
                dash_results = dash_builder.build()
                if dash_results[0] == 0:
                    dash_builder.move()
            else:
                dash_results = fake_results
            if pdf:
                pdf_builder = builder_loading.get('sphinx_pdf')(version)
                latex_results, pdf_results = pdf_builder.build()
                # Always move pdf results even when there's an error.
                #if pdf_results[0] == 0:
                pdf_builder.move()
            else:
                pdf_results = latex_results = fake_results
            if man:
                man_builder = builder_loading.get('sphinx_man')(version)
                man_results = man_builder.build()
                if man_results[0] == 0:
                    man_builder.move()
            else:
                man_results = fake_results
            if epub:
                epub_builder = builder_loading.get('sphinx_epub')(version)
                epub_results = epub_builder.build()
                if epub_results[0] == 0:
                    epub_builder.move()
            else:
                epub_results = fake_results

            if search:
                try:
                    # BETA
                    search_builder = builder_loading.get('sphinx_search')(
                        version)
                    search_results = search_builder.build()
                    if search_results[0] == 0:
                        search_builder.upload()
                except Exception, e:
                    log.error(LOG_TEMPLATE.format(project=project.slug,
                                                  version=version.slug,
                                                  msg=e.message),
                              exc_info=True)
예제 #14
0
def build_docs(version_pk, pdf, man, epub, dash, search, localmedia, record, force):
    """
    This handles the actual building of the documentation and DB records
    """
    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)
    project = version.project

    if 'sphinx' in project.documentation_type and not project.conf_file(version.slug):
        return ('', 'Conf file not found.', -1)

    with project.repo_lock(version, getattr(settings, 'REPO_LOCK_SECONDS', 30)):

        html_builder = builder_loading.get(project.documentation_type)(version)
        if force:
            html_builder.force()
        html_builder.clean()
        html_results = html_builder.build()
        if html_results[0] == 0:
            html_builder.move()

        fake_results = (999, "Project Skipped, Didn't build",
                        "Project Skipped, Didn't build")
        # Only build everything else if the html build changed.
        if html_builder.changed and 'sphinx' in project.documentation_type:
            # Search builder. Creates JSON from docs and sends it to the server.
            if search:
                try:
                    search_builder = builder_loading.get('sphinx_search')(version)
                    search_results = search_builder.build()
                    if search_results[0] == 0:
                        # Update search index
                        search_builder.upload()
                        # Copy json for safe keeping
                        search_builder.move()
                except:
                    log.error(LOG_TEMPLATE.format(project=project.slug, version=version.slug, msg="JSON Build Error"), exc_info=True)
            # Local media builder for singlepage HTML download archive
            if localmedia:
                try:
                    localmedia_builder = builder_loading.get('sphinx_singlehtmllocalmedia')(version)
                    localmedia_results = localmedia_builder.build()
                    if localmedia_results[0] == 0:
                        localmedia_builder.move()
                except:
                    log.error(LOG_TEMPLATE.format(project=project.slug, version=version.slug, msg="Local Media HTML Build Error"), exc_info=True)
                    
            # Optional build steps 
            if version.project.slug not in HTML_ONLY and not project.skip:
                if pdf:
                    pdf_builder = builder_loading.get('sphinx_pdf')(version)
                    latex_results, pdf_results = pdf_builder.build()
                    # Always move pdf results even when there's an error.
                    #if pdf_results[0] == 0:
                    pdf_builder.move()
                else:
                    pdf_results = latex_results = fake_results
                if dash:
                    dash_builder = builder_loading.get('sphinx_dash')(version)
                    dash_results = dash_builder.build()
                    if dash_results[0] == 0:
                        dash_builder.move()
                else:
                    dash_results = fake_results

                if epub:
                    epub_builder = builder_loading.get('sphinx_epub')(version)
                    epub_results = epub_builder.build()
                    if epub_results[0] == 0:
                        epub_builder.move()
                else:
                    epub_results = fake_results
            else:
                search_results = dash_results = latex_results = pdf_results = epub_results = (999, "Optional builds disabled", "Optional builds disabled")
        else:
            search_results = dash_results = latex_results = pdf_results = epub_results = (999, "Optional builds disabled", "Optional builds disabled")


    return (html_results, latex_results, pdf_results,
            epub_results, dash_results, search_results)
예제 #15
0
def build_docs(version, force, pdf, man, epub, dash, search, localmedia):
    """
    This handles the actual building of the documentation
    """

    project = version.project
    results = {}

    if 'sphinx' in project.documentation_type:
        try:
            project.conf_file(version.slug)
        except ProjectImportError:
            results['html'] = (999, 'Conf file not found.', '')
            return results

    with project.repo_nonblockinglock(version=version,
                                      max_lock_age=getattr(settings, 'REPO_LOCK_SECONDS', 30)):
        html_builder = builder_loading.get(project.documentation_type)(version)
        if force:
            html_builder.force()
        # html_builder.clean()
        if 'sphinx' in project.documentation_type:
            html_builder.append_conf()
        results['html'] = html_builder.build()
        if results['html'][0] == 0:
            html_builder.move()

        fake_results = (999, "Project Skipped, Didn't build",
                        "Project Skipped, Didn't build")
        if 'sphinx' in project.documentation_type:
            # Search builder. Creates JSON from docs and sends it to the
            # server.
            if search:
                try:
                    search_builder = builder_loading.get(
                        'sphinx_search')(version)
                    results['search'] = search_builder.build()
                    if results['search'][0] == 0:
                        # Copy json for safe keeping
                        search_builder.move()
                except:
                    log.error(LOG_TEMPLATE.format(
                        project=project.slug, version=version.slug, msg="JSON Build Error"), exc_info=True)
            # Local media builder for singlepage HTML download archive
            if localmedia:
                try:
                    localmedia_builder = builder_loading.get(
                        'sphinx_singlehtmllocalmedia')(version)
                    results['localmedia'] = localmedia_builder.build()
                    if results['localmedia'][0] == 0:
                        localmedia_builder.move()
                except:
                    log.error(LOG_TEMPLATE.format(
                        project=project.slug, version=version.slug, msg="Local Media HTML Build Error"), exc_info=True)

            # Optional build steps
            if version.project.slug not in HTML_ONLY and not project.skip:
                if pdf:
                    pdf_builder = builder_loading.get('sphinx_pdf')(version)
                    results['pdf'] = pdf_builder.build()
                    # Always move pdf results even when there's an error.
                    # if pdf_results[0] == 0:
                    pdf_builder.move()
                else:
                    results['pdf'] = fake_results
                if epub:
                    epub_builder = builder_loading.get('sphinx_epub')(version)
                    results['epub'] = epub_builder.build()
                    if results['epub'][0] == 0:
                        epub_builder.move()
                else:
                    results['epub'] = fake_results
    return results
예제 #16
0
def build_docs(version_pk, pdf, man, epub, dash, search, localmedia, record,
               force):
    """
    This handles the actual building of the documentation and DB records
    """
    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)
    project = version.project

    if 'sphinx' in project.documentation_type and not project.conf_file(
            version.slug):
        return ('', 'Conf file not found.', -1)

    with project.repo_lock(version, getattr(settings, 'REPO_LOCK_SECONDS',
                                            30)):

        html_builder = builder_loading.get(project.documentation_type)(version)
        if force:
            html_builder.force()
        html_builder.clean()
        html_results = html_builder.build()
        if html_results[0] == 0:
            html_builder.move()

        fake_results = (999, "Project Skipped, Didn't build",
                        "Project Skipped, Didn't build")
        # Only build everything else if the html build changed.
        if html_builder.changed and 'sphinx' in project.documentation_type:
            # Search builder. Creates JSON from docs and sends it to the server.
            if search:
                try:
                    search_builder = builder_loading.get('sphinx_search')(
                        version)
                    search_results = search_builder.build()
                    if search_results[0] == 0:
                        # Update search index
                        search_builder.upload()
                        # Copy json for safe keeping
                        search_builder.move()
                except:
                    log.error(LOG_TEMPLATE.format(project=project.slug,
                                                  version=version.slug,
                                                  msg="JSON Build Error"),
                              exc_info=True)
            # Local media builder for singlepage HTML download archive
            if localmedia:
                try:
                    localmedia_builder = builder_loading.get(
                        'sphinx_singlehtmllocalmedia')(version)
                    localmedia_results = localmedia_builder.build()
                    if localmedia_results[0] == 0:
                        localmedia_builder.move()
                except:
                    log.error(LOG_TEMPLATE.format(
                        project=project.slug,
                        version=version.slug,
                        msg="Local Media HTML Build Error"),
                              exc_info=True)

            # Optional build steps
            if version.project.slug not in HTML_ONLY and not project.skip:
                if pdf:
                    pdf_builder = builder_loading.get('sphinx_pdf')(version)
                    latex_results, pdf_results = pdf_builder.build()
                    # Always move pdf results even when there's an error.
                    #if pdf_results[0] == 0:
                    pdf_builder.move()
                else:
                    pdf_results = latex_results = fake_results
                if dash:
                    dash_builder = builder_loading.get('sphinx_dash')(version)
                    dash_results = dash_builder.build()
                    if dash_results[0] == 0:
                        dash_builder.move()
                else:
                    dash_results = fake_results

                if epub:
                    epub_builder = builder_loading.get('sphinx_epub')(version)
                    epub_results = epub_builder.build()
                    if epub_results[0] == 0:
                        epub_builder.move()
                else:
                    epub_results = fake_results
            else:
                search_results = dash_results = latex_results = pdf_results = epub_results = (
                    999, "Optional builds disabled",
                    "Optional builds disabled")
        else:
            search_results = dash_results = latex_results = pdf_results = epub_results = (
                999, "Optional builds disabled", "Optional builds disabled")

    return (html_results, latex_results, pdf_results, epub_results,
            dash_results, search_results)
예제 #17
0
def build_docs(version_pk, pdf, man, epub, dash, search, record, force):
    """
    This handles the actual building of the documentation and DB records
    """
    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)
    project = version.project

    if not project.conf_file(version.slug):
        return ('', 'Conf file not found.', -1)

    with project.repo_lock(getattr(settings, 'REPO_LOCK_SECONDS', 30)):

        html_builder = builder_loading.get(project.documentation_type)(version)
        if force:
            html_builder.force()
        html_builder.clean()
        html_results = html_builder.build()
        if html_results[0] == 0:
            html_builder.move()

        fake_results = (999, "Project Skipped, Didn't build",
                        "Project Skipped, Didn't build")
        # Only build everything else if the html build changed.
        if html_builder.changed and not project.skip:
            if dash:
                dash_builder = builder_loading.get('sphinx_dash')(version)
                dash_results = dash_builder.build()
                if dash_results[0] == 0:
                    dash_builder.move()
            else:
                dash_results = fake_results
            if pdf:
                pdf_builder = builder_loading.get('sphinx_pdf')(version)
                latex_results, pdf_results = pdf_builder.build()
                # Always move pdf results even when there's an error.
                #if pdf_results[0] == 0:
                pdf_builder.move()
            else:
                pdf_results = latex_results = fake_results
            if man:
                man_builder = builder_loading.get('sphinx_man')(version)
                man_results = man_builder.build()
                if man_results[0] == 0:
                    man_builder.move()
            else:
                man_results = fake_results
            if epub:
                epub_builder = builder_loading.get('sphinx_epub')(version)
                epub_results = epub_builder.build()
                if epub_results[0] == 0:
                    epub_builder.move()
            else:
                epub_results = fake_results

            if search:
                try:
                    # BETA
                    search_builder = builder_loading.get('sphinx_search')(version)
                    search_results = search_builder.build()
                    if search_results[0] == 0:
                        search_builder.upload()
                except Exception, e:
                    log.error(LOG_TEMPLATE.format(project=project.slug, version=version.slug, msg=e.message), exc_info=True)
예제 #18
0
         data = update_output.get(key, None)
         if data:
             output_data += data[1]
             error_data += data[2]
     # Update build.
     build["success"] = successful
     build["setup"] = output_data
     build["setup_error"] = error_data
     build["output"] = html_output[1]
     build["error"] = html_output[2]
     build["state"] = "finished"
     build["project"] = "/api/v1/project/%s/" % project.pk
     build["version"] = "/api/v1/version/%s/" % version.pk
     api.build(build["id"]).put(build)
 if pdf:
     pdf_builder = builder_loading.get("sphinx_pdf")(version)
     latex_results, pdf_results = pdf_builder.build()
     if record:
         api.build.post(
             dict(
                 project="/api/v1/project/%s/" % project.pk,
                 version="/api/v1/version/%s/" % version.pk,
                 success=pdf_results[0] == 0,
                 type="pdf",
                 setup=latex_results[1],
                 setup_error=latex_results[2],
                 output=pdf_results[1],
                 error=pdf_results[2],
             )
         )
     # PDF Builder is oddly 2-steped, and stateful for now
예제 #19
0
         data = update_output.get(key, None)
         if data:
             output_data += data[1]
             error_data += data[2]
     #Update build.
     build['success'] = successful
     build['setup'] = output_data
     build['setup_error'] = error_data
     build['output'] = html_output[1]
     build['error'] = html_output[2]
     build['state'] = 'finished'
     build['project'] = '/api/v1/project/%s/' % project.pk
     build['version'] = '/api/v1/version/%s/' % version.pk
     api.build(build['id']).put(build)
 if pdf:
     pdf_builder = builder_loading.get('sphinx_pdf')(version)
     latex_results, pdf_results = pdf_builder.build()
     if record:
         api.build.post(dict(
             project = '/api/v1/project/%s/' % project.pk,
             version = '/api/v1/version/%s/' % version.pk,
             success=pdf_results[0] == 0,
             type='pdf',
             setup=latex_results[1],
             setup_error=latex_results[2],
             output=pdf_results[1],
             error=pdf_results[2],
         ))
     #PDF Builder is oddly 2-steped, and stateful for now
     #pdf_builder.move(version)
 #XXX:dc: all builds should have their output checked
예제 #20
0
def build_docs(version_pk, pdf, man, epub, dash, search, record, force):
    """
    This handles the actual building of the documentation and DB records
    """
    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)
    project = version.project

    if not project.conf_file(version.slug):
        return ("", "Conf file not found.", -1)

    with project.repo_lock(getattr(settings, "REPO_LOCK_SECONDS", 30)):

        html_builder = builder_loading.get(project.documentation_type)(version)
        if force:
            html_builder.force()
        html_builder.clean()
        html_results = html_builder.build()
        if html_results[0] == 0:
            html_builder.move()

        fake_results = (999, "Project Skipped, Didn't build", "Project Skipped, Didn't build")
        # Only build everything else if the html build changed.
        if html_builder.changed and not project.skip:
            if search:
                try:
                    search_builder = builder_loading.get("sphinx_search")(version)
                    search_results = search_builder.build()
                    if search_results[0] == 0:
                        # Update search index
                        search_builder.upload()
                        # Copy json for safe keeping
                        search_builder.move()
                except:
                    log.error(
                        LOG_TEMPLATE.format(project=project.slug, version=version.slug, msg="JSON Build Error"),
                        exc_info=True,
                    )
            if dash:
                dash_builder = builder_loading.get("sphinx_dash")(version)
                dash_results = dash_builder.build()
                if dash_results[0] == 0:
                    dash_builder.move()
            else:
                dash_results = fake_results

            if version.project.slug not in HTML_ONLY:
                if pdf:
                    pdf_builder = builder_loading.get("sphinx_pdf")(version)
                    latex_results, pdf_results = pdf_builder.build()
                    # Always move pdf results even when there's an error.
                    # if pdf_results[0] == 0:
                    pdf_builder.move()
                else:
                    pdf_results = latex_results = fake_results
                if man:
                    man_builder = builder_loading.get("sphinx_man")(version)
                    man_results = man_builder.build()
                    if man_results[0] == 0:
                        man_builder.move()
                else:
                    man_results = fake_results
                if epub:
                    epub_builder = builder_loading.get("sphinx_epub")(version)
                    epub_results = epub_builder.build()
                    if epub_results[0] == 0:
                        epub_builder.move()
                else:
                    epub_results = fake_results
            else:
                latex_results = pdf_results = man_results = epub_results = (
                    999,
                    "Optional builds disabled",
                    "Optional builds disabled",
                )

    return (html_results, latex_results, pdf_results, man_results, epub_results, dash_results, search_results)