Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion configure.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
Comment thread
cclauss marked this conversation as resolved.
import json
import sys
import errno
Expand Down Expand Up @@ -594,7 +595,7 @@ def print_verbose(x):
if not options.verbose:
return
if type(x) is str:
print x
print(x)
else:
pprint.pprint(x, indent=2)

Expand Down
3 changes: 2 additions & 1 deletion deps/openssl/openssl/fuzz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

fuzzer.py <fuzzer> <extra fuzzer arguments>
"""
from __future__ import print_function

import os
import subprocess
Expand Down Expand Up @@ -45,7 +46,7 @@ def main():

cmd = ([os.path.abspath(os.path.join(THIS_DIR, FUZZER))] + sys.argv[2:]
+ ["-artifact_prefix=" + corpora[1] + "/"] + corpora)
print " ".join(cmd)
print(" ".join(cmd))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged in upstream in openssl/openssl#7409 but retained here because openssl in not pip installed but is vendored in.

subprocess.call(cmd)

if __name__ == "__main__":
Expand Down
37 changes: 25 additions & 12 deletions test/message/testcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,26 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from __future__ import print_function

import test
import os
from os.path import join, exists, basename, isdir
import re

try:
reduce # Python 2
except NameError: # Python 3
from functools import reduce

try:
xrange # Python 2
except NameError:
xrange = range # Python 3

FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")


class MessageTestCase(test.TestCase):

def __init__(self, path, file, expected, arch, mode, context, config):
Expand All @@ -48,7 +61,7 @@ def IgnoreLine(self, str):
else: return str.startswith('==') or str.startswith('**')

def IsFailureOutput(self, output):
f = file(self.expected)
f = open(self.expected)
# Skip initial '#' comment and spaces
#for line in f:
# if (not line.startswith('#')) and (not line.strip()):
Expand All @@ -67,22 +80,22 @@ def IsFailureOutput(self, output):
raw_lines = (output.stdout + output.stderr).split('\n')
outlines = [ s for s in raw_lines if not self.IgnoreLine(s) ]
if len(outlines) != len(patterns):
print "length differs."
print "expect=%d" % len(patterns)
print "actual=%d" % len(outlines)
print "patterns:"
print("length differs.")
print("expect=%d" % len(patterns))
print("actual=%d" % len(outlines))
print("patterns:")
for i in xrange(len(patterns)):
print "pattern = %s" % patterns[i]
print "outlines:"
print("pattern = %s" % patterns[i])
print("outlines:")
for i in xrange(len(outlines)):
print "outline = %s" % outlines[i]
print("outline = %s" % outlines[i])
return True
for i in xrange(len(patterns)):
if not re.match(patterns[i], outlines[i]):
print "match failed"
print "line=%d" % i
print "expect=%s" % patterns[i]
print "actual=%s" % outlines[i]
print("match failed")
print("line=%d" % i)
print("expect=%s" % patterns[i])
print("actual=%s" % outlines[i])
return True
return False

Expand Down
35 changes: 23 additions & 12 deletions test/pseudo-tty/testcfg.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
# Copyright 2008 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -31,6 +32,16 @@
import re
import utils

try:
reduce # Python 2
except NameError: # Python 3
from functools import reduce

try:
xrange # Python 2
except NameError:
xrange = range # Python 3

FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")

class TTYTestCase(test.TestCase):
Expand All @@ -50,7 +61,7 @@ def IgnoreLine(self, str):
else: return str.startswith('==') or str.startswith('**')

def IsFailureOutput(self, output):
f = file(self.expected)
f = open(self.expected)
# Convert output lines to regexps that we can match
env = { 'basename': basename(self.file) }
patterns = [ ]
Expand All @@ -65,22 +76,22 @@ def IsFailureOutput(self, output):
raw_lines = (output.stdout + output.stderr).split('\n')
outlines = [ s.strip() for s in raw_lines if not self.IgnoreLine(s) ]
if len(outlines) != len(patterns):
print "length differs."
print "expect=%d" % len(patterns)
print "actual=%d" % len(outlines)
print "patterns:"
print("length differs.")
print("expect=%d" % len(patterns))
print("actual=%d" % len(outlines))
print("patterns:")
for i in xrange(len(patterns)):
print "pattern = %s" % patterns[i]
print "outlines:"
print("pattern = %s" % patterns[i])
print("outlines:")
for i in xrange(len(outlines)):
print "outline = %s" % outlines[i]
print("outline = %s" % outlines[i])
return True
for i in xrange(len(patterns)):
if not re.match(patterns[i], outlines[i]):
print "match failed"
print "line=%d" % i
print "expect=%s" % patterns[i]
print "actual=%s" % outlines[i]
print("match failed")
print("line=%d" % i)
print("expect=%s" % patterns[i])
print("actual=%s" % outlines[i])
return True
return False

Expand Down
5 changes: 5 additions & 0 deletions test/testpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
# Copyright 2008 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -31,6 +32,10 @@
import re
import ast

try:
reduce # Python 2
except NameError: # Python 3
from functools import reduce

FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
Expand Down
6 changes: 6 additions & 0 deletions tools/compress_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
import sys
import zlib

try:
xrange # Python 2
except NameError:
xrange = range # Python 3


if __name__ == '__main__':
fp = open(sys.argv[1])
obj = json.load(fp)
Expand Down
15 changes: 8 additions & 7 deletions tools/configure.d/nodedownload.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# Moved some utilities here from ../../configure

from __future__ import print_function
import urllib
import hashlib
import sys
Expand Down Expand Up @@ -36,10 +37,10 @@ def retrievefile(url, targetfile):
sys.stdout.write(' <%s>\nConnecting...\r' % url)
sys.stdout.flush()
ConfigOpener().retrieve(url, targetfile, reporthook=reporthook)
print '' # clear the line
print('') # clear the line
return targetfile
except:
print ' ** Error occurred while downloading\n <%s>' % url
print(' ** Error occurred while downloading\n <%s>' % url)
Comment thread
cclauss marked this conversation as resolved.
raise

def md5sum(targetfile):
Expand All @@ -56,12 +57,12 @@ def unpack(packedfile, parent_path):
"""Unpacks packedfile into parent_path. Assumes .zip. Returns parent_path"""
if zipfile.is_zipfile(packedfile):
with contextlib.closing(zipfile.ZipFile(packedfile, 'r')) as icuzip:
print ' Extracting zipfile: %s' % packedfile
print(' Extracting zipfile: %s' % packedfile)
icuzip.extractall(parent_path)
return parent_path
elif tarfile.is_tarfile(packedfile):
with contextlib.closing(tarfile.TarFile.open(packedfile, 'r')) as icuzip:
print ' Extracting tarfile: %s' % packedfile
print(' Extracting tarfile: %s' % packedfile)
icuzip.extractall(parent_path)
return parent_path
else:
Expand Down Expand Up @@ -112,7 +113,7 @@ def parse(opt):
theRet[anOpt] = True
else:
# future proof: ignore unknown types
print 'Warning: ignoring unknown --download= type "%s"' % anOpt
print('Warning: ignoring unknown --download= type "%s"' % anOpt)
# all done
return theRet

Expand All @@ -122,6 +123,6 @@ def candownload(auto_downloads, package):
if auto_downloads[package]:
return True
else:
print """Warning: Not downloading package "%s". You could pass "--download=all"
(Windows: "download-all") to try auto-downloading it.""" % package
print("""Warning: Not downloading package "%s". You could pass "--download=all"
(Windows: "download-all") to try auto-downloading it.""" % package)
return False
13 changes: 7 additions & 6 deletions tools/genv8constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,29 @@
# ustack helper.
#

from __future__ import print_function
import re
import subprocess
import sys
import errno

if len(sys.argv) != 3:
print "usage: objsym.py outfile libv8_base.a"
print("usage: objsym.py outfile libv8_base.a")
sys.exit(2);

outfile = file(sys.argv[1], 'w');
outfile = open(sys.argv[1], 'w');
try:
pipe = subprocess.Popen([ 'objdump', '-z', '-D', sys.argv[2] ],
bufsize=-1, stdout=subprocess.PIPE).stdout;
except OSError, e:
except OSError as e:
if e.errno == errno.ENOENT:
print '''
print('''
Node.js compile error: could not find objdump

Check that GNU binutils are installed and included in PATH
'''
''')
else:
print 'problem running objdump: ', e.strerror
print('problem running objdump: ', e.strerror)

sys.exit()

Expand Down
1 change: 1 addition & 0 deletions tools/getnodeversion.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import os
import re

Expand Down
4 changes: 4 additions & 0 deletions tools/gyp/PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
for more details about the presubmit API built into gcl.
"""

