fedora-updates-system/updatessystem admin.py, 1.2, 1.3 controllers.py, 1.10, 1.11 mail.py, 1.3, 1.4 model.py, 1.8, 1.9 push.py, 1.4, 1.5

Luke Macken (lmacken) fedora-extras-commits at redhat.com
Mon Jan 8 06:07:09 UTC 2007


Author: lmacken

Update of /cvs/fedora/fedora-updates-system/updatessystem
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv23477/updatessystem

Modified Files:
	admin.py controllers.py mail.py model.py push.py 
Log Message:
- Add support for unpushing updates easily
- Add push, unpush, unpushed mails
- Don't allow deletion of pushed updates
- A bunch of other tweaks and such



Index: admin.py
===================================================================
RCS file: /cvs/fedora/fedora-updates-system/updatessystem/admin.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- admin.py	6 Jan 2007 08:03:21 -0000	1.2
+++ admin.py	8 Jan 2007 06:07:07 -0000	1.3
@@ -25,7 +25,6 @@
     push = PushController()
     catwalk = CatWalk()
 
-   # @identity.require(identity.in_group('admin'))
     @expose(template='updatessystem.templates.admin')
     def index(self):
         return dict()


Index: controllers.py
===================================================================
RCS file: /cvs/fedora/fedora-updates-system/updatessystem/controllers.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- controllers.py	6 Jan 2007 08:03:21 -0000	1.10
+++ controllers.py	8 Jan 2007 06:07:07 -0000	1.11
@@ -104,7 +104,7 @@
 
     @expose()
     @identity.require(identity.not_anonymous())
-    def submit(self, nvr):
+    def push(self, nvr):
         """
         Submit an update for pushing.
         """
@@ -112,6 +112,19 @@
             up = PackageUpdate.byNvr(nvr)
             up.needs_push = True
             flash("%s has been submitted for pushing" % nvr)
+            mail.send_admin('push', up)
+        except SQLObjectNotFound:
+            flash("Update %s not found" % nvr)
+        raise redirect('/show/%s' % nvr)
+
+    @expose()
+    @identity.require(identity.not_anonymous())
+    def unpush(self, nvr):
+        try:
+            up = PackageUpdate.byNvr(nvr)
+            up.needs_unpush = True
+            flash("%s has been submitted for unpushing" % nvr)
+            mail.send_admin('unpush', up)
         except SQLObjectNotFound:
             flash("Update %s not found" % nvr)
         raise redirect('/show/%s' % nvr)
@@ -119,31 +132,29 @@
     @expose()
     @identity.require(identity.not_anonymous())
     def delete(self, update):
+        """
+        Delete a pending update
+        """
         try:
             up = PackageUpdate.byNvr(update)
         except SQLObjectNotFound:
             flash("Update %s not found" % update)
             raise redirect("/list")
-        log.debug("Deleting update %s" % up.nvr)
-        if up.pushed:
-            log.info("Unpushing %s" % up.nvr)
-            for out in self.admin.push.unpush_update(up):
-                log.info(out)
-            for out in self.admin.push.generate_metadata(up):
-                log.info(out)
-            # TODO: remove extended metadata for this update
+        if not up.pushed:
+            log.debug("Deleting update %s" % up.nvr)
             up.destroySelf()
             mail.send_admin('deleted', up)
-            flash("Deleted and unpushed %s" % update)
-        else:
-            mail.send_admin('deleted', up)
-            up.destroySelf()
             flash("%s deleted" % update)
+        else:
+            flash("Cannot delete a pushed update")
         raise redirect("/list")
 
     @identity.require(identity.not_anonymous())
     @expose(template='updatessystem.templates.form')
     def edit(self, update):
+        """
+        Edit an update
+        """
         try:
             up = PackageUpdate.byNvr(update)
         except SQLObjectNotFound:
@@ -151,7 +162,7 @@
             raise redirect("/list")
         values = {
                 'nvr'       : {'text': up.nvr, 'hidden' : up.nvr},
-                'release'   : up.release.name,
+                'release'   : up.release.long_name,
                 'testing'   : up.testing,
                 'type'      : up.type,
                 'embargo'   : up.embargo,


Index: mail.py
===================================================================
RCS file: /cvs/fedora/fedora-updates-system/updatessystem/mail.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- mail.py	6 Jan 2007 08:03:21 -0000	1.3
+++ mail.py	8 Jan 2007 06:07:07 -0000	1.4
@@ -87,6 +87,38 @@
                         'package' : x.nvr,
                         'release' : x.release.long_name
                     }
