def symlink(slug): version_data = api.version().get(project=slug, slug='latest')['results'][0] v = tasks.make_api_version(version_data) log.info("Symlinking %s" % v) tasks.symlink_subprojects(v) tasks.symlink_cnames(v) tasks.symlink_translations(v)
def append_conf(self, **kwargs): """Modify the given ``conf.py`` file from a whitelisted user's project. """ # Pull config data try: conf_py_path = version_utils.get_conf_py_path(self.version) except ProjectImportError: self._write_config() self.create_index(extension='rst') project = self.version.project # Open file for appending. outfile = codecs.open(project.conf_file(self.version.slug), encoding='utf-8', mode='a') outfile.write("\n") conf_py_path = version_utils.get_conf_py_path(self.version) remote_version = version_utils.get_vcs_version_slug(self.version) github_info = version_utils.get_github_username_repo(self.version) bitbucket_info = version_utils.get_bitbucket_username_repo(self.version) if github_info[0] is None: display_github = False else: display_github = True if bitbucket_info[0] is None: display_bitbucket = False else: display_bitbucket = True rtd_ctx = Context({ 'current_version': self.version.slug, 'project': project, 'settings': settings, 'static_path': STATIC_DIR, 'template_path': TEMPLATE_DIR, 'conf_py_path': conf_py_path, 'api_host': getattr(settings, 'SLUMBER_API_HOST', 'https://readthedocs.org'), # GitHub 'github_user': github_info[0], 'github_repo': github_info[1], 'github_version': remote_version, 'display_github': display_github, # BitBucket 'bitbucket_user': bitbucket_info[0], 'bitbucket_repo': bitbucket_info[1], 'bitbucket_version': remote_version, 'display_bitbucket': display_bitbucket, 'commit': self.version.project.vcs_repo(self.version.slug).commit, }) # Avoid hitting database and API if using Docker build environment if getattr(settings, 'DONT_HIT_API', False): rtd_ctx['versions'] = project.active_versions() rtd_ctx['downloads'] = self.version.get_downloads(pretty=True) else: rtd_ctx['versions'] = project.api_versions() rtd_ctx['downloads'] = (apiv2.version(self.version.pk) .downloads.get()['downloads']) rtd_string = template_loader.get_template('doc_builder/conf.py.tmpl').render(rtd_ctx) outfile.write(rtd_string)
def _whitelisted(self, **kwargs): """Modify the given ``conf.py`` file from a whitelisted user's project. """ project = self.version.project #Open file for appending. outfile = codecs.open(project.conf_file(self.version.slug), encoding='utf-8', mode='a') outfile.write("\n") conf_py_path = _get_conf_py_path(self.version) github_info = _get_github_username_repo(self.version) github_version = _get_github_version(self.version) if github_info[0] is None: display_github = False else: display_github = True rtd_ctx = Context({ 'versions': project.api_versions(), 'downloads': self.version.get_downloads(pretty=True), 'current_version': self.version.slug, 'project': project, 'settings': settings, 'static_path': STATIC_DIR, 'template_path': TEMPLATE_DIR, 'conf_py_path': conf_py_path, 'github_user': github_info[0], 'github_repo': github_info[1], 'github_version': github_version, 'display_github': display_github, 'downloads': apiv2.version(self.version.pk).downloads.get()['downloads'], }) rtd_string = Template(RTD_CONF_ADDITIONS).render(rtd_ctx) outfile.write(rtd_string)
def handle(self, *args, **options): if len(args): for slug in args: version_data = api.version().get(project=slug, slug='latest')['results'][0] v = tasks.make_api_version(version_data) log.info("Symlinking %s" % v) tasks.symlink_subprojects(v) tasks.symlink_cnames(v) tasks.symlink_translations(v)
def version_from_slug(slug, version): from projects import tasks from builds.models import Version from tastyapi import apiv2 as api if getattr(settings, 'DONT_HIT_DB', True): version_data = api.version().get(project=slug, slug=version)['results'][0] v = tasks.make_api_version(version_data) else: v = Version.objects.get(project__slug=slug, slug=version) return v
def append_conf(self, **kwargs): """Modify the given ``conf.py`` file from a whitelisted user's project. """ project = self.version.project #Open file for appending. outfile = codecs.open(project.conf_file(self.version.slug), encoding='utf-8', mode='a') outfile.write("\n") conf_py_path = version_utils.get_conf_py_path(self.version) remote_version = version_utils.get_vcs_version_slug(self.version) gitlab_info = version_utils.get_gitlab_username_repo(self.version) github_info = version_utils.get_github_username_repo(self.version) bitbucket_info = version_utils.get_bitbucket_username_repo(self.version) if gitlab_info[0] is None: display_gitlab = False else: display_gitlab = True if github_info[0] is None: display_github = False else: display_github = True if bitbucket_info[0] is None: display_bitbucket = False else: display_bitbucket = True rtd_ctx = Context({ 'versions': project.api_versions(), 'downloads': self.version.get_downloads(pretty=True), 'current_version': self.version.slug, 'project': project, 'settings': settings, 'static_path': STATIC_DIR, 'template_path': TEMPLATE_DIR, 'conf_py_path': conf_py_path, 'downloads': apiv2.version(self.version.pk).downloads.get()['downloads'], 'api_host': getattr(settings, 'SLUMBER_API_HOST', 'https://readthedocs.org'), # GitLab 'gitlab_user': gitlab_info[0], 'gitlab_repo': gitlab_info[1], 'gitlab_version': remote_version, 'display_gitlab': display_gitlab, # GitHub 'github_user': github_info[0], 'github_repo': github_info[1], 'github_version': remote_version, 'display_github': display_github, # BitBucket 'bitbucket_user': bitbucket_info[0], 'bitbucket_repo': bitbucket_info[1], 'bitbucket_version': remote_version, 'display_bitbucket': display_bitbucket, }) rtd_string = template_loader.get_template('doc_builder/conf.py.tmpl').render(rtd_ctx) outfile.write(rtd_string)
def symlink(project, version='latest'): from projects import tasks from builds.models import Version from tastyapi import apiv2 as 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)
def append_conf(self, **kwargs): """Modify the given ``conf.py`` file from a whitelisted user's project. """ project = self.version.project # Open file for appending. outfile = codecs.open(project.conf_file(self.version.slug), encoding="utf-8", mode="a") outfile.write("\n") conf_py_path = version_utils.get_conf_py_path(self.version) remote_version = version_utils.get_vcs_version_slug(self.version) github_info = version_utils.get_github_username_repo(self.version) bitbucket_info = version_utils.get_bitbucket_username_repo(self.version) if github_info[0] is None: display_github = False else: display_github = True if bitbucket_info[0] is None: display_bitbucket = False else: display_bitbucket = True rtd_ctx = Context( { "versions": project.api_versions(), "downloads": self.version.get_downloads(pretty=True), "current_version": self.version.slug, "project": project, "settings": settings, "static_path": STATIC_DIR, "template_path": TEMPLATE_DIR, "conf_py_path": conf_py_path, "downloads": apiv2.version(self.version.pk).downloads.get()["downloads"], "api_host": getattr(settings, "SLUMBER_API_HOST", "https://readthedocs.org"), # GitHub "github_user": github_info[0], "github_repo": github_info[1], "github_version": remote_version, "display_github": display_github, # BitBucket "bitbucket_user": bitbucket_info[0], "bitbucket_repo": bitbucket_info[1], "bitbucket_version": remote_version, "display_bitbucket": display_bitbucket, "commit": self.version.project.vcs_repo(self.version.slug).commit, } ) rtd_string = template_loader.get_template("doc_builder/conf.py.tmpl").render(rtd_ctx) outfile.write(rtd_string)
def append_conf(self, **kwargs): """Modify the given ``conf.py`` file from a whitelisted user's project. """ project = self.version.project # Open file for appending. outfile = codecs.open(project.conf_file(self.version.slug), encoding='utf-8', mode='a') outfile.write("\n") conf_py_path = version_utils.get_conf_py_path(self.version) remote_version = version_utils.get_vcs_version_slug(self.version) github_info = version_utils.get_github_username_repo(self.version) bitbucket_info = version_utils.get_bitbucket_username_repo(self.version) if github_info[0] is None: display_github = False else: display_github = True if bitbucket_info[0] is None: display_bitbucket = False else: display_bitbucket = True rtd_ctx = Context({ 'versions': project.api_versions(), 'downloads': self.version.get_downloads(pretty=True), 'current_version': self.version.slug, 'project': project, 'settings': settings, 'static_path': STATIC_DIR, 'template_path': TEMPLATE_DIR, 'conf_py_path': conf_py_path, 'downloads': apiv2.version(self.version.pk).downloads.get()['downloads'], 'api_host': getattr(settings, 'SLUMBER_API_HOST', 'https://readthedocs.org'), # GitHub 'github_user': github_info[0], 'github_repo': github_info[1], 'github_version': remote_version, 'display_github': display_github, # BitBucket 'bitbucket_user': bitbucket_info[0], 'bitbucket_repo': bitbucket_info[1], 'bitbucket_version': remote_version, 'display_bitbucket': display_bitbucket, 'commit': self.version.project.vcs_repo(self.version.slug).commit, }) rtd_string = template_loader.get_template('doc_builder/conf.py.tmpl').render(rtd_ctx) outfile.write(rtd_string)
def _whitelisted(self, **kwargs): """Modify the given ``conf.py`` file from a whitelisted user's project. """ project = self.version.project # Open file for appending. outfile = codecs.open(project.conf_file(self.version.slug), encoding="utf-8", mode="a") outfile.write("\n") conf_py_path = version_utils.get_conf_py_path(self.version) remote_version = version_utils.get_vcs_version(self.version) github_info = version_utils.get_github_username_repo(self.version) bitbucket_info = version_utils.get_bitbucket_username_repo(self.version) if github_info[0] is None: display_github = False else: display_github = True if bitbucket_info[0] is None: display_bitbucket = False else: display_bitbucket = True rtd_ctx = Context( { "versions": project.api_versions(), "downloads": self.version.get_downloads(pretty=True), "current_version": self.version.slug, "project": project, "settings": settings, "static_path": STATIC_DIR, "template_path": TEMPLATE_DIR, "conf_py_path": conf_py_path, "downloads": apiv2.version(self.version.pk).downloads.get()["downloads"], # GitHub "github_user": github_info[0], "github_repo": github_info[1], "github_version": remote_version, "display_github": display_github, # BitBucket "bitbucket_user": bitbucket_info[0], "bitbucket_repo": bitbucket_info[1], "bitbucket_version": remote_version, "display_bitbucket": display_bitbucket, } ) rtd_string = Template(RTD_CONF_ADDITIONS).render(rtd_ctx) outfile.write(rtd_string)
def append_conf(self, **kwargs): """Modify the given ``conf.py`` file from a whitelisted user's project. """ # Pull config data try: conf_py_path = version_utils.get_conf_py_path(self.version) except ProjectImportError: self._write_config() self.create_index(extension='rst') project = self.version.project # Open file for appending. try: outfile = codecs.open(project.conf_file(self.version.slug), encoding='utf-8', mode='a') except IOError: trace = sys.exc_info()[2] raise ProjectImportError('Conf file not found'), None, trace outfile.write("\n") conf_py_path = version_utils.get_conf_py_path(self.version) remote_version = version_utils.get_vcs_version_slug(self.version) github_info = version_utils.get_github_username_repo(self.version) bitbucket_info = version_utils.get_bitbucket_username_repo( self.version) if github_info[0] is None: display_github = False else: display_github = True if bitbucket_info[0] is None: display_bitbucket = False else: display_bitbucket = True rtd_ctx = Context({ 'current_version': self.version.slug, 'project': project, 'settings': settings, 'static_path': STATIC_DIR, 'template_path': TEMPLATE_DIR, 'conf_py_path': conf_py_path, 'api_host': getattr(settings, 'SLUMBER_API_HOST', 'https://readthedocs.org'), # GitHub 'github_user': github_info[0], 'github_repo': github_info[1], 'github_version': remote_version, 'display_github': display_github, # BitBucket 'bitbucket_user': bitbucket_info[0], 'bitbucket_repo': bitbucket_info[1], 'bitbucket_version': remote_version, 'display_bitbucket': display_bitbucket, 'commit': self.version.project.vcs_repo(self.version.slug).commit, }) # Avoid hitting database and API if using Docker build environment if getattr(settings, 'DONT_HIT_API', False): rtd_ctx['versions'] = project.active_versions() rtd_ctx['downloads'] = self.version.get_downloads(pretty=True) else: rtd_ctx['versions'] = project.api_versions() rtd_ctx['downloads'] = (apiv2.version( self.version.pk).get()['downloads']) rtd_string = template_loader.get_template( 'doc_builder/conf.py.tmpl').render(rtd_ctx) outfile.write(rtd_string)
def append_conf(self, **kwargs): """Modify the given ``conf.py`` file from a whitelisted user's project. """ # Pull config data try: conf_py_path = self.version.get_conf_py_path() except ProjectImportError: self._write_config() self.create_index(extension='rst') project = self.version.project # Open file for appending. try: outfile = codecs.open(project.conf_file(self.version.slug), encoding='utf-8', mode='a') except IOError: trace = sys.exc_info()[2] raise ProjectImportError('Conf file not found'), None, trace outfile.write("\n") conf_py_path = self.version.get_conf_py_path() remote_version = self.version.get_vcs_slug() github_user, github_repo = version_utils.get_github_username_repo(url=self.version.project.repo) github_version_is_editable = (self.version.type == 'branch') display_github = github_user is not None bitbucket_user, bitbucket_repo = version_utils.get_bitbucket_username_repo(url=self.version.project.repo) bitbucket_version_is_editable = (self.version.type == 'branch') display_bitbucket = bitbucket_user is not None rtd_ctx = Context({ 'current_version': self.version.verbose_name, 'project': project, 'settings': settings, 'static_path': STATIC_DIR, 'template_path': TEMPLATE_DIR, 'conf_py_path': conf_py_path, 'api_host': getattr(settings, 'SLUMBER_API_HOST', 'https://readthedocs.org'), # GitHub 'github_user': github_user, 'github_repo': github_repo, 'github_version': remote_version, 'github_version_is_editable': github_version_is_editable, 'display_github': display_github, # BitBucket 'bitbucket_user': bitbucket_user, 'bitbucket_repo': bitbucket_repo, 'bitbucket_version': remote_version, 'bitbucket_version_is_editable': bitbucket_version_is_editable, 'display_bitbucket': display_bitbucket, 'commit': self.version.project.vcs_repo(self.version.slug).commit, }) # Avoid hitting database and API if using Docker build environment if getattr(settings, 'DONT_HIT_API', False): rtd_ctx['versions'] = project.active_versions() rtd_ctx['downloads'] = self.version.get_downloads(pretty=True) else: rtd_ctx['versions'] = project.api_versions() rtd_ctx['downloads'] = (apiv2.version(self.version.pk) .get()['downloads']) rtd_string = template_loader.get_template('doc_builder/conf.py.tmpl').render(rtd_ctx) outfile.write(rtd_string)
def _whitelisted(self, **kwargs): """Modify the given ``conf.py`` file from a whitelisted user's project. """ project = self.version.project #Open file for appending. outfile = codecs.open(project.conf_file(self.version.slug), encoding='utf-8', mode='a') outfile.write("\n") conf_py_path = version_utils.get_conf_py_path(self.version) remote_version = version_utils.get_vcs_version(self.version) github_info = version_utils.get_github_username_repo(self.version) bitbucket_info = version_utils.get_bitbucket_username_repo( self.version) if github_info[0] is None: display_github = False else: display_github = True if bitbucket_info[0] is None: display_bitbucket = False else: display_bitbucket = True rtd_ctx = Context({ 'versions': project.api_versions(), 'downloads': self.version.get_downloads(pretty=True), 'current_version': self.version.slug, 'project': project, 'settings': settings, 'static_path': STATIC_DIR, 'template_path': TEMPLATE_DIR, 'conf_py_path': conf_py_path, 'downloads': apiv2.version(self.version.pk).downloads.get()['downloads'], # GitHub 'github_user': github_info[0], 'github_repo': github_info[1], 'github_version': remote_version, 'display_github': display_github, # BitBucket 'bitbucket_user': bitbucket_info[0], 'bitbucket_repo': bitbucket_info[1], 'bitbucket_version': remote_version, 'display_bitbucket': display_bitbucket, }) rtd_string = Template(RTD_CONF_ADDITIONS).render(rtd_ctx) outfile.write(rtd_string)