[releng] fedretire: Refactor command running

Till Maas till at fedoraproject.org
Wed Nov 5 17:45:29 UTC 2014


commit 632559b8b80ffb947e29db4a5de4832b7b2779c6
Author: Till Maas <opensource at till.name>
Date:   Wed Nov 5 18:44:24 2014 +0100

    fedretire: Refactor command running

 scripts/fedretire |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/scripts/fedretire b/scripts/fedretire
index 243c1f5..9b516e8 100755
--- a/scripts/fedretire
+++ b/scripts/fedretire
@@ -10,26 +10,24 @@ import tempfile
 
 
 def retire(pkg, branch, reason, dryrun=False):
-    tempdir = tempfile.mkdtemp(pkg, branch)
-    try:
-        cmd = ["fedpkg", "clone", pkg]
+    def run(cmd, cwd):
         if dryrun:
             print(cmd)
         else:
-            subprocess.check_call(cmd, cwd=tempdir)
+            return subprocess.check_call(cmd, cwd=cwd)
+
+    tempdir = tempfile.mkdtemp(pkg, branch)
+    try:
+        cmd = ["fedpkg", "clone", pkg]
+        run(cmd, tempdir)
+
         pkgdir = os.path.join(tempdir, pkg)
 
         cmd = ["fedpkg", "switch-branch", branch]
-        if dryrun:
-            print(cmd)
-        else:
-            subprocess.check_call(cmd, cwd=pkgdir)
+        run(cmd, pkgdir)
 
         cmd = ["fedpkg", "retire", reason]
-        if dryrun:
-            print(cmd)
-        else:
-            subprocess.check_call(cmd, cwd=pkgdir)
+        run(cmd, pkgdir)
     finally:
         shutil.rmtree(tempdir)
 


More information about the rel-eng mailing list