+    },
+
+    'push' : {
+        'subject' : '[Fedora Update] [push] %(package)s',
+        'body'    : """\
+%(submitter)s has requested the pushing of the following update:\n%(updatestr)s
+""",
+        'fields'  : lambda x: {
+                        'submitter' : x.submitter,
+                        'updatestr' : update_str(x)
+                    }
+    },
+
+    'unpush' : {
+        'subject' : '[Fedora Update] [unpush] %(package)s',
+        'body'    : """\
+%(submitter)s has requested the unpushing of the following update:\n%(updatestr)s
+""",
+        'fields'  : lambda x: {
+                        'submitter' : x.submitter,
+                        'updatestr' : update_str(x)
+                    }
+    },
+
+    'unpushed' : {
+        'subject' : '[Fedora Update] [unpushed] %(package)s',
+        'body'    : """\
+The following update has been unpushed\n\n%(updatestr)s
+""",
+        'fields'  : lambda x: {
+                        'updatestr' : update_str(x)
+                    }
     }
 }
 


Index: model.py
===================================================================
RCS file: /cvs/fedora/fedora-updates-system/updatessystem/model.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- model.py	6 Jan 2007 08:03:21 -0000	1.8
+++ model.py	8 Jan 2007 06:07:07 -0000	1.9
@@ -46,12 +46,6 @@
     arches      = RelatedJoin('Arch')
 
 class Package(SQLObject):
-    """
-        Table of packages in available for updating.  This table should
-        eventually populate itself from either the package database, or some
-        other reliable source.  For now, they are populated when this model
-        is executed by hand.
-    """
     name    = UnicodeCol(alternateID=True, notNone=True)
     updates = MultipleJoin('PackageUpdate', joinColumn='package_id')
 
@@ -63,7 +57,7 @@
     package         = ForeignKey('Package')
     submitter       = UnicodeCol(notNone=True)
     update_id       = UnicodeCol(default=None)
-    type            = UnicodeCol() # security/bugfix/enhancement
+    type            = EnumCol(enumValues=['security', 'bugfix', 'enhancement'])
     embargo         = DateTimeCol(default=None)
     cves            = RelatedJoin("CVE")
     bugs            = RelatedJoin("Bugzilla")
@@ -73,10 +67,10 @@
     date_pushed     = DateTimeCol(default=None)
     notes           = UnicodeCol()
     mail_sent       = BoolCol(default=False)
-    close_bugs      = BoolCol(default=False)
-    bug_close_msg   = UnicodeCol(default=None)
+    #close_bugs      = BoolCol(default=False)
     archived_mail   = UnicodeCol(default=None)
     needs_push      = BoolCol(default=False)
+    needs_unpush    = BoolCol(default=False)
     comments        = MultipleJoin('Comment', joinColumn='update_id')
 
     ## TODO: create File table ?


Index: push.py
===================================================================
RCS file: /cvs/fedora/fedora-updates-system/updatessystem/push.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- push.py	6 Jan 2007 08:03:21 -0000	1.4
+++ push.py	8 Jan 2007 06:07:07 -0000	1.5
@@ -41,7 +41,7 @@
         self.stage_dir = config.get('stage_dir')
         self.lockfile = join(self.stage_dir, '.lock')
         if isfile(self.lockfile):
-            log.debug("Removing stale lockfile")
+            log.debug("Removing stale repository lockfile")
             self._unlock_repo()
 
     def _lock_repo(self):
@@ -57,18 +57,23 @@
     @expose(template='updatessystem.templates.push')
     def index(self):
         updates = PackageUpdate.select(PackageUpdate.q.needs_push == True)
-        return dict(updates=updates)
+        return dict(updates=updates, label='Push Updates', callback='/admin/push/push_updates')
+
+    @expose(template='updatessystem.templates.push')
+    def unpush(self):
+        updates = PackageUpdate.select(PackageUpdate.q.needs_unpush == True)
+        return dict(updates=updates, label='Unpush Updates', callback='/admin/push/unpush_updates')
 
     @expose(template='updatessystem.templates.pushconsole')
-    def console(self, updates, **kw):
+    def console(self, updates, callback, **kw):
         if not updates:
             flash("No updates selected for pushing")
             raise redirect("/push")
         if not isinstance(updates, list):
             updates = [updates]
         log.debug("Setting updates in session: %s" % updates)