try:
xrange # Python 2
except NameError:
xrange = range # Python 3

PYLINT_BLACKLIST = [
# TODO: fix me.
Expand Down
23 changes: 12 additions & 11 deletions tools/gyp/buildbot/buildbot_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# found in the LICENSE file.

"""Argument-less script to select what to run on the buildbots."""
from __future__ import print_function

import os
import shutil
Expand All @@ -24,25 +25,25 @@ def CallSubProcess(*args, **kwargs):
with open(os.devnull) as devnull_fd:
retcode = subprocess.call(stdin=devnull_fd, *args, **kwargs)
if retcode != 0:
print '@@@STEP_EXCEPTION@@@'
print('@@@STEP_EXCEPTION@@@')
sys.exit(1)


def PrepareCmake():
"""Build CMake 2.8.8 since the version in Precise is 2.8.7."""
if os.environ['BUILDBOT_CLOBBER'] == '1':
print '@@@BUILD_STEP Clobber CMake checkout@@@'
print('@@@BUILD_STEP Clobber CMake checkout@@@')
shutil.rmtree(CMAKE_DIR)

# We always build CMake 2.8.8, so no need to do anything
# if the directory already exists.
if os.path.isdir(CMAKE_DIR):
return

print '@@@BUILD_STEP Initialize CMake checkout@@@'
print('@@@BUILD_STEP Initialize CMake checkout@@@')
os.mkdir(CMAKE_DIR)

print '@@@BUILD_STEP Sync CMake@@@'
print('@@@BUILD_STEP Sync CMake@@@')
CallSubProcess(
['git', 'clone',
'--depth', '1',
Expand All @@ -53,7 +54,7 @@ def PrepareCmake():
CMAKE_DIR],
cwd=CMAKE_DIR)

print '@@@BUILD_STEP Build CMake@@@'
print('@@@BUILD_STEP Build CMake@@@')
CallSubProcess(
['/bin/bash', 'bootstrap', '--prefix=%s' % CMAKE_DIR],
cwd=CMAKE_DIR)
Expand All @@ -74,7 +75,7 @@ def GypTestFormat(title, format=None, msvs_version=None, tests=[]):
if not format:
format = title

print '@@@BUILD_STEP ' + title + '@@@'
print('@@@BUILD_STEP ' + title + '@@@')
sys.stdout.flush()
env = os.environ.copy()
if msvs_version:
Expand All @@ -89,17 +90,17 @@ def GypTestFormat(title, format=None, msvs_version=None, tests=[]):
retcode = subprocess.call(command, cwd=ROOT_DIR, env=env, shell=True)
if retcode:
# Emit failure tag, and keep going.
print '@@@STEP_FAILURE@@@'
print('@@@STEP_FAILURE@@@')
return 1
return 0


def GypBuild():
# Dump out/ directory.
print '@@@BUILD_STEP cleanup@@@'
print 'Removing %s...' % OUT_DIR
print('@@@BUILD_STEP cleanup@@@')
print('Removing %s...' % OUT_DIR)
shutil.rmtree(OUT_DIR, ignore_errors=True)
print 'Done.'
print('Done.')

retcode = 0
if sys.platform.startswith('linux'):
Expand Down Expand Up @@ -128,7 +129,7 @@ def GypBuild():
# after the build proper that could be used for cumulative failures),
# use that instead of this. This isolates the final return value so
# that it isn't misattributed to the last stage.
print '@@@BUILD_STEP failures@@@'
print('@@@BUILD_STEP failures@@@')
sys.exit(retcode)


Expand Down
2 changes: 1 addition & 1 deletion tools/gyp/gyptest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def main(argv=None):
os.chdir(args.chdir)

if args.path:
extra_path = [os.path.abspath(p) for p in opts.path]
extra_path = [os.path.abspath(p) for p in args.path]
extra_path = os.pathsep.join(extra_path)
os.environ['PATH'] = extra_path + os.pathsep + os.environ['PATH']

Expand Down
Loading