diff --git a/client.py b/client.py index 214b038ffa71..60729dcd40a7 100755 --- a/client.py +++ b/client.py @@ -3,6 +3,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import, print_function LIBFFI_DIRS = (('js/ctypes/libffi', 'libffi'),) HG_EXCLUSIONS = ['.hg', '.hgignore', '.hgtags'] @@ -22,7 +23,7 @@ if topsrcdir == '': topsrcdir = '.' def check_call_noisy(cmd, *args, **kwargs): - print "Executing command:", cmd + print("Executing command:", cmd) check_call(cmd, *args, **kwargs) def do_hg_pull(dir, repository, hg): @@ -67,22 +68,22 @@ def do_cvs_export(modules, tag, cvsroot, cvs): cvs_module = module_tuple[1] fullpath = os.path.join(topsrcdir, module) if os.path.exists(fullpath): - print "Removing '%s'" % fullpath + print("Removing '%s'" % fullpath) shutil.rmtree(fullpath) (parent, leaf) = os.path.split(module) - print "CVS export begin: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC") + print("CVS export begin: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")) check_call_noisy([cvs, '-d', cvsroot, 'export', '-r', tag, '-d', leaf, cvs_module], cwd=os.path.join(topsrcdir, parent)) - print "CVS export end: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC") + print("CVS export end: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")) def toggle_trailing_blank_line(depname): """If the trailing line is empty, then we'll delete it. Otherwise we'll add a blank line.""" lines = open(depname, "r").readlines() if not lines: - print >>sys.stderr, "unexpected short file" + print("unexpected short file", file=sys.stderr) return if not lines[-1].strip(): @@ -95,7 +96,7 @@ def toggle_trailing_blank_line(depname): def get_trailing_blank_line_state(depname): lines = open(depname, "r").readlines() if not lines: - print >>sys.stderr, "unexpected short file" + print("unexpected short file", file=sys.stderr) return "no blank line" if not lines[-1].strip(): @@ -108,25 +109,26 @@ def update_nspr_or_nss(tag, depfile, destination, hgpath): permanent_patch_dir = destination + '/patches' temporary_patch_dir = destination + '.patches' if os.path.exists(temporary_patch_dir): - print "please clean up leftover directory " + temporary_patch_dir + print("please clean up leftover directory " + temporary_patch_dir) sys.exit(2) warn_if_patch_exists(permanent_patch_dir) # protect patch directory from being removed by do_hg_replace if os.path.exists(permanent_patch_dir): shutil.move(permanent_patch_dir, temporary_patch_dir) # now update the destination - print "reverting to HG version of %s to get its blank line state" % depfile + print("reverting to HG version of %s to get its blank line state" % depfile) check_call_noisy([options.hg, 'revert', depfile]) old_state = get_trailing_blank_line_state(depfile) - print "old state of %s is: %s" % (depfile, old_state) + print("old state of %s is: %s" % (depfile, old_state)) do_hg_replace(destination, hgpath, tag, HG_EXCLUSIONS, options.hg) new_state = get_trailing_blank_line_state(depfile) - print "new state of %s is: %s" % (depfile, new_state) + print("new state of %s is: %s" % (depfile, new_state)) if old_state == new_state: - print "toggling blank line in: ", depfile + print("toggling blank line in: ", depfile) toggle_trailing_blank_line(depfile) tag_file = destination + "/TAG-INFO" - print >>file(tag_file, "w"), tag + with open(tag_file, 'w') as f: + f.write(tag) # move patch directory back to a subdirectory if os.path.exists(temporary_patch_dir): shutil.move(temporary_patch_dir, permanent_patch_dir) @@ -135,12 +137,12 @@ def warn_if_patch_exists(path): # If the given patch directory exists and contains at least one file, # then print warning and wait for the user to acknowledge. if os.path.isdir(path) and os.listdir(path): - print "========================================" - print "WARNING: At least one patch file exists" - print "in directory: " + path - print "You must manually re-apply all patches" - print "after this script has completed!" - print "========================================" + print("========================================") + print("WARNING: At least one patch file exists") + print("in directory: " + path) + print("You must manually re-apply all patches") + print("after this script has completed!") + print("========================================") raw_input("Press Enter to continue...") return diff --git a/tools/lint/py2.yml b/tools/lint/py2.yml index 1b241538390a..6d328af8cba2 100644 --- a/tools/lint/py2.yml +++ b/tools/lint/py2.yml @@ -4,7 +4,6 @@ py2: include: ['.'] exclude: - build - - client.py - dom - editor - gfx diff --git a/tools/lint/py3.yml b/tools/lint/py3.yml index 10d65400b913..b0fa00c1af17 100644 --- a/tools/lint/py3.yml +++ b/tools/lint/py3.yml @@ -5,7 +5,6 @@ py3: exclude: - browser/app - build - - client.py - dom/canvas/test - gfx - ipc/ipdl