[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

extras-buildsys/server BuildJob.py, 1.12, 1.13 UserInterface.py, 1.12, 1.13



Author: dcbw

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

Modified Files:
	BuildJob.py UserInterface.py 
Log Message:
2005-06-29  Dan Williams <dcbw redhat com>

    * Add the ability to search jobs on current job status from plague-client




Index: BuildJob.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/BuildJob.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- BuildJob.py	29 Jun 2005 18:06:12 -0000	1.12
+++ BuildJob.py	29 Jun 2005 20:27:17 -0000	1.13
@@ -71,6 +71,20 @@
 
 http_dir = os.path.join(config_opts['server_work_dir'], "srpm_http_dir")
 
+
+
+def is_build_job_stage_valid(stage):
+    """
+    Validate a job stage.
+    """
+
+    stages = ['initialize', 'checkout', 'make_srpm', 'prep', 'building', 'cleanup', 'failed', 'addtorepo', 'repodone', 'needsign', 'finished', 'killed']
+    if stage in stages:
+        return True
+    return False
+
+
+
 class BuildJob(threading.Thread):
     """ Controller object for building 1 SRPM on multiple arches """
 


Index: UserInterface.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/UserInterface.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- UserInterface.py	29 Jun 2005 05:23:00 -0000	1.12
+++ UserInterface.py	29 Jun 2005 20:27:17 -0000	1.13
@@ -23,6 +23,7 @@
 import os
 import copy
 import BuildMaster
+import BuildJob
 
 # Load in the config
 execfile("/etc/plague/server/CONFIG.py")
@@ -119,17 +120,31 @@
         first = True
 
         if args_dict.has_key('email') and args_dict['email']:
+            # FIXME: validate email so users can't do random SQL queries
+            # in place of the email address
             if first:
                 search = search +  " WHERE "
+                first = False
             else:
-                search = search + "AND "
-            search = search + 'username LIKE "%%%s%%" ' % args_dict['email']
-            first = False
+                search = search + " AND "
+            search = search + 'username LIKE "%%%s%%"' % args_dict['email']
+
+        if args_dict.has_key('status') and args_dict['status']:
+            status = args_dict['status']
+            if BuildJob.is_build_job_stage_valid(status):
+                if first:
+                    search = search +  " WHERE "
+                    first = False
+                else:
+                    search = search + " AND "
+                search = search + 'status = "%s"' % status
+            else:
+                return (-1, "Error: Invalid query.", [])
 
         if len(search):
             sql = sql + search
         if not len(sql):
-            return []
+            return (-1, "Error: Invalid query.", [])
 
         job_list = []
         query = BuildMaster.JobsQuery(sql)
@@ -137,12 +152,16 @@
         start_time = time.time()
 
         # Wait for query to return from BuildMaster
+        ret = -1
+        msg = "Error: The query timed out, please try again."
         while time.time() <= start_time + 5:
             if query.done:
                 job_list = copy.deepcopy(query.result)
                 del query
+                ret = 0
+                msg = "Success."
                 break
-        return job_list
+        return (ret, msg, job_list)
 
 
     def update_clients(self):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]