def update_docs(pk, version_pk=None, build_pk=None, record=True, docker=False, pdf=True, man=True, epub=True, dash=True, search=True, force=False, intersphinx=True, localmedia=True, api=None, **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. """ # Dependency injection to allow for testing if api is None: api = tastyapi.api project_data = api.project(pk).get() project = make_api_project(project_data) log.info(LOG_TEMPLATE.format(project=project.slug, version='', msg='Building')) version = ensure_version(api, project, version_pk) build = create_build(build_pk) results = {} # Build Servery stuff try: record_build(api=api, build=build, record=record, results=results, state='cloning') vcs_results = setup_vcs(version, build, api) if vcs_results: results.update(vcs_results) if docker or settings.DOCKER_ENABLE: record_build(api=api, build=build, record=record, results=results, state='building') docker = DockerEnvironment(version) build_results = docker.build() results.update(build_results) else: record_build(api=api, build=build, record=record, results=results, state='installing') setup_results = setup_environment(version) results.update(setup_results) record_build(api=api, build=build, record=record, results=results, state='building') build_results = build_docs(version, force, pdf, man, epub, dash, 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)
def update_docs(pk, version_pk=None, build_pk=None, record=True, docker=False, pdf=True, man=True, epub=True, dash=True, search=True, force=False, intersphinx=True, localmedia=True, api=None, 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. """ # Dependency injection to allow for testing if api is None: api = tastyapi.api apiv2 = tastyapi.apiv2 else: apiv2 = api start_time = datetime.datetime.utcnow() try: project_data = api.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(api, project, version_pk) build = create_build(build_pk) results = {} # Build Servery stuff try: record_build(api=api, build=build, record=record, results=results, state='cloning') vcs_results = setup_vcs(version, build, api) if vcs_results: results.update(vcs_results) if project.documentation_type == 'auto': update_documentation_type(version, apiv2) if docker or settings.DOCKER_ENABLE: record_build(api=api, build=build, record=record, results=results, state='building') docker = DockerEnvironment(version) build_results = docker.build() results.update(build_results) else: record_build(api=api, build=build, record=record, results=results, state='installing') setup_results = setup_environment(version) results.update(setup_results) record_build(api=api, build=build, record=record, results=results, state='building') build_results = build_docs(version, force, pdf, man, epub, dash, 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)
def test_container_id(self): '''Test docker build command''' docker = DockerEnvironment(self.version) self.assertEqual(docker.container_id(), 'version-foobar-of-pip-20')
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)