]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
debian_build.py: remove unused variables
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Tue, 26 Aug 2014 12:32:40 +0000 (14:32 +0200)
committerBenjamin Drung <benjamin.drung@profitbricks.com>
Tue, 26 Aug 2014 12:32:40 +0000 (14:32 +0200)
debian_build.py

index 5c7eb0894a6d04a286aee7b1cfb1ed1ba5099831..cc8dda7026dcbcc411845f1881f274dc520f09ac 100755 (executable)
@@ -140,7 +140,7 @@ def is_valid_debian_version(version):
     return is_valid
 
 
-def version_substitution(logger, pattern, git_commit=None):
+def version_substitution(logger, pattern, git_commit=None, time=None):
     """Return a version string with the pattern substituted.
 
     Following substitution variables are supported:
@@ -156,7 +156,10 @@ def version_substitution(logger, pattern, git_commit=None):
     subst = dict()
     if git_commit:
         subst['git-commit'] = git_commit.hexsha[0:7]
-    subst['time'] = datetime.datetime.utcnow()
+    if time is None:
+        subst['time'] = datetime.datetime.utcnow()
+    else:
+        subst['time'] = time
     if os.path.isfile('debian/changelog'):
         changelog_file = open('debian/changelog')
         changelog = debian.changelog.Changelog(changelog_file, max_blocks=1)
@@ -206,7 +209,7 @@ def main():
     # Act I: prepare variables
     # .. command line arguments
     # FIXME: not used right now, shall it be used?
-    options, args = getopts()
+    options = getopts()[0]
 
     # .. actions, define defaults
     do_autoincrement = False
@@ -236,14 +239,13 @@ def main():
             else:
                 gitrepo.remotes[name].update({git_type: url})
         #    this would also be helpful, but is not yet included in git lib
-        repo_name = re.sub('\.git$', '', gitrepo.remotes['origin']['fetch'].split('/')[-1])
+        repo_name = re.sub(r'\.git$', '', gitrepo.remotes['origin']['fetch'].split('/')[-1])
     else:
-        repo_name = re.sub('\.git$', '', gitrepo.remotes['origin'].url.split('/')[-1])
+        repo_name = re.sub(r'\.git$', '', gitrepo.remotes['origin'].url.split('/')[-1])
     logger.info('Remotes: %s' % gitrepo.remotes)
     logger.info('Repository Name: %s' % repo_name)
 
     # .. some local variables
-    daily_date = build_start.strftime('%Y%m%d%H%M%S')
     local_branch = re.match('^(origin/)?(.*)', ENV['GIT_BRANCH']).groups()[1]
     remote_branch = os.path.join('origin', local_branch)
 
@@ -262,7 +264,6 @@ def main():
     # .. content related
     changelog = debian.changelog.Changelog()
     changelog.parse_changelog(open('debian/changelog'))
-    curr_name = changelog.package
     curr_version = changelog.full_version
     curr_dist = changelog.distributions
 
@@ -359,7 +360,7 @@ def main():
         else:
             pattern = "{debversion}+develop{time:%Y%m%d+%H%M}+{build}+{git-commit}"
         pattern = re.sub('{build}', ENV['BUILD_NUMBER'], pattern) + options.version_suffix
-        new_version = version_substitution(logger, pattern, curr_commit)
+        new_version = version_substitution(logger, pattern, curr_commit, build_start)
         reprepro_base = '/srv/pb-{dist}'.format(dist=curr_dist)
         apt_target = "repo01-debian-dev"
         additional_repos = [
@@ -389,7 +390,7 @@ def main():
         else:
             pattern = "{debversion}+experimental{time:%Y%m%d+%H%M}+{build}+{git-commit}"
         pattern = re.sub('{build}', ENV['BUILD_NUMBER'], pattern) + options.version_suffix
-        new_version = version_substitution(logger, pattern, curr_commit)
+        new_version = version_substitution(logger, pattern, curr_commit, build_start)
         reprepro_base = '/srv/dev-{dist}'.format(dist=curr_dist)
         apt_target = "repo01-debian-dev"
         additional_repos = [
@@ -687,7 +688,7 @@ def main():
         failed_message = 'package build has failed'
         do_cidb = False
         no_cidb_cause = failed_message
-        do_liveboot = False
+        #do_liveboot = False
         no_liveboot_cause = failed_message
         do_uploads = False
         no_uploads_cause = failed_message
@@ -842,7 +843,7 @@ def main():
             try:
                 add_liveboot_request(package_instances)
                 figlet('Liveboot OK')
-            except:
+            except Exception:
                 logger.debug("liveboot request failed")
                 figlet('Liveboot failed')
                 exit_error()