From: Benjamin Drung Date: Tue, 4 Mar 2014 10:43:13 +0000 (+0100) Subject: debian_build.py: PEP 8 fixes. X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=41647962607e439cf006c55904429f9710f2daa7;p=profitbricks%2Fjenkins-build-scripts.git debian_build.py: PEP 8 fixes. --- diff --git a/debian_build.py b/debian_build.py index f786c2f..4486eae 100755 --- a/debian_build.py +++ b/debian_build.py @@ -19,8 +19,8 @@ from debian import changelog # import local modules from add_liveboot_request import add_liveboot_request -from common_code import figlet, logger_init, exit_ok, exit_error, ENV, \ - BIN_SUDO, BUILD_AREA, BIN_RM, BIN_DCH, BIN_GIT_DCH +from common_code import (figlet, logger_init, exit_ok, exit_error, ENV, BIN_SUDO, BUILD_AREA, + BIN_RM, BIN_DCH, BIN_GIT_DCH) from db_add import add_package_instances from lib import dput from lib import gitpkg @@ -28,7 +28,7 @@ from lib import pbuilder # from common_code -logger = logger_init(re.match('^(.*/jenkins_build_script/)(.*)',__file__).groups()[1]) +logger = logger_init(re.match('^(.*/jenkins_build_script/)(.*)', __file__).groups()[1]) # jenkins environment - parameters ENV.setdefault('NO_UPLOAD', '') @@ -129,13 +129,13 @@ if __name__ == '__main__': # .. repository related gitrepo = git.Repo('.') - if not hasattr(gitrepo,'remotes'): + if not hasattr(gitrepo, 'remotes'): # this should be part of 'git' lib, but it isn't right now gitrepo.remotes = {} for remote in gitrepo.git.remote('-v').split('\n'): name, url, type = remote.split() type = type.strip('()') - if not gitrepo.remotes.has_key(name): + if name not in gitrepo.remotes: gitrepo.remotes.update({name: {type: url}}) else: gitrepo.remotes[name].update({type: url}) @@ -170,7 +170,6 @@ if __name__ == '__main__': curr_version = cl.full_version curr_dist = cl.distributions - # Act II: make decissions # compatibility until call_jenkins was replaced if curr_dist not in ('squeeze', 'wheezy'): @@ -203,7 +202,8 @@ if __name__ == '__main__': do_liveboot_request = True # .. fail if we already found the tag we would create upon a successfull build, # except, the existing tag uses the same commit as we were triggered with - # FIXME: tagging only works for squeeze this way, change it to make it multipledist compatible + # FIXME: tagging only works for squeeze this way, change it to make it multipledist + # compatible remote_tag = [tag for tag in gitrepo.tags if tag.name == new_tag] if not do_autoincrement and len(remote_tag) > 0: # FIXME: .id attribute but avl. in wheezy based git lib @@ -277,7 +277,8 @@ if __name__ == '__main__': #FIXME: get rid of jenkins parameter, instead use git remote #if GIT_REPO_PATH.startswith('/srv/git/dev/'): # if ENV['GIT_BRANCH_NAME'] == 'pre-staging': - # version = '%s~develop%s+%s+%s' %(version, daily_date, BUILD_NUMBER, curr_commit_id[0:7]) + # version = '%s~develop%s+%s+%s' %(version, daily_date, BUILD_NUMBER, + # curr_commit_id[0:7]) # changelog_distro = 'pre-staging' # else: # # use shorter date because we can @@ -295,7 +296,8 @@ if __name__ == '__main__': 'login': 'reprepro', 'incoming': reprepro_base + '/incoming/profitbricks', 'allow_unsigned_uploads': 1, - 'post_upload_command': 'ssh reprepro@alexandria.pb.local ' + reprepro_base + '/bin/pb_processincoming', + 'post_upload_command': 'ssh reprepro@alexandria.pb.local ' + reprepro_base + + '/bin/pb_processincoming', } ) @@ -390,16 +392,14 @@ if __name__ == '__main__': logger.debug(gitrepo.git.checkout(dst_branch)) logger.debug(gitrepo.git.pull()) logger.debug(gitrepo.git.merge(src_branch)) - logger.info('Rebase and merge from branch "{src_branch}" completed. Now in "{dst_branch}".'.format( - dst_branch=dst_branch, - src_branch=src_branch, - )) + logger.info('Rebase and merge from branch "{src_branch}" completed. Now in ' + '"{dst_branch}".'.format(dst_branch=dst_branch, src_branch=src_branch)) except Exception as error: logger.error('Rebase has failed!\n\n%s\n' % error.stderr, exc_info=error) logger.debug(gitrepo.git.rebase('--abort')) - logger.debug(gitrepo.git.reset('--hard',src_branch)) + logger.debug(gitrepo.git.reset('--hard', src_branch)) if os.path.exists('.git/rebase-apply'): - subprocess.check_call(['rm','-rf','.git/rebase-apply']) + subprocess.check_call(['rm', '-rf', '.git/rebase-apply']) exit_error() if 'no-test' in build_triggers: @@ -412,7 +412,8 @@ if __name__ == '__main__': # .. NOW we can verify debian/control contents for line in fileinput.input('debian/control'): if line.lower().startswith('section: unknown'): - raise Exception('debian/control sets "section" to unknown. This is not allowed, failing...') + raise Exception('debian/control sets "section" to unknown. ' + 'This is not allowed, failing...') exit_error() # .. and update changelog if we trust the package @@ -430,7 +431,8 @@ if __name__ == '__main__': new_version = cl.full_version new_tag = new_version.replace('~', '_').replace(':', ',') except Exception as error: - logger.error('Autoincrement failed. Standard error returned:\n\n%s\n' % error.stderr, exc_info=error) + logger.error('Autoincrement failed. Standard error returned:\n\n%s\n' % + error.stderr, exc_info=error) exit_error() # .. or set approriate versions for our development candidates @@ -534,16 +536,14 @@ export {builder_env} FORCE_SHELL=TRUE ### Beware when using 'merge' trigger: The above command specifies the target ### branch already while you want to run on original branch '{orig_branch}'. ### -'''.format( - hostname=socket.gethostname(), - jenkins_user=ENV['USER'], - jenkins_workspace=ENV['WORKSPACE'], - builder_env=' '.join(['{k}="{v}"'.format(k=key, v=builder.env[key],) - for key in builder.env.keys() - ]), - command=' '.join(builder.command), - orig_branch=ENV['GIT_BRANCH'], - )) +'''.format(hostname=socket.gethostname(), + jenkins_user=ENV['USER'], + jenkins_workspace=ENV['WORKSPACE'], + builder_env=' '.join(['{k}="{v}"'.format(k=key, v=builder.env[key],) + for key in builder.env.keys()]), + command=' '.join(builder.command), + orig_branch=ENV['GIT_BRANCH'], + )) # .. and finally handle the result if ret: @@ -707,6 +707,6 @@ export {builder_env} FORCE_SHELL=TRUE exit_error() # finally, finished! - logger.info('---------------------------------------------------------------------------------------------------------') + logger.info('-' * 99) figlet('Success!!!') exit_ok()