]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
handle situations when build-area does not exist yet
authorHolger Levsen <holger@layer-acht.org>
Wed, 16 May 2012 12:14:08 +0000 (14:14 +0200)
committerHolger Levsen <holger@layer-acht.org>
Wed, 16 May 2012 12:14:08 +0000 (14:14 +0200)
debian_build.py

index 8bd1f098c1625ddaaf1775898ff221baa4af6573..35959b1e927c18dc4feb9919851b906cdd2142a5 100755 (executable)
@@ -427,31 +427,32 @@ if __name__ == '__main__':
          raise Exception('unhandled branch, failing.')
 
     # cleanup existing *orig.tar.gz
-    files = " ".join(fnmatch.filter(os.listdir('../build-area/'),'*.orig.tar.gz'))
-    cmd = [BIN_SUDO, BIN_RM, '-f', files]
-    cmdobj = subprocess.Popen(
-            cmd,
-            shell=False,
-            cwd='/',
-            close_fds=True,
-            stdout=sys.stdout,
-            stderr=sys.stderr,
-            env={'':''}
-    )
-
-    logger.debug(
-            'Trying to call "%s"'
-            %(' '.join(cmd))
-    )
-
-    ret = cmdobj.wait()
-    if ret:
-        _str = (
-                'Cmd "%s" returned non-zero (exitcode: %s).'
-                %(' '.join(cmd), ret)
+    if os.os.path.isdir('../build-area/'):
+        files = " ".join(fnmatch.filter(os.listdir('../build-area/'),'*.orig.tar.gz'))
+        cmd = [BIN_SUDO, BIN_RM, '-f', files]
+        cmdobj = subprocess.Popen(
+                cmd,
+                shell=False,
+                cwd='/',
+                close_fds=True,
+                stdout=sys.stdout,
+                stderr=sys.stderr,
+                env={'':''}
+        )
+    
+        logger.debug(
+                'Trying to call "%s"'
+                %(' '.join(cmd))
         )
-        logger.debug(_str)
-        raise Exception(_str)
+    
+        ret = cmdobj.wait()
+        if ret:
+            _str = (
+                    'Cmd "%s" returned non-zero (exitcode: %s).'
+                    %(' '.join(cmd), ret)
+            )
+            logger.debug(_str)
+            raise Exception(_str)
 
 
     logger.info('dist: %s' %(pb_suite))