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


Python api.version函数代码示例

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


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

示例1: build_docs

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)
开发者ID:Nagyman,项目名称:readthedocs.org,代码行数:25,代码来源:tasks.py

示例2: ensure_version

def ensure_version(api, project, version_pk):
    """
    Ensure we're using a sane version.
    """

    if version_pk:
        version_data = api.version(version_pk).get()
    else:
        version_data = api.version(project.slug).get(slug=LATEST)['objects'][0]
    version = make_api_version(version_data)
    return version
开发者ID:agjohnson,项目名称:readthedocs.org,代码行数:11,代码来源:tasks.py

示例3: ensure_version

def ensure_version(api, project, version_pk):
    """
    Ensure we're using a sane version.
    This also creates the "latest" version if it doesn't exist.
    """

    if version_pk:
        version_data = api.version(version_pk).get()
    else:
        branch = project.default_branch or project.vcs_repo().fallback_branch
        try:
            # Use latest version
            version_data = (api.version(project.slug)
                            .get(slug='latest')['objects'][0])
        except (slumber.exceptions.HttpClientError, IndexError):
            # Create the latest version since it doesn't exist
            version_data = dict(
                project='/api/v1/project/%s/' % project.pk,
                slug='latest',
                type='branch',
                active=True,
                verbose_name='latest',
                identifier=branch,
            )
            try:
                version_data = api.version.post(version_data)
            except Exception as e:
                log.info(LOG_TEMPLATE.format(
                    project=project.slug, version='', msg='Exception in creating version: %s' % e))
                raise e

    version = make_api_version(version_data)

    if not version_pk:
        # Lots of course correction.
        to_save = False
        if not version.verbose_name:
            version_data['verbose_name'] = 'latest'
            to_save = True
        if not version.active:
            version_data['active'] = True
            to_save = True
        if version.identifier != branch:
            version_data['identifier'] = branch
            to_save = True
        if to_save:
            version_data['project'] = ("/api/v1/project/%s/"
                                       % version_data['project'].pk)
            api.version(version.pk).put(version_data)

    return version
开发者ID:PeterSchregle,项目名称:readthedocs.org,代码行数:51,代码来源:tasks.py

示例4: ensure_version

def ensure_version(api, project, version_pk):
    """
    Ensure we're using a sane version.
    This also creates the "latest" version if it doesn't exist.
    """

    if version_pk:
        version_data = api.version(version_pk).get()
    else:
        branch = project.default_branch or project.vcs_repo().fallback_branch
        try:
            # Use latest version
            version_data = api.version(project.slug).get(slug="latest")["objects"][0]
        except (slumber.exceptions.HttpClientError, IndexError):
            # Create the latest version since it doesn't exist
            version_data = dict(
                project="/api/v1/project/%s/" % project.pk,
                slug="latest",
                type="branch",
                active=True,
                verbose_name="latest",
                identifier=branch,
            )
            try:
                version_data = api.version.post(version_data)
            except Exception as e:
                log.info(
                    LOG_TEMPLATE.format(project=project.slug, version="", msg="Exception in creating version: %s" % e)
                )
                raise e

    version = make_api_version(version_data)

    if not version_pk:
        # Lots of course correction.
        to_save = False
        if not version.verbose_name:
            version_data["verbose_name"] = "latest"
            to_save = True
        if not version.active:
            version_data["active"] = True
            to_save = True
        if version.identifier != branch:
            version_data["identifier"] = branch
            to_save = True
        if to_save:
            version_data["project"] = "/api/v1/version/%s/" % version_data["project"].pk
            api.version(version.pk).put(version_data)

    return version
开发者ID:WojtekK1902,项目名称:readthedocs.org,代码行数:50,代码来源:tasks.py

示例5: handle

 def handle(self, *args, **options):
     if len(args):
         for slug in args:
             version_data = api.version(slug).get(slug="latest")['objects'][0]
             version = tasks.make_api_version(version_data)
             log.info("Building %s" % version)
             tasks.docker_build(version_pk=version.pk)
开发者ID:0day1day,项目名称:readthedocs.org,代码行数:7,代码来源:run_docker.py

示例6: fileify

