extras-buildsys/utils extras-repobuild.py,1.4,1.5

Seth Vidal (skvidal) fedora-extras-commits at redhat.com
Wed Nov 2 14:46:47 UTC 2005


Author: skvidal

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

Modified Files:
	extras-repobuild.py 
Log Message:

reduce a lot of silly code for running these commands



Index: extras-repobuild.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/extras-repobuild.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- extras-repobuild.py	2 Nov 2005 14:37:45 -0000	1.4
+++ extras-repobuild.py	2 Nov 2005 14:46:45 -0000	1.5
@@ -41,6 +41,14 @@
         print msg
         
 
+def run_and_check(cmd)
+    debugprint(cmd)
+    if not DEBUG:
+        result = os.system(cmd)
+        if result != 0:
+            print >> sys.stderr, 'Error running command: %s ' % cmd
+            sys.exit(result)
+
 def main(dist):
     if not archdict.has_key(dist):
         print "No Distribution named %s found" % dist
@@ -59,19 +67,13 @@
 
     print 'Cleaning up older packages'
     cmd = '/usr/bin/repomanage -k2 -o %s | xargs rm -f' % (repodir)
-    debugprint(cmd)
-    if not DEBUG:    
-        result = os.system(cmd)
-    
+    run_and_check(cmd)
+
     cmd = '/usr/bin/createrepo -c %s -q %s' % (cachedir, repodir)
-    debugprint(cmd)
-    if not DEBUG:    
-        result = os.system(cmd)
+    run_and_check(cmd)    
         
     cmd = '/usr/bin/repoview %s' % repodir
-    debugprint(cmd)
-    if not DEBUG:    
-        result = os.system(cmd)
+    run_and_check(cmd)        
     
     # arch repo creation
     for arch in archdict[dist]:
@@ -84,22 +86,16 @@
             
         print 'Cleaning up older packages'
         cmd = '/usr/bin/repomanage -k2 -o %s | xargs rm -f' % (repodir)
-        debugprint(cmd)
-        if not DEBUG:    
-            result = os.system(cmd)
+        run_and_check(cmd)            
             
         if os.path.exists(compspath):
             cmd = '/usr/bin/createrepo -c %s -q -g %s -x *debuginfo* %s' % (cachedir, compsname, repodir)
         else:
             cmd = '/usr/bin/createrepo -c %s -q -x *debuginfo* %s' % (cachedir, repodir)
-        debugprint(cmd)
-        if not DEBUG:        
-            result = os.system(cmd)
+        run_and_check(cmd)            
             
         cmd = '/usr/bin/repoview %s' % repodir
-        debugprint(cmd)
-        if not DEBUG:        
-            result = os.system(cmd)
+        run_and_check(cmd)            
         
         dbg_repodir = os.path.join(destdir, arch, 'debug')
         dbg_rpdata = os.path.join(dbg_repodir, 'repodata')
@@ -109,19 +105,13 @@
         
         print 'Cleaning up older packages'
         cmd = '/usr/bin/repomanage -k2 -o %s | xargs rm -f' % (repodir)
-        debugprint(cmd)
-        if not DEBUG:    
-            result = os.system(cmd)
+        run_and_check(cmd)                    
 
         cmd = '/usr/bin/createrepo -c %s -q %s' % (cachedir, dbg_repodir)
-        debugprint(cmd)
-        if not DEBUG:        
-            result = os.system(cmd)
+        run_and_check(cmd)            
             
         cmd = '/usr/bin/repoview %s' % dbg_repodir
-        debugprint(cmd)
-        if not DEBUG:        
-            result = os.system(cmd)
+        run_and_check(cmd)                    
             
     
 if __name__ == '__main__':




More information about the fedora-extras-commits mailing list