Beispiel #1
0
    def default(self, reponame):
        if reponame not in self.repos.sections():
            raise cherrypy.HTTPError(404)

        self._checkAccess(reponame)

        logger = BuildLogger(self.repodir)

        msg = "<table><tr><th>Time</th><th>Message</th><th>User</th></tr>"
        first = True
        for record in logger.getLogs(reponame):
            record += [''] * (3 - len(record))
            if first:
                msg += """<tr><td>{}</td><td><a href="../buildlog/{}">{}</a></td><td>{}</td></tr>""".format(
                    record[0], reponame, record[1], record[2])
                first = False
            else:
                msg += """<tr><td>{}</td><td>{}</td><td>{}</td></tr>""".format(
                    record[0], record[1], record[2])

        msg += "</table>"

        template = Template("templates/info.html")
        template.assignData("reponame", reponame)
        for k, v in self.repos.items(reponame):
            template.assignData("repo." + k, v)

        template.assignData("messages", msg)
        template.assignData("pagetitle", reponame + " info")

        return template.render()
Beispiel #2
0
    def default(self, reponame):
        if reponame not in self.repos.sections():
            raise cherrypy.HTTPError(404)

        self._checkAccess(reponame)
        lock = self.locks[reponame]
        msg = None
        sendMail = False

        lock.acquire()
        try:
            try:
                time_start = time.time()
                time_end = None
                repo = self._updateRepo(reponame)
                try:
                    if self._build(reponame):
                        msg = "#{} Build succeeded.".format(
                            repo.head.commit.hexsha[0:6])
                        msg_class = "green"
                        time_end = time.time()
                    else:
                        msg = "#{} Build failed.".format(
                            repo.head.commit.hexsha[0:6])
                        msg_class = "red"
                except:
                    msg = "#{} Build error.".format(
                        repo.head.commit.hexsha[0:6])
                    msg_class = "red"
                    raise
            except GitCommandError as e:
                msg = "Pull error. ({})".format(str(e))
                msg_class = "red"
                sendMail = True
                raise

            if time_end != None:
                msg += " ({:.2f} s)".format(time_end - time_start)

            template = Template("templates/build.html")
            template.assignData("reponame", reponame)
            template.assignData("message", msg)
            template.assignData("msg_class", msg_class)
            template.assignData("pagetitle", "Build")
            return template.render()
        finally:
            logger = BuildLogger(self.repodir)
            logger.log(reponame, msg, sendMail)
            lock.release()
Beispiel #3
0
    def index(self, **params):
        template = Template('templates/home.html')
        repos = ""
        user = cherrypy.request.login

        for section in self.repos.sections():
            if user in self.repos.get(section, "users").split(","):
                building = self._isBuilding(section)
                building = ', building&hellip;' if building else ''
                repos += """<li><a href="{}">{}</a> (<a href="info/{}">info</a>{})</li>""".format(
                    section, section, section, building)

        template.assignData("pagetitle", "Astrid")
        template.assignData("repos", repos)
        template.assignData("user", user)
        return template.render()
Beispiel #4
0
    def default(self, reponame):
        if reponame not in self.repos.sections():
            raise cherrypy.HTTPError(404)

        self._checkAccess(reponame)

        logger = BuildLogger(self.repodir)
        building = self._isBuilding(reponame)
        building = ', building&hellip;' if building else ''

        template = Template("templates/buildlog.html")
        template.assignData("reponame", reponame)
        template.assignData("building", building)
        template.assignData("buildlog", logger.getBuildlog(reponame))

        template.assignData("pagetitle", reponame + " build log")

        return template.render()