extras-buildsys/server PackageJob.py, 1.17, 1.18 UserInterface.py, 1.39, 1.40

Daniel Williams (dcbw) fedora-extras-commits at redhat.com
Thu Aug 4 20:27:14 UTC 2005


Author: dcbw

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

Modified Files:
	PackageJob.py UserInterface.py 
Log Message:
2005-08-04  Dan Williams <dcbw at redhat.com>

    * Attempts to reduce network bandwidth usage between client & server
        - for listing jobs, 'status' item in the arg list is now a list itself
            which is combined using OR.
        - New 'orderby' arg for listing jobs
        - Fixes for both of the above in the web interface, the client,
            and the server

    * Small fixes to the web interface to display 'result' as well as 'status'




Index: PackageJob.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/PackageJob.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- PackageJob.py	4 Aug 2005 11:47:07 -0000	1.17
+++ PackageJob.py	4 Aug 2005 20:27:12 -0000	1.18
@@ -549,8 +549,7 @@
                     # the original SRPM.
                     if not os.path.exists(srpm_file):
                         shutil.copy(src_file, srpm_file)
-                else:
-                    os.remove(src_file)
+                os.remove(src_file)
 
         # If there were no builder-built SRPMs, keep the original around
         if not os.path.exists(srpm_file):


Index: UserInterface.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/UserInterface.py,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- UserInterface.py	3 Aug 2005 04:32:40 -0000	1.39
+++ UserInterface.py	4 Aug 2005 20:27:12 -0000	1.40
@@ -71,6 +71,11 @@
             return False
     return True
 
+def validate_orderby(order):
+    safe_list = ['username', 'status', 'result', 'uid', 'target', 'starttime', 'endtime', 'package']
+    if order in safe_list:
+        return True
+    return False
 
 class InvalidTargetError(exceptions.Exception): pass
 
@@ -224,11 +229,19 @@
                 return (-1, "Error: Invalid email address.", [])
 
         if args_dict.has_key('status') and args_dict['status']:
-            status = args_dict['status']
-            if PackageJob.is_package_job_stage_valid(status):
-                sql_args.append('status="%s"' % status)
-            else:
+            status_list = args_dict['status']
+            if not len(status_list):
                 return (-1, "Error: Invalid job status.", [])
+            status_sql = ''
+            for status in status_list:
+                if not PackageJob.is_package_job_stage_valid(status):
+                    return (-1, "Error: Invalid job status.", [])
+                if len(status_sql) > 0:
+                    status_sql = status_sql + ' OR status="%s"' % status
+                else:
+                    status_sql = 'status="%s"' % status
+            status_sql = '(' + status_sql + ')'
+            sql_args.append(status_sql)
 
         if args_dict.has_key('result') and args_dict['result']:
             result = args_dict['result']
@@ -273,7 +286,23 @@
                 sql = sql + " AND "
             i = i + 1
 
+        # Result list order
+        if args_dict.has_key('orderby') and args_dict['orderby']:
+            orderby_list = args_dict['orderby']
+            if not len(orderby_list):
+                return (-1, "Error: Invalid result order.", [])
+            orderby_sql = ''
+            for order in orderby_list:
+                if not validate_orderby(order):
+                    return (-1, "Error: Invalid result order.", [])
+                if len(orderby_sql) > 0:
+                    orderby_sql = orderby_sql + ', %s' % order
+                else:
+                    orderby_sql = order
+            sql = sql + " ORDER BY %s" % orderby_sql
+
         # Deal with max # records
+        # MUST BE LAST ON SQL
         if args_dict.has_key('maxrows') and args_dict['maxrows']:
             if not validate_uid(args_dict['maxrows']):
                 return (-1, "Error: Invalid max rows number.", [])




More information about the fedora-extras-commits mailing list