Esempio n. 1
0
def finish_build(version_pk, build_pk, hostname=None, html=False,
                 localmedia=False, search=False, pdf=False, epub=False):
    """Build Finished, do house keeping bits"""
    version = Version.objects.get(pk=version_pk)
    build = Build.objects.get(pk=build_pk)

    if html:
        version.active = True
        version.built = True
        version.save()

    if not pdf:
        clear_pdf_artifacts(version)
    if not epub:
        clear_epub_artifacts(version)

    move_files(
        version_pk=version_pk,
        hostname=hostname,
        html=html,
        localmedia=localmedia,
        search=search,
        pdf=pdf,
        epub=epub,
    )

    symlink(project=version.project)

    # Delayed tasks
    update_static_metadata.delay(version.project.pk)
    fileify.delay(version.pk, commit=build.commit)
    update_search.delay(version.pk, commit=build.commit)
Esempio n. 2
0
def finish_build(version_pk, build_pk, hostname=None, html=False,
                 localmedia=False, search=False, pdf=False, epub=False):
    """Build Finished, do house keeping bits"""
    version = Version.objects.get(pk=version_pk)
    build = Build.objects.get(pk=build_pk)

    if html:
        version.active = True
        version.built = True
        version.save()

    if not pdf:
        clear_pdf_artifacts(version)
    if not epub:
        clear_epub_artifacts(version)

    move_files(
        version_pk=version_pk,
        hostname=hostname,
        html=html,
        localmedia=localmedia,
        search=search,
        pdf=pdf,
        epub=epub,
    )

    symlink(project=version.project)

    # Delayed tasks
    update_static_metadata.delay(version.project.pk)
    fileify.delay(version.pk, commit=build.commit)
    update_search.delay(version.pk, commit=build.commit)
Esempio n. 3
0
 def handle(self, *args, **options):
     if len(args):
         if args[0] == "cnames":
             log.info("Updating all CNAME Symlinks")
             redis_conn = redis.Redis(**settings.REDIS)
             slugs = redis_conn.keys('rtd_slug:v1:*')
             slugs = [slug.replace("rtd_slug:v1:", "") for slug in slugs]
             for slug in slugs:
                 try:
                     log.info("Got slug from redis: %s" % slug)
                     utils.symlink(project=Project.objects.get(slug=slug))
                 except Exception, e:
                     print e
         else:
             for slug in args:
                 utils.symlink(project=Project.objects.get(slug=slug))
Esempio n. 4
0
 def handle(self, *args, **options):
     if len(args):
         if args[0] == "cnames":
             log.info("Updating all CNAME Symlinks")
             redis_conn = redis.Redis(**settings.REDIS)
             slugs = redis_conn.keys('rtd_slug:v1:*')
             slugs = [slug.replace("rtd_slug:v1:", "") for slug in slugs]
             for slug in slugs:
                 try:
                     log.info("Got slug from redis: %s" % slug)
                     utils.symlink(project=slug)
                 except Exception, e:
                     print e
         else:
             for slug in args:
                 utils.symlink(project=slug)
Esempio n. 5
0
    def save(self, *args, **kwargs):
        first_save = self.pk is None
        if not self.slug:
            # Subdomains can't have underscores in them.
            self.slug = slugify(self.name).replace('_', '-')
            if self.slug == '':
                raise Exception(_("Model must have slug"))
        super(Project, self).save(*args, **kwargs)
        for owner in self.users.all():
            assign('view_project', owner, self)
        try:
            if self.default_branch:
                latest = self.versions.get(slug=LATEST)
                if latest.identifier != self.default_branch:
                    latest.identifier = self.default_branch
                    latest.save()
        except Exception:
            log.error('Failed to update latest identifier', exc_info=True)

        # Add exceptions here for safety
        try:
            self.sync_supported_versions()
        except Exception:
            log.error('failed to sync supported versions', exc_info=True)
        try:
            if not first_save:
                symlink(project=self.slug)
        except Exception:
            log.error('failed to symlink project', exc_info=True)
        try:
            update_static_metadata(project_pk=self.pk)
        except Exception:
            log.error('failed to update static metadata', exc_info=True)
        try:
            branch = self.default_branch or self.vcs_repo().fallback_branch
            if not self.versions.filter(slug=LATEST).exists():
                self.versions.create_latest(identifier=branch)
            # if not self.versions.filter(slug=STABLE).exists():
            #     self.versions.create_stable(type='branch', identifier=branch)
        except Exception:
            log.error('Error creating default branches', exc_info=True)
Esempio n. 6
0
    def save(self, *args, **kwargs):
        first_save = self.pk is None
        if not self.slug:
            # Subdomains can't have underscores in them.
            self.slug = slugify(self.name).replace('_', '-')
            if self.slug == '':
                raise Exception(_("Model must have slug"))
        super(Project, self).save(*args, **kwargs)
        for owner in self.users.all():
            assign('view_project', owner, self)
        try:
            if self.default_branch:
                latest = self.versions.get(slug=LATEST)
                if latest.identifier != self.default_branch:
                    latest.identifier = self.default_branch
                    latest.save()
        except Exception:
            log.error('Failed to update latest identifier', exc_info=True)

        # Add exceptions here for safety
        try:
            self.sync_supported_versions()
        except Exception:
            log.error('failed to sync supported versions', exc_info=True)
        try:
            if not first_save:
                symlink(project=self.slug)
        except Exception:
            log.error('failed to symlink project', exc_info=True)
        try:
            update_static_metadata(project_pk=self.pk)
        except Exception:
            log.error('failed to update static metadata', exc_info=True)
        try:
            branch = self.default_branch or self.vcs_repo().fallback_branch
            if not self.versions.filter(slug=LATEST).exists():
                self.versions.create_latest(identifier=branch)
            # if not self.versions.filter(slug=STABLE).exists():
            #     self.versions.create_stable(type='branch', identifier=branch)
        except Exception:
            log.error('Error creating default branches', exc_info=True)
Esempio n. 7
0
 def handle(self, *args, **options):
     for slug in options['projects']:
         utils.symlink(project=Project.objects.get(slug=slug))