Bug 1612632 - Port nspr-release-helper.py to python3. r=jcj default tip
authorKai Engert <kaie@kuix.de>
Mon, 10 Feb 2020 20:58:42 +0000
changeset 4865 219d131499d57b02c0ed9b788dbeffd7e75e2fe4
parent 4864 794e7f46995d28c8aceaa12d14508aa9a7cbc2c5
push id360
push userkaie@kuix.de
push dateMon, 10 Feb 2020 21:23:26 +0000
reviewersjcj
bugs1612632
Bug 1612632 - Port nspr-release-helper.py to python3. r=jcj Differential Revision: https://phabricator.services.mozilla.com/D61382
automation/release/nspr-release-helper.py
--- a/automation/release/nspr-release-helper.py
+++ b/automation/release/nspr-release-helper.py
@@ -12,69 +12,69 @@ import glob
 from optparse import OptionParser
 from subprocess import check_call
 
 prinit_h = "pr/include/prinit.h"
 f_conf = "configure"
 f_conf_in = "configure.in"
 
 def check_call_noisy(cmd, *args, **kwargs):
-    print "Executing command:", cmd
+    print("Executing command:", cmd)
     check_call(cmd, *args, **kwargs)
 
 o = OptionParser(usage="client.py [options] remove_beta | set_beta | print_library_versions | set_version_to_minor_release | set_version_to_patch_release | create_nspr_release_archive")
 
 try:
     options, args = o.parse_args()
     action = args[0]
 except IndexError:
     o.print_help()
     sys.exit(2)
 
 def exit_with_failure(what):
-    print "failure: ", what
+    print("failure: ", what)
     sys.exit(2)
 
 def check_files_exist():
     if (not os.path.exists(prinit_h)):
         exit_with_failure("cannot find expected header files, must run from inside NSPR hg directory")
 
 def sed_inplace(sed_expression, filename):
     backup_file = filename + '.tmp'
     check_call_noisy(["sed", "-i.tmp", sed_expression, filename])
     os.remove(backup_file)
 
 def toggle_beta_status(is_beta):
     check_files_exist()
     if (is_beta):
-        print "adding Beta status to version numbers"
+        print("adding Beta status to version numbers")
         sed_inplace('s/^\(#define *PR_VERSION *\"[0-9.]\+\)\" *$/\\1 Beta\"/', prinit_h)
         sed_inplace('s/^\(#define *PR_BETA *\)PR_FALSE *$/\\1PR_TRUE/', prinit_h)
 
     else:
-        print "removing Beta status from version numbers"
+        print("removing Beta status from version numbers")
         sed_inplace('s/^\(#define *PR_VERSION *\"[0-9.]\+\) *Beta\" *$/\\1\"/', prinit_h)
         sed_inplace('s/^\(#define *PR_BETA *\)PR_TRUE *$/\\1PR_FALSE/', prinit_h)
-    print "please run 'hg stat' and 'hg diff' to verify the files have been verified correctly"
+    print("please run 'hg stat' and 'hg diff' to verify the files have been verified correctly")
 
 def print_beta_versions():
     check_call_noisy(["egrep", "#define *PR_VERSION|#define *PR_BETA", prinit_h])
 
 def remove_beta_status():
-    print "--- removing beta flags. Existing versions were:"
+    print("--- removing beta flags. Existing versions were:")
     print_beta_versions()
     toggle_beta_status(False)
-    print "--- finished modifications, new versions are:"
+    print("--- finished modifications, new versions are:")
     print_beta_versions()
 
 def set_beta_status():
-    print "--- adding beta flags. Existing versions were:"
+    print("--- adding beta flags. Existing versions were:")
     print_beta_versions()
     toggle_beta_status(True)
-    print "--- finished modifications, new versions are:"
+    print("--- finished modifications, new versions are:")
     print_beta_versions()
 
 def print_library_versions():
     check_files_exist()
     check_call_noisy(["egrep", "#define *PR_VERSION|#define PR_VMAJOR|#define *PR_VMINOR|#define *PR_VPATCH|#define *PR_BETA", prinit_h])
 
 def ensure_arguments_after_action(how_many, usage):
     if (len(sys.argv) != (2+how_many)):
@@ -98,27 +98,27 @@ def set_patch_versions(patch):
 def set_full_lib_versions(version):
     sed_inplace('s/^\(#define *PR_VERSION *\"\)\([0-9.]\+\)\(.*\)$/\\1' + version + '\\3/', prinit_h)
 
 def set_all_lib_versions(version, major, minor, patch):
     set_full_lib_versions(version)
     set_major_versions(major)
     set_minor_versions(minor)
     set_patch_versions(patch)
-    print
-    print "==========================="
-    print "======== ATTENTION ========"
-    print
-    print "You *MUST* manually edit file pr/tests/vercheck.c"
-    print
-    print "Edit two arrays, named compatible_version and incompatible_version"
-    print "according to the new version you're adding."
-    print
-    print "======== ATTENTION ========"
-    print "==========================="
+    print()
+    print("===========================")
+    print("======== ATTENTION ========")
+    print()
+    print("You *MUST* manually edit file pr/tests/vercheck.c")
+    print()
+    print("Edit two arrays, named compatible_version and incompatible_version")
+    print("according to the new version you're adding.")
+    print()
+    print("======== ATTENTION ========")
+    print("===========================")
 
 def set_version_to_minor_release():
     ensure_arguments_after_action(2, "major_version  minor_version")
     major = args[1].strip()
     minor = args[2].strip()
     version = major + '.' + minor
     patch = "0"
     set_all_lib_versions(version, major, minor, patch)
@@ -139,22 +139,22 @@ def create_nspr_release_archive():
     nspr_tar = "nspr-" + nsprrel + ".tar.gz"
     nspr_stagedir="../stage/v" + nsprrel + "/src"
     if (os.path.exists(nspr_stagedir)):
         exit_with_failure("nspr stage directory already exists: " + nspr_stagedir)
 
     check_call_noisy(["mkdir", "-p", nspr_stagedir])
     check_call_noisy(["hg", "archive", "-r", nsprreltag, "--prefix=nspr-" + nsprrel + "/nspr",
                       "../stage/v" + nsprrel + "/src/" + nspr_tar, "-X", ".hgtags"])
-    print "changing to directory " + nspr_stagedir
+    print("changing to directory " + nspr_stagedir)
     os.chdir(nspr_stagedir)
 
     check_call("sha1sum " + nspr_tar + " > SHA1SUMS", shell=True)
     check_call("sha256sum " + nspr_tar + " > SHA256SUMS", shell=True)
-    print "created directory " + nspr_stagedir + " with files:"
+    print("created directory " + nspr_stagedir + " with files:")
     check_call_noisy(["ls", "-l"])
 
 if action in ('remove_beta'):
     remove_beta_status()
 
 elif action in ('set_beta'):
     set_beta_status()