def fileify(version_pk):
    """
    Create ImportedFile objects for all of a version's files.

    This is a prereq for indexing the docs for search.
    It also causes celery-haystack to kick off an index of the file.
    """
    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)
    project = version.project
    path = project.rtd_build_path(version.slug)
    log.info("Indexing files for %s" % project)
    if path:
        for root, dirnames, filenames in os.walk(path):
            for filename in filenames:
                if fnmatch.fnmatch(filename, "*.html"):
                    dirpath = os.path.join(root.replace(path, "").lstrip("/"), filename.lstrip("/"))
                    if getattr(settings, "DONT_HIT_DB", True):
                        api.file.post(
                            dict(
                                project="/api/v1/project/%s/" % project.pk,
                                version="/api/v1/version/%s/" % version.pk,
                                path=dirpath,
                                name=filename,
                            )
                        )
                    else:
                        ImportedFile.objects.get_or_create(
                            project=project, version=version, path=dirpath, name=filename
                        )
开发者ID:billthornton,项目名称:readthedocs.org,代码行数:30,代码来源:tasks.py

示例7: docker_build

def docker_build(version_pk, pdf=True, man=True, epub=True, dash=True, search=True, force=False, intersphinx=True, localmedia=True):
    """
    The code that executes inside of docker
    """
    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)

    environment_results = setup_environment(version)
    results = build_docs(version=version, force=force, pdf=pdf, man=man,
                         epub=epub, dash=dash, search=search, localmedia=localmedia)
    results.update(environment_results)
    try:
        number = uuid.uuid4()
        path = os.path.join(version.project.doc_path, 'build.json')
        fh = open(path, 'w')
        json.dump(results, fh)
        fh.close()
    except IOError as e:
        log.debug(LOG_TEMPLATE.format(
            project=version.project.slug,
            version='',
            msg='Cannot write to build.json: {0}'.format(e)
        ))
        return None
    return number
开发者ID:PeterSchregle,项目名称:readthedocs.org,代码行数:25,代码来源:tasks.py

示例8: update_config_from_json

def update_config_from_json(version_pk):
    """
    Check out or update the given project's repository.
    """
    # Remove circular import
    from projects.forms import ImportProjectForm
    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)
    project = version.project
    log.debug(LOG_TEMPLATE.format(project=project.slug, version=version.slug, msg="Checking for json config"))
    try:
        rtd_json = open(os.path.join(
            project.checkout_path(version.slug),
            '.rtd.json'
        ))
        json_obj = json.load(rtd_json)
        for key in json_obj.keys():
            # Treat the defined fields on the Import form as 
            # the canonical list of allowed user editable fields.
            # This is in essense just another UI for that form.
            if key not in ImportProjectForm._meta.fields:
                del json_obj[key]
    except IOError:
        log.debug(LOG_TEMPLATE.format(project=project.slug, version=version.slug, msg="No rtd.json found."))
        return None

    project_data = api.project(project.pk).get()
    project_data.update(json_obj)
    api.project(project.pk).put(project_data)
    log.debug(LOG_TEMPLATE.format(project=project.slug, version=version.slug, msg="Updated from JSON."))
开发者ID:awesome,项目名称:readthedocs.org,代码行数:30,代码来源:tasks.py

示例9: update_imported_docs

def update_imported_docs(version_pk, api=None):
    """
    Check out or update the given project's repository.
    """
    if api is None:
        api = tastyapi.api

    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)
    project = version.project
    ret_dict = {}

    # Make Dirs
    if not os.path.exists(project.doc_path):
        os.makedirs(project.doc_path)

    with project.repo_nonblockinglock(version=version, max_lock_age=getattr(settings, "REPO_LOCK_SECONDS", 30)):
        if not project.vcs_repo():
            raise ProjectImportError(("Repo type '{0}' unknown".format(project.repo_type)))

        # Get the actual code on disk
        if version:
            log.info(
                LOG_TEMPLATE.format(
                    project=project.slug,
                    version=version.slug,
                    msg="Checking out version {slug}: {identifier}".format(
                        slug=version.slug, identifier=version.identifier
                    ),
                )
            )
            version_slug = version.slug
            version_repo = project.vcs_repo(version_slug)
            ret_dict["checkout"] = version_repo.checkout(version.identifier)
        else:
            # Does this ever get called?
            log.info(LOG_TEMPLATE.format(project=project.slug, version=version.slug, msg="Updating to latest revision"))
            version_slug = "latest"
            version_repo = project.vcs_repo(version_slug)
            ret_dict["checkout"] = version_repo.update()

        # Update tags/version

        version_post_data = {"repo": version_repo.repo_url}

        if version_repo.supports_tags:
            version_post_data["tags"] = [
                {"identifier": v.identifier, "verbose_name": v.verbose_name} for v in version_repo.tags
            ]

        if version_repo.supports_branches:
            version_post_data["branches"] = [
                {"identifier": v.identifier, "verbose_name": v.verbose_name} for v in version_repo.branches
            ]

        try:
            apiv2.project(project.pk).sync_versions.post(version_post_data)
        except Exception, e:
            print "Sync Verisons Exception: %s" % e.message
