extras-buildsys/common Commands.py,1.6,1.7

Daniel Williams (dcbw) fedora-extras-commits at redhat.com
Fri May 12 04:04:07 UTC 2006


Author: dcbw

Update of /cvs/fedora/extras-buildsys/common
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29934/common

Modified Files:
	Commands.py 
Log Message:
2006-05-12  Dan Williams  <dcbw at redhat.com>

    * common/Commands.py
        - pylint cleanups
        - Add the KillJob command




Index: Commands.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/common/Commands.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Commands.py	9 May 2006 19:10:56 -0000	1.6
+++ Commands.py	12 May 2006 04:04:05 -0000	1.7
@@ -34,6 +34,7 @@
 CMD_NAME_JOB_STATUS_ACK = "JobStatusAck"
 CMD_NAME_JOB_FILES_REQ = "JobFiles"
 CMD_NAME_JOB_FILES_ACK = "JobFilesAck"
+CMD_NAME_KILL_JOB = "KillJob"
 
 
 class SequenceGenerator(object):
@@ -111,8 +112,8 @@
             name = cmd_stream['name']
             args = cmd_stream['args']
             seq = cmd_stream['sequence']
-        except (KeyError, TypeError), e:
-            print "PlgCommand deserialize error: %s" % e
+        except (KeyError, TypeError), exc:
+            print "PlgCommand deserialize error: %s" % exc
             return None
 
         # Create the specific command object from the command's name
@@ -138,6 +139,8 @@
             cmd = PlgCommandJobFilesAck._deserialize(args)
         elif name == CMD_NAME_UNLOCK_REPO:
             cmd = PlgCommandUnlockRepo._deserialize(args)
+        elif name == CMD_NAME_KILL_JOB:
+            cmd = PlgCommandKillJob._deserialize(args)
 
         # If command creation was successful, set the sequence
         # number from the command stream on the command.  We don't
@@ -195,7 +198,7 @@
     def _deserialize_acked_seq(args):
         try:
             acked_seq = args['acked_seq']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'acked_seq' argument found.")
         return acked_seq
 
@@ -230,7 +233,7 @@
     def _deserialize(args):
         try:
             reason = args['reason']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'reason' argument found.")
         return PlgCommandError(reason)
 
@@ -257,11 +260,11 @@
     def _deserialize(args):
         try:
             free = args['free']
-        except ValueError, TypeError:
+        except (ValueError, TypeError):
             raise ValueError("No 'free' argument found.")
         try:
             maximum = args['max']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'max' argument found.")
         return PlgCommandSlots(free, maximum)
 
@@ -291,7 +294,7 @@
     def _deserialize(args):
         try:
             targets = args['targets']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'targets' argument found.")
 
         # Sanity checking on targets argument
@@ -304,8 +307,8 @@
                 basearch = target['arch']
                 repo = target['repo']
                 suparch = target['supported_arches']
-            except KeyError, e:
-                raise ValueError("Required item '%s' not found in a target." % e)
+            except KeyError, exc:
+                raise ValueError("Required item '%s' not found in a target." % exc)
 
         return PlgCommandTargets(targets)
 
@@ -336,11 +339,11 @@
     def _deserialize(args):
         try:
             target_dict = args['target_dict']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'target_dict' argument found.")
         try:
             srpm_url = args['srpm_url']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'srpm_url' argument found.")
 
         return PlgCommandNewJobReq(None, target_dict, srpm_url)
@@ -376,7 +379,7 @@
         try:
             archjob_id = args['archjob_id']
             msg = args['msg']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'archjob_id' argument found.")
         req_seq = PlgCommandAck._deserialize_acked_seq(args)
         return PlgCommandNewJobAck(archjob_id, msg, req_seq)
@@ -404,7 +407,7 @@
     def _deserialize(args):
         try:
             archjob_id = args['archjob_id']
-        except ValueError, TypeError:
+        except (ValueError, TypeError):
             raise ValueError("No 'archjob_id' argument found.")
         return PlgCommandUnlockRepo(archjob_id)
 
@@ -430,7 +433,7 @@
     def _deserialize(args):
         try:
             jobs = args['jobs']
-        except ValueError, TypeError:
+        except (ValueError, TypeError):
             raise ValueError("No 'jobs' argument found.")
 
         # Basic sanity
@@ -441,7 +444,7 @@
             for job in jobs:
                 archjob_id = job['archjob_id']
                 status = job['status']
-        except KeyError, e:
+        except KeyError:
             raise ValueError("Required item '%s' wasn't found in jobs item.")
 
         cmd = PlgCommandBuildingJobs()
@@ -480,7 +483,7 @@
     def _deserialize(args):
         try:
             archjob_id = args['archjob_id']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'archjob_id' argument found.")
 
         return PlgCommandJobStatus(archjob_id)
@@ -508,11 +511,11 @@
     def _deserialize(args):
         try:
             archjob_id = args['archjob_id']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'archjob_id' argument found.")
         try:
             status = args['status']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'status' argument found.")
         req_seq = PlgCommandAck._deserialize_acked_seq(args)
         return PlgCommandJobStatusAck(archjob_id, status, req_seq)
@@ -543,7 +546,7 @@
     def _deserialize(args):
         try:
             archjob_id = args['archjob_id']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'archjob_id' argument found.")
 
         return PlgCommandJobFiles(archjob_id)
@@ -574,11 +577,11 @@
     def _deserialize(args):
         try:
             archjob_id = args['archjob_id']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'archjob_id' argument found.")
         try:
             files = args['files']
-        except KeyError, TypeError:
+        except (KeyError, TypeError):
             raise ValueError("No 'files' argument found.")
         if type(files) != type([]):
             raise ValueError("The 'files' argument was of the wrong type.")
@@ -599,3 +602,32 @@
 
     def files(self):
         return self._files
+
+
+class PlgCommandKillJob(PlgCommand):
+    def __init__(self, archjob_id, seq=0):
+        PlgCommand.__init__(self, CMD_NAME_KILL_JOB, seq)
+        self._archjob_id = archjob_id
+
+    def _deserialize(args):
+        try:
+            archjob_id = args['archjob_id']
+        except (KeyError, TypeError):
+            raise ValueError("No 'archjob_id' argument found.")
+
+        return PlgCommandKillJob(archjob_id)
+
+    _deserialize = staticmethod(_deserialize)
+
+    def serialize(self):
+        args = {}
+        args['archjob_id'] = self._archjob_id
+        return PlgCommand._serialize(self, args)
+
+    def archjob_id(self):
+        return self._archjob_id
+
+    def __str__(self):
+        return "%s(seq: %d, archjob_id: %s)" % (self._name, self._seq, self._archjob_id)
+
+




More information about the scm-commits mailing list