From: Holger Levsen Date: Wed, 16 May 2012 12:14:08 +0000 (+0200) Subject: handle situations when build-area does not exist yet X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=68527ebab35ace9587c2f31bbdf6cada28b844f3;p=profitbricks%2Fjenkins-build-scripts.git handle situations when build-area does not exist yet --- diff --git a/debian_build.py b/debian_build.py index 8bd1f09..35959b1 100755 --- a/debian_build.py +++ b/debian_build.py @@ -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))