开发者ID:WojtekK1902,项目名称:readthedocs.org,代码行数:59,代码来源:tasks.py

示例10: build_docs

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)
开发者ID:RandomStuffs22,项目名称:readthedocs.org,代码行数:59,代码来源:tasks.py

示例11: clear_artifacts

def clear_artifacts(version_pk):
    """ Remove artifacts from the build server. """
    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)
    run('rm -rf %s' % version.project.full_epub_path(version.slug))
    run('rm -rf %s' % version.project.full_man_path(version.slug))
    run('rm -rf %s' % version.project.full_build_path(version.slug))
    run('rm -rf %s' % version.project.full_latex_path(version.slug))
开发者ID:ctb,项目名称:readthedocs.org,代码行数:8,代码来源:tasks.py

示例12: update_intersphinx

def update_intersphinx(version_pk):
    version_data = api.version(version_pk).get()
    version = make_api_version(version_data)
    project = version.project

    try:
        object_file = version.project.find("objects.inv", version.slug)[0]
    except IndexError, e:
        print "Failed to find objects file"
        return None
开发者ID:billthornton,项目名称:readthedocs.org,代码行数:10,代码来源:tasks.py

示例13: symlink

def symlink(project, version="latest"):
    from projects import tasks
    from builds.models import Version
    from tastyapi import api

    if getattr(settings, "DONT_HIT_DB", True):
        version_data = api.version().get(project=project, slug=version)["results"][0]
        v = tasks.make_api_version(version_data)
    else:
        v = Version.objects.get(project__slug=project, slug=version)
    log.info("Symlinking %s" % v)
    tasks.symlink_subprojects(v)
    tasks.symlink_cnames(v)
    tasks.symlink_translations(v)
开发者ID:k-okada,项目名称:readthedocs.org,代码行数:14,代码来源:utils.py

示例14: update_intersphinx

def update_intersphinx(version_pk):
    version_data = api.version(version_pk).get()
    del version_data['resource_uri']
    project_data = version_data['project']
    del project_data['users']
    del project_data['resource_uri']
    del project_data['absolute_url']
    project = Project(**project_data)
    version_data['project'] = project
    version = Version(**version_data)

    try:
        object_file = version.project.find('objects.inv', version.slug)[0]
    except IndexError, e:
        print "Failed to find objects file"
        return None
开发者ID:dangra,项目名称:readthedocs.org,代码行数:16,代码来源:tasks.py

示例15: update_intersphinx

def update_intersphinx(version_pk):
    version_data = api.version(version_pk).get()
    del version_data["resource_uri"]
    project_data = version_data["project"]
    del project_data["users"]
    del project_data["resource_uri"]
    del project_data["absolute_url"]
    project = Project(**project_data)
    version_data["project"] = project
    version = Version(**version_data)

    object_file = version.project.find("objects.inv", version.slug)[0]
    path = version.project.rtd_build_path(version.slug)
    if not path:
        print "ERR: %s has no path" % version
        return None
    app = DictObj()
    app.srcdir = path
    try:
        inv = fetch_inventory(app, path, object_file)
    except TypeError:
        print "Failed to fetch inventory for %s" % version
        return None
    # I'm entirelty not sure this is even close to correct.
    # There's a lot of info I'm throwing away here; revisit later?
    for keytype in inv:
        for term in inv[keytype]:
            try:
                _, _, url, title = inv[keytype][term]
                if not title or title == "-":
                    if "#" in url:
                        title = url.rsplit("#")[-1]
                    else:
                        title = url
                find_str = "rtd-builds/latest"
                latest = url.find(find_str)
                url = url[latest + len(find_str) + 1 :]
                url = "http://%s.readthedocs.org/en/latest/%s" % (version.project.slug, url)
                save_term(version, term, url, title)
                if "." in term:
                    save_term(version, term.split(".")[-1], url, title)
            except Exception, e:  # Yes, I'm an evil person.
                print "*** Failed updating %s: %s" % (term, e)
开发者ID:rmaceissoft,项目名称:readthedocs.org,代码行数:43,代码来源:tasks.py


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