From c1a18e3ce944a7e47a96b84f349a03ad7d07f6da Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Thu, 20 Sep 2012 13:36:08 +0200 Subject: [PATCH] handle errors properly --- debian_build.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/debian_build.py b/debian_build.py index 2186313..21bb67c 100755 --- a/debian_build.py +++ b/debian_build.py @@ -130,8 +130,7 @@ def db_add_job(con, name): cur = con.cursor() cur.execute("SAVEPOINT a") try: - cur.execute("INSERT INTO jenkins_job(name) VALUES(%s)" - " RETURNING id", (name)) + cur.execute("INSERT INTO jenkins_job(name) VALUES(%s)") logger.debug("saved %s to databased" %(job_name)) except psycopg2.DatabaseError as e: # record already exist @@ -604,7 +603,6 @@ if __name__ == '__main__': # upload (if NO_UPLOAD is not set) if NO_UPLOAD not in ('true', 'True'): dput_package_upload(changes_file) - add_package_instance("profitbricks", BUILD_JOBNAME, BUILD_NUMBER, changes_file, version) else: logger.debug('value of NO_UPLOAD: %s' % NO_UPLOAD) logger.info('dist: %s' %(pb_suite)) @@ -613,15 +611,21 @@ if __name__ == '__main__': logger.info('version: %s' %(version)) cmd = ['figlet-figlet', '-t', 'version: %s' %(version)] subprocess.check_call(cmd) - logger.info('---------------------------------------------------------------------------------------------------------') - cmd = ['figlet-figlet', '-t', 'Success!!!'] - subprocess.check_call(cmd) except Exception, error: cmd = ['figlet-figlet', '-t', 'upload to reprepro failed:'] subprocess.check_call(cmd) logger.exception(error) exit_error() + logger.info('---------------------------------------------------------------------------------------------------------') + cmd = ['figlet-figlet', '-t', 'Success!!!'] + subprocess.check_call(cmd) + try: + add_package_instance("profitbricks", BUILD_JOBNAME, BUILD_NUMBER, changes_file, version) + except Exception, error: + cmd = ['figlet-figlet', '-t', 'package instance not added to DB'] + subprocess.check_call(cmd) + exit_error() # finally exit_ok() -- 2.39.5