From bc1a4afb1ea98ccd6834c8a202897287452f5c88 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Tue, 6 Sep 2011 11:09:19 +0200 Subject: [PATCH] dont use atexit as we cannot unregister it (only in python 3.1...), better error handling --- build.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/build.py b/build.py index d12688a..834ec33 100755 --- a/build.py +++ b/build.py @@ -210,6 +210,7 @@ def remove_git_target_workspace(): return cmdobj def exit_ok(): + remove_git_target_workspace() send_email(SMTP_BUILD_SUCCESS) sys.exit(0) @@ -250,7 +251,7 @@ if __name__ == '__main__': logger.info('git clone was not successfull') exit_error() - atexit.register(remove_git_target_workspace) + #atexit.register(remove_git_target_workspace) os.chdir(GIT_TARGET_DIR) if GIT_UPSTREAM_BRANCH != GIT_DEBIAN_BRANCH: @@ -355,11 +356,16 @@ if __name__ == '__main__': cmd, shell=False, close_fds=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + stdout=sys.stdout, + stderr=sys.stderr, cwd='./' ) ret = parse_changelog.wait() + if ret: + raise Exception( + '%s was not successfull, return code was %s ' % (' '.join(cmd), ret) + exit_error() + ) cmd = ['grep-dctrl', '-n', '-s', 'Version', ''] grep_dctrl = subprocess.Popen( @@ -367,17 +373,23 @@ if __name__ == '__main__': shell=False, close_fds=True, stdin=parse_changelog.stdout, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + stdout=sys.stdout, + stderr=sys.stderr, cwd=os.getcwd() ) ret = grep_dctrl.wait() + if ret: + raise Exception( + '%s was not successfull, return code was %s ' % (' '.join(cmd), ret) + exit_error() + ) + version = grep_dctrl.stdout.read() version = version.strip() logger.info('version is %s' % (version)) - stdout_msg = parse_changelog.stdout.read() - logger.info(stdout_msg) + #stdout_msg = parse_changelog.stdout.read() + #logger.info(stdout_msg) if not GIT_COMMITTER_EMAIL: @@ -412,7 +424,6 @@ if __name__ == '__main__': fh.close() except: pass - atexit.unregister(remove_git_target_workspace) exit_error() else: create_dput_cfg() -- 2.39.5