-        cherrypy.session['topush'] = updates
-        return dict()
+        cherrypy.session['updates'] = updates
+        return dict(callback=callback)
 
     @expose()
     def push_updates(self):
@@ -91,7 +96,7 @@
                 return
 
             line = '=' * 100
-            for package in cherrypy.session['topush']:
+            for package in cherrypy.session['updates']:
                 update = PackageUpdate.byNvr(package)
                 try:
                     yield "%s\nPushing %s\n%s" % (line, update.nvr, line)
@@ -111,11 +116,40 @@
                     yield "ERROR: Exception thrown during push: %s" % e
 
             self._unlock_repo()
-            cherrypy.session['topush'] = []
+            cherrypy.session['updates'] = []
             yield "\nPushing Complete! <%s>\n" % datetime.now()
 
         return _do_push()
 
+    @expose()
+    def unpush_updates(self):
+        @comet(content_type='text/plain')
+        def _do_unpush():
+            try:
+                self._lock_repo()
+                yield "Acquired lock for repository"
+            except RepositoryLocked:
+                err = "Unable to acquire lock for repository"
+                log.debug(err)
+                yield err
+                return
+            line = '=' * 100
+            for package in cherrypy.session['updates']:
+                update = PackageUpdate.byNvr(package)
+                yield "%s\nUnpushing %s\n%s" % (line, update.nvr, line)
+                for msg in self.unpush_update(update):
+                    log.info(msg)
+                    yield msg
+                yield "%s\nRegenerating metadata\n%s" % (line, line)
+                for msg in self.generate_metadata(update):
+                    log.info(msg)
+                    yield msg
+                update.pushed = False
+                update.needs_unpush = False
+                mail.send(update.submitter, 'unpushed', update)
+            yield "%s\nUpdates successfully unpushed!" % (line)
+            self._unlock_repo()
+        return _do_unpush()
 
     def get_dest_path(self, update, arch):
         """
@@ -128,7 +162,6 @@
         """
         Go through update.filelist, and push files to buildsys.get_dest_path.
         """
-        log.debug("push_update")
         try:
             for arch in update.filelist.keys():
                 dest = self.get_dest_path(update, arch)
@@ -155,12 +188,17 @@
         """
         yield "Unpushing %s" % update.nvr
         for arch in update.filelist.keys():
-            deset = self.get_dest_path(update, arch)
+            dest = self.get_dest_path(update, arch)
             for file in update.filelist[arch]:
-                destfile = join(dest, basename(file))
+                if file.find('debuginfo') != -1:
+                    destfile = join(dest, 'debug', basename(file))
+                else:
+                    destfile = join(dest, basename(file))
                 if isfile(destfile):
                     yield "Deleting %s" % destfile
                     os.unlink(destfile)
+                else:
+                    yield "Cannot find file in update: %s" % destfile
 
     def generate_metadata(self, update):
         """
@@ -168,22 +206,22 @@
         """
         for arch in update.filelist.keys():
             repo = self.get_dest_path(update, arch)
-            cache_dir = join(self.createrepo_cache, 'fc%s-%s' %
-                             (update.release.name[-1], arch))
-
-            if not isdir(cache_dir):
-                log.info("Creating createrepo cache directory: %s" % cache_dir)
-                os.makedirs(cache_dir)
+            #cache_dir = join(self.createrepo_cache, 'fc%s-%s' %
+            #                 (update.release.name[-1], arch))
+            #if not isdir(cache_dir):
+            #    log.info("Creating createrepo cache directory: %s" % cache_dir)
+            #    os.makedirs(cache_dir)
 
             yield repo
-            genpkgmetadata.main(['--cachedir', str(cache_dir), '-p', '-q',
-                                str(repo)])
+            genpkgmetadata.main(['--cachedir', str(self.createrepo_cache),
+                                 '-p', '-q', str(repo)])
 
             debugrepo = join(repo, 'debug')
             if isdir(debugrepo):
-                 genpkgmetadata.main(['--cachedir', str(cache_dir), '-p', '-q',
-                                     str(debugrepo)])
-                 yield repo
+                 genpkgmetadata.main(['--cachedir', str(self.createrepo_cache),
+                                      '-p', '-q', str(debugrepo)])
+                 yield debugrepo
 
 ## Allow us to return a generator for streamed responses
 cherrypy.config.update({'/push/push_updates':{'stream_response':True}})
+cherrypy.config.update({'/push/unpush_updates':{'stream_response':True}})




More information about the fedora-extras-commits mailing list