fedora-accounts bz-make-components.py,1.12,1.13

Jeremy Katz (katzj) fedora-extras-commits at redhat.com
Tue Jun 19 15:00:22 UTC 2007


Author: katzj

Update of /cvs/fedora/fedora-accounts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32191

Modified Files:
	bz-make-components.py 
Log Message:
update to work with new Fedora product.  add dry run functionality so that
things can actually be tested



Index: bz-make-components.py
===================================================================
RCS file: /cvs/fedora/fedora-accounts/bz-make-components.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- bz-make-components.py	30 Mar 2007 19:27:58 -0000	1.12
+++ bz-make-components.py	19 Jun 2007 15:00:20 -0000	1.13
@@ -10,6 +10,8 @@
 GRANT_DERIVED = 1
 GRANT_REGEXP = 2
 
+DRY_RUN = True
+
 def get_bz_user_id(bzdbh, username):
     bzdbc = bzdbh.cursor()
     bzdbc.execute("SELECT userid FROM profiles WHERE login_name = %s",
@@ -78,27 +80,39 @@
                     continue
                 cclist.append(Inum)
 
-        if product[:len('Fedora ')] != 'Fedora ' or product == 'Fedora Core' or product == 'Fedora Legacy':
+        if product != "Fedora" and product[:len('Fedora ')] != 'Fedora ':
             print "Invalid product %s at %s:%s" % (product, curfile, lnum)
             continue
 
         bzdbc.execute("SELECT id FROM products WHERE name = %s", (product,))
         if not bzdbc.rowcount:
-            bzdbc.execute("INSERT INTO products (name, description, disallownew, votesperuser, maxvotesperbug, votestoconfirm, defaultmilestone, depends) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", (product, product, 0, 0, 10000, 0, '---', 0))
-            bzdbc.execute("SELECT id FROM products WHERE name = %s", (product,))
-            product_id = bzdbc.fetchone()[0]
-            bzdbc.execute("INSERT INTO versions (value, product_id) VALUES (%s, %s)", ("development", product_id))
-            bzdbc.execute("INSERT INTO milestones (product_id, value, sortkey) VALUES (%s, '---', 0)", (product_id,))
+            if DRY_RUN:
+                print "Need to create product %s" %(product,)
+                sys.exit(0)
+            else:
+                bzdbc.execute("INSERT INTO products (name, description, disallownew, votesperuser, maxvotesperbug, votestoconfirm, defaultmilestone, depends) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", (product, product, 0, 0, 10000, 0, '---', 0))
+                bzdbc.execute("SELECT id FROM products WHERE name = %s", (product,))
+                product_id = bzdbc.fetchone()[0]
+                bzdbc.execute("INSERT INTO versions (value, product_id) VALUES (%s, %s)", ("development", product_id))
+                bzdbc.execute("INSERT INTO milestones (product_id, value, sortkey) VALUES (%s, '---', 0)", (product_id,))
         else:
             product_id = bzdbc.fetchone()[0]
 
         bzdbc.execute("SELECT * FROM components WHERE product_id = %s AND name = %s", (product_id, component))
         if bzdbc.rowcount:
             arow = bzdbc.fetchhash()
-            bzdbc.execute("UPDATE components SET initialowner = %s, initialqacontact = %s, initialcclist = %s WHERE id = %s",
+            if DRY_RUN:
+                print("component update of %s:  UPDATE components SET initialowner = %s, initialqacontact = %s, initialcclist = %s WHERE id = %s",
+                              (component, owner_num, qa_num, ':'.join(map(str,cclist)), arow['id']))
+            else:
+                bzdbc.execute("UPDATE components SET initialowner = %s, initialqacontact = %s, initialcclist = %s WHERE id = %s",
                           (owner_num, qa_num, ':'.join(map(str,cclist)), arow['id']))
         else:
-            bzdbc.execute("INSERT INTO components (name, product_id, description, initialowner, initialqacontact, initialcclist) VALUES (%s, %s, %s, %s, %s, %s)",
+            if DRY_RUN:
+                print("create component: INSERT INTO components (name, product_id, description, initialowner, initialqacontact, initialcclist) VALUES (%s, %s, %s, %s, %s, %s)",
+                          (component, product_id, description, owner_num, qa_num, ':'.join(map(str,cclist))))
+            else:
+                bzdbc.execute("INSERT INTO components (name, product_id, description, initialowner, initialqacontact, initialcclist) VALUES (%s, %s, %s, %s, %s, %s)",
                           (component, product_id, description, owner_num, qa_num, ':'.join(map(str,cclist))))
 bzdbh.commit()
 




More information about the scm-commits mailing list