Beispiel #1
0
 def do(self):
     with db_transaction(self.project.env_name) as cursor:
         try:
             cursor.execute("TRUNCATE version")
             cursor.execute("TRUNCATE component")
             cursor.execute("TRUNCATE milestone")
         except Exception, e:
             conf.log.exception("Could not truncate trac default information")
             return False
 def do(self):
     with db_transaction(self.project.env_name) as cursor:
         try:
             cursor.execute("TRUNCATE version")
             cursor.execute("TRUNCATE component")
             cursor.execute("TRUNCATE milestone")
         except Exception, e:
             conf.log.exception("Could not truncate trac default information")
             return False
Beispiel #3
0
    def do(self):
        # TODO:
        # If project is home or HelpAndSupport, don't delete help wiki pages.
        # See self.project.env_name, home project identifier configuration.
        allowed_pages = ["TitleIndex", "RecentChanges"]
        allowed_pages = ", ".join("'%s'" % x for x in allowed_pages)

        with db_transaction(self.project.env_name) as cursor:
            try:
                cursor.execute("DELETE FROM wiki WHERE name NOT IN (%s)" % allowed_pages)
            except:
                conf.log.exception("InitTracWiki: Cannot delete pages")
                return False

            wikistart = ""
            downloads = ""
            templatef = ""

            # Read templates
            try:
                # TODO: Read files using template processor
                wikipth = "%s/wiki/%s" % (conf.default_theme_path, conf.theme_name)

                templatef = wikipth + "/wikistart.txt"
                wikistart = file(templatef).read()

                templatef = wikipth + "/downloads.txt"
                downloads = file(templatef).read()
            except:
                conf.log.exception("Cannot read template file (%s)." % templatef)
                return False

            try:
                t =  to_utimestamp(datetime.now(utc))
                query = """
                INSERT INTO wiki(name, version, time, author, ipnr, text)
                VALUES
                    ('WikiStart', 1, %s, 'trac', '127.0.0.1', %s),
                    ('Downloads', 1, %s, 'trac', '127.0.0.1', %s)
                """
                cursor.execute(query, (str(t), wikistart, str(t), downloads))
            except Exception:
                conf.log.exception("Failed to initialize project wiki")
                return False

        return True
    def do(self):
        # TODO:
        # If project is home or HelpAndSupport, don't delete help wiki pages.
        # See self.project.env_name, home project identifier configuration.
        allowed_pages = ["TitleIndex", "RecentChanges"]
        allowed_pages = ", ".join("'%s'" % x for x in allowed_pages)

        with db_transaction(self.project.env_name) as cursor:
            try:
                cursor.execute("DELETE FROM wiki WHERE name NOT IN (%s)" % allowed_pages)
            except:
                conf.log.exception("InitTracWiki: Cannot delete pages")
                return False

            wikistart = ""
            downloads = ""
            templatef = ""

            # Read templates
            try:
                # TODO: Read files using template processor
                wikipth = "%s/wiki/%s" % (conf.default_theme_path, conf.theme_name)

                templatef = wikipth + "/wikistart.txt"
                wikistart = file(templatef).read()

                templatef = wikipth + "/downloads.txt"
                downloads = file(templatef).read()
            except:
                conf.log.exception("Cannot read template file (%s)." % templatef)
                return False

            try:
                t =  to_utimestamp(datetime.now(utc))
                query = """
                INSERT INTO wiki(name, version, time, author, ipnr, text)
                VALUES
                    ('WikiStart', 1, %s, 'trac', '127.0.0.1', %s),
                    ('Downloads', 1, %s, 'trac', '127.0.0.1', %s)
                """
                cursor.execute(query, (str(t), wikistart, str(t), downloads))
            except Exception:
                conf.log.exception("Failed to initialize project wiki")
                return False

        return True