summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/Command.py7
-rw-r--r--bin/SConsDoc.py45
-rw-r--r--bin/SConsExamples.py164
-rw-r--r--bin/calibrate.py8
-rw-r--r--bin/caller-tree.py11
-rw-r--r--bin/docs-create-example-outputs.py9
-rw-r--r--bin/docs-update-generated.py3
-rw-r--r--bin/docs-validate.py9
-rw-r--r--bin/import-test.py4
-rw-r--r--bin/install_python.py7
-rw-r--r--bin/install_scons.py12
-rw-r--r--bin/linecount.py34
-rw-r--r--bin/memlogs.py10
-rw-r--r--bin/memoicmp.py30
-rw-r--r--bin/objcounts.py14
-rw-r--r--bin/restore.sh28
-rw-r--r--bin/scons-diff.py15
-rw-r--r--bin/scons-proc.py25
-rw-r--r--bin/scons-test.py65
-rw-r--r--bin/scons-unzip.py3
-rw-r--r--bin/scons_dev_master.py26
-rw-r--r--bin/sfsum11
-rwxr-xr-xbin/svn-bisect.py14
-rw-r--r--bin/update-release-info.py35
-rwxr-xr-xbin/xmlagenda.py3
25 files changed, 316 insertions, 276 deletions
diff --git a/bin/Command.py b/bin/Command.py
index 8702f51..dadd7a9 100644
--- a/bin/Command.py
+++ b/bin/Command.py
@@ -4,6 +4,7 @@
#
# XXX Describe what the script does here.
#
+from __future__ import print_function
import getopt
import os
@@ -109,18 +110,18 @@ Usage: script-template.py [-hnq]
try:
try:
opts, args = getopt.getopt(argv[1:], short_options, long_options)
- except getopt.error, msg:
+ except getopt.error as msg:
raise Usage(msg)
for o, a in opts:
if o in ('-h', '--help'):
- print helpstr
+ print(helpstr)
sys.exit(0)
elif o in ('-n', '--no-exec'):
Command.execute = Command.do_not_execute
elif o in ('-q', '--quiet'):
Command.display = Command.do_not_display
- except Usage, err:
+ except Usage as err:
sys.stderr.write(err.msg)
sys.stderr.write('use -h to get help')
return 2
diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py
index ff8a312..cfb4e54 100644
--- a/bin/SConsDoc.py
+++ b/bin/SConsDoc.py
@@ -24,6 +24,7 @@
#
# Module for handling SCons documentation processing.
#
+from __future__ import print_function
__doc__ = """
This module parses home-brew XML files that document various things
@@ -51,7 +52,7 @@ Builder example:
to indicate a new paragraph.
<example>
- print "this is example code, it will be offset and indented"
+ print("this is example code, it will be offset and indented")
</example>
</summary>
</builder>
@@ -71,7 +72,7 @@ Function example:
&f-FUNCTION; element. It need not be on a line by itself.</para>
<example>
- print "this is example code, it will be offset and indented"
+ print("this is example code, it will be offset and indented")
</example>
</summary>
</scons_function>
@@ -88,7 +89,7 @@ Construction variable example:
&t-VARIABLE; element. It need not be on a line by itself.</para>
<example>
- print "this is example code, it will be offset and indented"
+ print("this is example code, it will be offset and indented")
</example>
</summary>
</cvar>
@@ -105,7 +106,7 @@ Tool example:
&t-TOOL; element. It need not be on a line by itself.</para>
<example>
- print "this is example code, it will be offset and indented"
+ print("this is example code, it will be offset and indented")
</example>
</summary>
</tool>
@@ -167,7 +168,7 @@ xsi = "http://www.w3.org/2001/XMLSchema-instance"
# Header comment with copyright
copyright_comment = """
-Copyright (c) 2001 - 2016 The SCons Foundation
+Copyright (c) 2001 - 2017 The SCons Foundation
This file is processed by the bin/SConsDoc.py module.
See its __doc__ string for a discussion of the format.
@@ -208,12 +209,12 @@ class Libxml2ValidityHandler:
def error(self, msg, data):
if data != ARG:
- raise Exception, "Error handler did not receive correct argument"
+ raise Exception("Error handler did not receive correct argument")
self.errors.append(msg)
def warning(self, msg, data):
if data != ARG:
- raise Exception, "Warning handler did not receive correct argument"
+ raise Exception("Warning handler did not receive correct argument")
self.warnings.append(msg)
@@ -330,16 +331,16 @@ if not has_libxml2:
xmlschema = etree.XMLSchema(xmlschema_context)
try:
doc = etree.parse(fpath)
- except Exception, e:
- print "ERROR: %s fails to parse:"%fpath
- print e
+ except Exception as e:
+ print("ERROR: %s fails to parse:"%fpath)
+ print(e)
return False
doc.xinclude()
try:
xmlschema.assertValid(doc)
- except Exception, e:
- print "ERROR: %s fails to validate:" % fpath
- print e
+ except Exception as e:
+ print("ERROR: %s fails to validate:" % fpath)
+ print(e)
return False
return True
@@ -475,8 +476,8 @@ else:
if err or eh.errors:
for e in eh.errors:
- print e.rstrip("\n")
- print "%s fails to validate" % fpath
+ print(e.rstrip("\n"))
+ print("%s fails to validate" % fpath)
return False
return True
@@ -597,7 +598,7 @@ class SConsDocTree:
# Create xpath context
self.xpath_context = self.doc.xpathNewContext()
# Register namespaces
- for key, val in self.nsmap.iteritems():
+ for key, val in self.nsmap.items():
self.xpath_context.xpathRegisterNs(key, val)
def __del__(self):
@@ -635,8 +636,8 @@ def validate_all_xml(dpaths, xsdfile=default_xsd):
fails = []
for idx, fp in enumerate(fpaths):
fpath = os.path.join(path, fp)
- print "%.2f%s (%d/%d) %s" % (float(idx+1)*100.0/float(len(fpaths)),
- perc, idx+1, len(fpaths),fp)
+ print("%.2f%s (%d/%d) %s" % (float(idx+1)*100.0/float(len(fpaths)),
+ perc, idx+1, len(fpaths),fp))
if not tf.validateXml(fp, xmlschema_context):
fails.append(fp)
@@ -665,8 +666,10 @@ class Item(object):
if name[0] == '_':
name = name[1:]
return name.lower()
- def __cmp__(self, other):
- return cmp(self.sort_name, other.sort_name)
+ def __eq__(self, other):
+ return self.sort_name == other.sort_name
+ def __lt__(self, other):
+ return self.sort_name < other.sort_name
class Builder(Item):
pass
@@ -808,7 +811,7 @@ def importfile(path):
file = open(path, 'r')
try:
module = imp.load_module(name, file, path, (ext, 'r', kind))
- except ImportError, e:
+ except ImportError as e:
sys.stderr.write("Could not import %s: %s\n" % (path, e))
return None
file.close()
diff --git a/bin/SConsExamples.py b/bin/SConsExamples.py
index 9823a05..50c4c1a 100644
--- a/bin/SConsExamples.py
+++ b/bin/SConsExamples.py
@@ -1,7 +1,7 @@
# !/usr/bin/env python
-#
+#
# Copyright (c) 2010 The SCons Foundation
-#
+#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
@@ -9,10 +9,10 @@
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -21,18 +21,18 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-#
+#
+#
# This script looks for some XML tags that describe SCons example
# configurations and commands to execute in those configurations, and
# uses TestCmd.py to execute the commands and insert the output from
# those commands into the XML that we output. This way, we can run a
# script and update all of our example documentation output without
# a lot of laborious by-hand checking.
-#
+#
# An "SCons example" looks like this, and essentially describes a set of
# input files (program source files as well as SConscript files):
-#
+#
# <scons_example name="ex1">
# <file name="SConstruct" printme="1">
# env = Environment()
@@ -42,7 +42,7 @@
# int main() { printf("foo.c\n"); }
# </file>
# </scons_example>
-#
+#
# The <file> contents within the <scons_example> tag will get written
# into a temporary directory whenever example output needs to be
# generated. By default, the <file> contents are not inserted into text
@@ -50,41 +50,43 @@
# in which case they will get inserted within a <programlisting> tag.
# This makes it easy to define the example at the appropriate
# point in the text where you intend to show the SConstruct file.
-#
+#
# Note that you should usually give the <scons_example> a "name"
# attribute so that you can refer to the example configuration later to
# run SCons and generate output.
-#
+#
# If you just want to show a file's contents without worry about running
# SCons, there's a shorter <sconstruct> tag:
-#
+#
# <sconstruct>
# env = Environment()
# env.Program('foo')
# </sconstruct>
-#
+#
# This is essentially equivalent to <scons_example><file printme="1">,
# but it's more straightforward.
-#
+#
# SCons output is generated from the following sort of tag:
-#
+#
# <scons_output example="ex1" os="posix">
# <scons_output_command suffix="1">scons -Q foo</scons_output_command>
# <scons_output_command suffix="2">scons -Q foo</scons_output_command>
# </scons_output>
-#
+#
# You tell it which example to use with the "example" attribute, and then
# give it a list of <scons_output_command> tags to execute. You can also
# supply an "os" tag, which specifies the type of operating system this
# example is intended to show; if you omit this, default value is "posix".
-#
+#
# The generated XML will show the command line (with the appropriate
# command-line prompt for the operating system), execute the command in
# a temporary directory with the example files, capture the standard
# output from SCons, and insert it into the text as appropriate.
# Error output gets passed through to your error output so you
# can see if there are any problems executing the command.
-#
+#
+
+from __future__ import print_function
import os
import re
@@ -94,9 +96,9 @@ import time
import SConsDoc
from SConsDoc import tf as stf
-#
+#
# The available types for ExampleFile entries
-#
+#
FT_FILE = 0 # a physical file (=<file>)
FT_FILEREF = 1 # a reference (=<scons_example_file>)
@@ -106,7 +108,7 @@ class ExampleFile:
self.name = ''
self.content = ''
self.chmod = ''
-
+
def isFileRef(self):
return self.type == FT_FILEREF
@@ -130,19 +132,19 @@ class ExampleOutput:
self.preserve = None
self.suffix = ''
self.commands = []
-
+
class ExampleInfo:
def __init__(self):
self.name = ''
self.files = []
self.folders = []
self.outputs = []
-
+
def getFileContents(self, fname):
for f in self.files:
if fname == f.name and not f.isFileRef():
return f.content
-
+
return ''
def readExampleInfos(fpath, examples):
@@ -150,10 +152,10 @@ def readExampleInfos(fpath, examples):
global dictionary examples.
"""
- # Create doctree
+ # Create doctree
t = SConsDoc.SConsDocTree()
t.parseXmlFile(fpath)
-
+
# Parse scons_examples
for e in stf.findAll(t.root, "scons_example", SConsDoc.dbxid,
t.xpath_context, t.nsmap):
@@ -164,7 +166,7 @@ def readExampleInfos(fpath, examples):
i = ExampleInfo()
i.name = n
examples[n] = i
-
+
# Parse file and directory entries
for f in stf.findAll(e, "file", SConsDoc.dbxid,
t.xpath_context, t.nsmap):
@@ -199,8 +201,8 @@ def readExampleInfos(fpath, examples):
fi.chmod = stf.getAttribute(f, 'chmod')
fi.content = stf.getText(f)
examples[e].files.append(fi)
-
-
+
+
# Parse scons_output
for o in stf.findAll(t.root, "scons_output", SConsDoc.dbxid,
t.xpath_context, t.nsmap):
@@ -238,7 +240,7 @@ def readExampleInfos(fpath, examples):
examples[n].outputs.append(eout)
def readAllExampleInfos(dpath):
- """ Scan for XML files in the given directory and
+ """ Scan for XML files in the given directory and
collect together all relevant infos (files/folders,
output commands) in a map, which gets returned.
"""
@@ -249,13 +251,13 @@ def readAllExampleInfos(dpath):
fpath = os.path.join(path, f)
if SConsDoc.isSConsXml(fpath):
readExampleInfos(fpath, examples)
-
+
return examples
generated_examples = os.path.join('doc', 'generated', 'examples')
def ensureExampleOutputsExist(dpath):
- """ Scan for XML files in the given directory and
+ """ Scan for XML files in the given directory and
ensure that for every example output we have a
corresponding output file in the 'generated/examples'
folder.
@@ -263,9 +265,9 @@ def ensureExampleOutputsExist(dpath):
# Ensure that the output folder exists
if not os.path.isdir(generated_examples):
os.mkdir(generated_examples)
-
+
examples = readAllExampleInfos(dpath)
- for key, value in examples.iteritems():
+ for key, value in examples.items():
# Process all scons_output tags
for o in value.outputs:
cpath = os.path.join(generated_examples,
@@ -276,7 +278,7 @@ def ensureExampleOutputsExist(dpath):
stf.setText(s, "NO OUTPUT YET! Run the script to generate/update all examples.")
# Write file
stf.writeTree(s, cpath)
-
+
# Process all scons_example_file tags
for r in value.files:
if r.isFileRef():
@@ -292,22 +294,22 @@ def ensureExampleOutputsExist(dpath):
perc = "%"
def createAllExampleOutputs(dpath):
- """ Scan for XML files in the given directory and
+ """ Scan for XML files in the given directory and
creates all output files for every example in
the 'generated/examples' folder.
"""
# Ensure that the output folder exists
if not os.path.isdir(generated_examples):
os.mkdir(generated_examples)
-
+
examples = readAllExampleInfos(dpath)
total = len(examples)
idx = 0
- for key, value in examples.iteritems():
+ for key, value in examples.items():
# Process all scons_output tags
- print "%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 / float(total),
- perc, idx + 1, total, key)
-
+ print("%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 / float(total),
+ perc, idx + 1, total, key))
+
create_scons_output(value)
# Process all scons_example_file tags
for r in value.files:
@@ -329,10 +331,10 @@ def collectSConsExampleNames(fpath):
suffixes = {}
failed_suffixes = False
- # Create doctree
+ # Create doctree
t = SConsDoc.SConsDocTree()
t.parseXmlFile(fpath)
-
+
# Parse it
for e in stf.findAll(t.root, "scons_example", SConsDoc.dbxid,
t.xpath_context, t.nsmap):
@@ -344,40 +346,40 @@ def collectSConsExampleNames(fpath):
if n not in suffixes:
suffixes[n] = []
else:
- print "Error: Example in file '%s' is missing a name!" % fpath
+ print("Error: Example in file '%s' is missing a name!" % fpath)
failed_suffixes = True
-
+
for o in stf.findAll(t.root, "scons_output", SConsDoc.dbxid,
t.xpath_context, t.nsmap):
n = ''
if stf.hasAttribute(o, 'example'):
n = stf.getAttribute(o, 'example')
else:
- print "Error: scons_output in file '%s' is missing an example name!" % fpath
+ print("Error: scons_output in file '%s' is missing an example name!" % fpath)
failed_suffixes = True
-
+
if n not in suffixes:
- print "Error: scons_output in file '%s' is referencing non-existent example '%s'!" % (fpath, n)
+ print("Error: scons_output in file '%s' is referencing non-existent example '%s'!" % (fpath, n))
failed_suffixes = True
continue
-
+
s = ''
if stf.hasAttribute(o, 'suffix'):
s = stf.getAttribute(o, 'suffix')
else:
- print "Error: scons_output in file '%s' (example '%s') is missing a suffix!" % (fpath, n)
+ print("Error: scons_output in file '%s' (example '%s') is missing a suffix!" % (fpath, n))
failed_suffixes = True
-
+
if s not in suffixes[n]:
suffixes[n].append(s)
else:
- print "Error: scons_output in file '%s' (example '%s') is using a duplicate suffix '%s'!" % (fpath, n, s)
+ print("Error: scons_output in file '%s' (example '%s') is using a duplicate suffix '%s'!" % (fpath, n, s))
failed_suffixes = True
-
+
return names, failed_suffixes
def exampleNamesAreUnique(dpath):
- """ Scan for XML files in the given directory and
+ """ Scan for XML files in the given directory and
check whether the scons_example names are unique.
"""
unique = True
@@ -392,21 +394,21 @@ def exampleNamesAreUnique(dpath):
unique = False
i = allnames.intersection(names)
if i:
- print "Not unique in %s are: %s" % (fpath, ', '.join(i))
+ print("Not unique in %s are: %s" % (fpath, ', '.join(i)))
unique = False
-
+
allnames |= names
-
+
return unique
# ###############################################################
-#
+#
# In the second half of this module (starting here)
# we define the variables and functions that are required
# to actually run the examples, collect their output and
# write it into the files in doc/generated/examples...
# which then get included by our UserGuide.
-#
+#
# ###############################################################
sys.path.append(os.path.join(os.getcwd(), 'QMTest'))
@@ -416,6 +418,8 @@ scons_py = os.path.join('bootstrap', 'src', 'script', 'scons.py')
if not os.path.exists(scons_py):
scons_py = os.path.join('src', 'script', 'scons.py')
+scons_py = os.path.join(os.getcwd(), scons_py)
+
scons_lib_dir = os.path.join(os.getcwd(), 'bootstrap', 'src', 'engine')
if not os.path.exists(scons_lib_dir):
scons_lib_dir = os.path.join(os.getcwd(), 'src', 'engine')
@@ -430,7 +434,7 @@ Prompt = {
}
# The magick SCons hackery that makes this work.
-#
+#
# So that our examples can still use the default SConstruct file, we
# actually feed the following into SCons via stdin and then have it
# SConscript() the SConstruct file. This stdin wrapper creates a set
@@ -438,7 +442,7 @@ Prompt = {
# Surrogates print output like the real tools and behave like them
# without actually having to be on the right platform or have the right
# tool installed.
-#
+#
# The upshot: The wrapper transparently changes the world out from
# under the top-level SConstruct file in an example just so we can get
# the command output.
@@ -610,10 +614,6 @@ ToolList = {
('ar', ['ARCOM', 'RANLIBCOM'], Cat, []),
('tar', 'TARCOM', Null, []),
('zip', 'ZIPCOM', Null, []),
- ('BitKeeper', 'BITKEEPERCOM', Cat, []),
- ('CVS', 'CVSCOM', Cat, []),
- ('RCS', 'RCS_COCOM', Cat, []),
- ('SCCS', 'SCCSCOM', Cat, []),
('javac', 'JAVACCOM', JavaCCom, []),
('javah', 'JAVAHCOM', JavaHCom, []),
('jar', 'JARCOM', JarCom, []),
@@ -624,10 +624,6 @@ ToolList = {
('mslib', 'ARCOM', Cat, []),
('tar', 'TARCOM', Null, []),
('zip', 'ZIPCOM', Null, []),
- ('BitKeeper', 'BITKEEPERCOM', Cat, []),
- ('CVS', 'CVSCOM', Cat, []),
- ('RCS', 'RCS_COCOM', Cat, []),
- ('SCCS', 'SCCSCOM', Cat, []),
('javac', 'JAVACCOM', JavaCCom, []),
('javah', 'JAVAHCOM', JavaHCom, []),
('jar', 'JARCOM', JarCom, []),
@@ -734,7 +730,11 @@ def command_edit(args, c, test, dict):
def command_ls(args, c, test, dict):
def ls(a):
- return [' '.join(sorted([x for x in os.listdir(a) if x[0] != '.']))]
+ try:
+ return [' '.join(sorted([x for x in os.listdir(a) if x[0] != '.']))]
+ except OSError as e:
+ # This should never happen. Pop into debugger
+ import pdb; pdb.set_trace()
if args:
l = []
for a in args:
@@ -765,7 +765,7 @@ def ExecuteCommand(args, c, t, dict):
def create_scons_output(e):
# The real raison d'etre for this script, this is where we
# actually execute SCons to fetch the output.
-
+
# Loop over all outputs for the example
for o in e.outputs:
# Create new test directory
@@ -774,19 +774,19 @@ def create_scons_output(e):
t.preserve()
t.subdir('ROOT', 'WORK')
t.rootpath = t.workpath('ROOT').replace('\\', '\\\\')
-
+
for d in e.folders:
dir = t.workpath('WORK', d.name)
if not os.path.exists(dir):
os.makedirs(dir)
-
+
for f in e.files:
if f.isFileRef():
continue
- #
+ #
# Left-align file's contents, starting on the first
# non-empty line
- #
+ #
data = f.content.split('\n')
i = 0
# Skip empty lines
@@ -813,26 +813,26 @@ def create_scons_output(e):
if hasattr(f, 'chmod'):
if len(f.chmod):
os.chmod(path, int(f.chmod, 0))
-
+
# Regular expressions for making the doc output consistent,
# regardless of reported addresses or Python version.
-
+
# Massage addresses in object repr strings to a constant.
address_re = re.compile(r' at 0x[0-9a-fA-F]*\>')
-
+
# Massage file names in stack traces (sometimes reported as absolute
# paths) to a consistent relative path.
engine_re = re.compile(r' File ".*/src/engine/SCons/')
-
+
# Python 2.5 changed the stack trace when the module is read
# from standard input from read "... line 7, in ?" to
# "... line 7, in <module>".
file_re = re.compile(r'^( *File ".*", line \d+, in) \?$', re.M)
-
+
# Python 2.6 made UserList a new-style class, which changes the
# AttributeError message generated by our NodeList subclass.
nodelist_re = re.compile(r'(AttributeError:) NodeList instance (has no attribute \S+)')
-
+
# Root element for our subtree
sroot = stf.newEtreeNode("screen", True)
curchild = None
@@ -881,7 +881,7 @@ def create_scons_output(e):
curchild.tail = content
else:
sroot.text = content
-
+
# Construct filename
fpath = os.path.join(generated_examples,
e.name + '_' + o.suffix + '.xml')
diff --git a/bin/calibrate.py b/bin/calibrate.py
index 8ed2ece..3f9104e 100644
--- a/bin/calibrate.py
+++ b/bin/calibrate.py
@@ -20,7 +20,7 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-from __future__ import division
+from __future__ import division, print_function
import optparse
import os
@@ -48,7 +48,7 @@ def main(argv=None):
for arg in args:
if len(args) > 1:
- print arg + ':'
+ print(arg + ':')
command = [sys.executable, 'runtest.py']
if opts.package:
@@ -67,9 +67,9 @@ def main(argv=None):
try:
elapsed = float(em.group(1))
except AttributeError:
- print output
+ print(output)
raise
- print "run %3d: %7.3f: %s" % (run, elapsed, ' '.join(vm.groups()))
+ print("run %3d: %7.3f: %s" % (run, elapsed, ' '.join(vm.groups())))
if opts.min < elapsed and elapsed < opts.max:
good += 1
else:
diff --git a/bin/caller-tree.py b/bin/caller-tree.py
index 03c1616..18cd9e1 100644
--- a/bin/caller-tree.py
+++ b/bin/caller-tree.py
@@ -39,6 +39,7 @@
# function at the same time, for example, their counts will intermix.
# So use this to get a *general* idea of who's calling what, not for
# fine-grained performance tuning.
+from __future__ import print_function
import sys
@@ -74,19 +75,19 @@ for line in sys.stdin.readlines():
stack = []
def print_entry(e, level, calls):
- print '%-72s%6s' % ((' '*2*level) + e.file_line_func, calls)
+ print('%-72s%6s' % ((' '*2*level) + e.file_line_func, calls))
if e in stack:
- print (' '*2*(level+1))+'RECURSION'
- print
+ print((' '*2*(level+1))+'RECURSION')
+ print()
elif e.called_by:
stack.append(e)
for c in e.called_by:
print_entry(c[0], level+1, c[1])
stack.pop()
else:
- print
+ print()
-for e in [ e for e in AllCalls.values() if not e.calls ]:
+for e in [ e for e in list(AllCalls.values()) if not e.calls ]:
print_entry(e, 0, '')
# Local Variables:
diff --git a/bin/docs-create-example-outputs.py b/bin/docs-create-example-outputs.py
index 6e59d9f..73aa31a 100644
--- a/bin/docs-create-example-outputs.py
+++ b/bin/docs-create-example-outputs.py
@@ -3,17 +3,18 @@
# Searches through the whole doc/user tree and creates
# all output files for the single examples.
#
+from __future__ import print_function
import os
import sys
import SConsExamples
if __name__ == "__main__":
- print "Checking whether all example names are unique..."
+ print("Checking whether all example names are unique...")
if SConsExamples.exampleNamesAreUnique(os.path.join('doc','user')):
- print "OK"
+ print("OK")
else:
- print "Not all example names and suffixes are unique! Please correct the errors listed above and try again."
+ print("Not all example names and suffixes are unique! Please correct the errors listed above and try again.")
sys.exit(1)
-
+
SConsExamples.createAllExampleOutputs(os.path.join('doc','user'))
diff --git a/bin/docs-update-generated.py b/bin/docs-update-generated.py
index 55f0035..c164baf 100644
--- a/bin/docs-update-generated.py
+++ b/bin/docs-update-generated.py
@@ -6,6 +6,7 @@
# as well as the entity declarations for them.
# Uses scons-proc.py under the hood...
#
+from __future__ import print_function
import os
import sys
@@ -39,7 +40,7 @@ def generate_all():
try:
os.makedirs(gen_folder)
except:
- print "Couldn't create destination folder %s! Exiting..." % gen_folder
+ print("Couldn't create destination folder %s! Exiting..." % gen_folder)
return
# Call scons-proc.py
os.system('%s %s -b %s -f %s -t %s -v %s %s' %
diff --git a/bin/docs-validate.py b/bin/docs-validate.py
index f888c21..342ed43 100644
--- a/bin/docs-validate.py
+++ b/bin/docs-validate.py
@@ -3,6 +3,7 @@
# Searches through the whole source tree and validates all
# documentation files against our own XSD in docs/xsd.
#
+from __future__ import print_function
import sys,os
import SConsDoc
@@ -10,9 +11,9 @@ import SConsDoc
if __name__ == "__main__":
if len(sys.argv)>1:
if SConsDoc.validate_all_xml((sys.argv[1],)):
- print "OK"
+ print("OK")
else:
- print "Validation failed! Please correct the errors above and try again."
+ print("Validation failed! Please correct the errors above and try again.")
else:
if SConsDoc.validate_all_xml(['src',
os.path.join('doc','design'),
@@ -22,7 +23,7 @@ if __name__ == "__main__":
os.path.join('doc','reference'),
os.path.join('doc','user')
]):
- print "OK"
+ print("OK")
else:
- print "Validation failed! Please correct the errors above and try again."
+ print("Validation failed! Please correct the errors above and try again.")
sys.exit(1)
diff --git a/bin/import-test.py b/bin/import-test.py
index eb93828..168208f 100644
--- a/bin/import-test.py
+++ b/bin/import-test.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# tree2test.py - turn a directory tree into TestSCons code
#
@@ -25,7 +25,7 @@
# """ triple-quotes will need to have their contents edited by hand.
#
-__revision__ = "bin/import-test.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "bin/import-test.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
import os.path
import sys
diff --git a/bin/install_python.py b/bin/install_python.py
index 86807af..5c947ac 100644
--- a/bin/install_python.py
+++ b/bin/install_python.py
@@ -6,6 +6,7 @@
# This was written for a Linux system (specifically Ubuntu) but should
# be reasonably generic to any POSIX-style system with a /usr/local
# hierarchy.
+from __future__ import print_function
import getopt
import os
@@ -48,7 +49,7 @@ Usage: install_python.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...]
try:
try:
opts, args = getopt.getopt(argv[1:], short_options, long_options)
- except getopt.error, msg:
+ except getopt.error as msg:
raise Usage(msg)
for o, a in opts:
@@ -57,7 +58,7 @@ Usage: install_python.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...]
elif o in ('-d', '--downloads'):
downloads_dir = a
elif o in ('-h', '--help'):
- print helpstr
+ print(helpstr)
sys.exit(0)
elif o in ('-n', '--no-exec'):
CommandRunner.execute = CommandRunner.do_not_execute
@@ -65,7 +66,7 @@ Usage: install_python.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...]
prefix = a
elif o in ('-q', '--quiet'):
CommandRunner.display = CommandRunner.do_not_display
- except Usage, err:
+ except Usage as err:
sys.stderr.write(str(err.msg) + '\n')
sys.stderr.write('use -h to get help\n')
return 2
diff --git a/bin/install_scons.py b/bin/install_scons.py
index 00129f6..ac79fd3 100644
--- a/bin/install_scons.py
+++ b/bin/install_scons.py
@@ -18,12 +18,14 @@
# be reasonably generic to any POSIX-style system with a /usr/local
# hierarchy.
+from __future__ import print_function
+
import getopt
import os
import shutil
import sys
import tarfile
-import urllib
+from urllib import urlretrieve
from Command import CommandRunner, Usage
@@ -129,7 +131,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...]
try:
try:
opts, args = getopt.getopt(argv[1:], short_options, long_options)
- except getopt.error, msg:
+ except getopt.error as msg:
raise Usage(msg)
for o, a in opts:
@@ -138,7 +140,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...]
elif o in ('-d', '--downloads'):
downloads_dir = a
elif o in ('-h', '--help'):
- print helpstr
+ print(helpstr)
sys.exit(0)
elif o in ('-n', '--no-exec'):
CommandRunner.execute = CommandRunner.do_not_execute
@@ -146,7 +148,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...]
prefix = a
elif o in ('-q', '--quiet'):
CommandRunner.display = CommandRunner.do_not_display
- except Usage, err:
+ except Usage as err:
sys.stderr.write(str(err.msg) + '\n')
sys.stderr.write('use -h to get help\n')
return 2
@@ -171,7 +173,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...]
if not os.path.exists(tar_gz):
if not os.path.exists(downloads_dir):
cmd.run('mkdir %(downloads_dir)s')
- cmd.run((urllib.urlretrieve, tar_gz_url, tar_gz),
+ cmd.run((urlretrieve, tar_gz_url, tar_gz),
'wget -O %(tar_gz)s %(tar_gz_url)s')
def extract(tar_gz):
diff --git a/bin/linecount.py b/bin/linecount.py
index 147089a..75723d0 100644
--- a/bin/linecount.py
+++ b/bin/linecount.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Count statistics about SCons test and source files. This must be run
# against a fully-populated tree (for example, one that's been freshly
@@ -21,9 +21,9 @@
# in each category, the number of non-blank lines, and the number of
# non-comment lines. The last figure (non-comment) lines is the most
# interesting one for most purposes.
-from __future__ import division
+from __future__ import division, print_function
-__revision__ = "bin/linecount.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "bin/linecount.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
import os.path
@@ -98,23 +98,23 @@ all_tests = Collection('all tests', src_tests.files + test_tests.files)
def ratio(over, under):
return "%.2f" % (float(len(over)) / float(len(under)))
-print fmt % ('', '', '', '', '', 'non-blank')
-print fmt % ('', 'files', 'lines', 'non-blank', 'non-comment', 'non-comment')
-print
-print fmt % src_Tests_py_tests.printables()
-print fmt % src_test_tests.printables()
-print
-print fmt % src_tests.printables()
-print fmt % test_tests.printables()
-print
-print fmt % all_tests.printables()
-print fmt % sources.printables()
-print
-print fmt % ('ratio:',
+print(fmt % ('', '', '', '', '', 'non-blank'))
+print(fmt % ('', 'files', 'lines', 'non-blank', 'non-comment', 'non-comment'))
+print()
+print(fmt % src_Tests_py_tests.printables())
+print(fmt % src_test_tests.printables())
+print()
+print(fmt % src_tests.printables())
+print(fmt % test_tests.printables())
+print()
+print(fmt % all_tests.printables())
+print(fmt % sources.printables())
+print()
+print(fmt % ('ratio:',
ratio(all_tests, sources),
ratio(all_tests.lines(), sources.lines()),
ratio(all_tests.non_blank(), sources.non_blank()),
ratio(all_tests.non_comment(), sources.non_comment()),
ratio(all_tests.non_blank_non_comment(),
sources.non_blank_non_comment())
- )
+ ))
diff --git a/bin/memlogs.py b/bin/memlogs.py
index 9d957c9..b450939 100644
--- a/bin/memlogs.py
+++ b/bin/memlogs.py
@@ -21,26 +21,28 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+from __future__ import print_function
+
import getopt
import sys
filenames = sys.argv[1:]
if not filenames:
- print """Usage: memlogs.py file [...]
+ print("""Usage: memlogs.py file [...]
Summarizes the --debug=memory numbers from one or more build logs.
-"""
+""")
sys.exit(0)
fmt = "%12s %12s %12s %12s %s"
-print fmt % ("pre-read", "post-read", "pre-build", "post-build", "")
+print(fmt % ("pre-read", "post-read", "pre-build", "post-build", ""))
for fname in sys.argv[1:]:
lines = [l for l in open(fname).readlines() if l[:7] == 'Memory ']
t = tuple([l.split()[-1] for l in lines]) + (fname,)
- print fmt % t
+ print(fmt % t)
# Local Variables:
# tab-width:4
diff --git a/bin/memoicmp.py b/bin/memoicmp.py
index 812af66..63f6538 100644
--- a/bin/memoicmp.py
+++ b/bin/memoicmp.py
@@ -3,6 +3,8 @@
# A script to compare the --debug=memoizer output found in
# two different files.
+from __future__ import print_function
+
import sys
def memoize_output(fname):
@@ -23,20 +25,20 @@ def memoize_cmp(filea, fileb):
ma = memoize_output(filea)
mb = memoize_output(fileb)
- print 'All output: %s / %s [delta]'%(filea, fileb)
- print '----------HITS---------- ---------MISSES---------'
+ print('All output: %s / %s [delta]'%(filea, fileb))
+ print('----------HITS---------- ---------MISSES---------')
cfmt='%7d/%-7d [%d]'
ma_o = []
mb_o = []
mab = []
- for k in ma.keys():
- if k in mb.keys():
+ for k in list(ma.keys()):
+ if k in list(mb.keys()):
if k not in mab:
mab.append(k)
else:
ma_o.append(k)
- for k in mb.keys():
- if k in ma.keys():
+ for k in list(mb.keys()):
+ if k in list(ma.keys()):
if k not in mab:
mab.append(k)
else:
@@ -45,30 +47,30 @@ def memoize_cmp(filea, fileb):
mab.sort()
ma_o.sort()
mb_o.sort()
-
+
for k in mab:
hits = cfmt%(ma[k][0], mb[k][0], mb[k][0]-ma[k][0])
miss = cfmt%(ma[k][1], mb[k][1], mb[k][1]-ma[k][1])
- print '%-24s %-24s %s'%(hits, miss, k)
+ print('%-24s %-24s %s'%(hits, miss, k))
for k in ma_o:
hits = '%7d/ --'%(ma[k][0])
miss = '%7d/ --'%(ma[k][1])
- print '%-24s %-24s %s'%(hits, miss, k)
+ print('%-24s %-24s %s'%(hits, miss, k))
for k in mb_o:
hits = ' -- /%-7d'%(mb[k][0])
miss = ' -- /%-7d'%(mb[k][1])
- print '%-24s %-24s %s'%(hits, miss, k)
+ print('%-24s %-24s %s'%(hits, miss, k))
+
+ print('-'*(24+24+1+20))
- print '-'*(24+24+1+20)
-
if __name__ == "__main__":
if len(sys.argv) != 3:
- print """Usage: %s file1 file2
+ print("""Usage: %s file1 file2
-Compares --debug=memomize output from file1 against file2."""%sys.argv[0]
+Compares --debug=memomize output from file1 against file2."""%sys.argv[0])
sys.exit(1)
memoize_cmp(sys.argv[1], sys.argv[2])
diff --git a/bin/objcounts.py b/bin/objcounts.py
index 0662012..8b550d1 100644
--- a/bin/objcounts.py
+++ b/bin/objcounts.py
@@ -20,6 +20,7 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+from __future__ import print_function
import re
import sys
@@ -27,10 +28,10 @@ import sys
filenames = sys.argv[1:]
if len(sys.argv) != 3:
- print """Usage: objcounts.py file1 file2
+ print("""Usage: objcounts.py file1 file2
Compare the --debug=object counts from two build logs.
-"""
+""")
sys.exit(0)
def fetch_counts(fname):
@@ -47,7 +48,7 @@ c1 = fetch_counts(sys.argv[1])
c2 = fetch_counts(sys.argv[2])
common = {}
-for k in c1.keys():
+for k in list(c1.keys()):
try:
common[k] = (c1[k], c2[k])
except KeyError:
@@ -58,7 +59,7 @@ for k in c1.keys():
if not '.' in k:
s = '.'+k
l = len(s)
- for k2 in c2.keys():
+ for k2 in list(c2.keys()):
if k2[-l:] == s:
common[k2] = (c1[k], c2[k2])
del c1[k]
@@ -81,10 +82,9 @@ def diffstr(c1, c2):
return " %5s/%-5s %-8s" % (c1, c2, d)
def printline(c1, c2, classname):
- print \
- diffstr(c1[2], c2[2]) + \
+ print(diffstr(c1[2], c2[2]) + \
diffstr(c1[3], c2[3]) + \
- ' ' + classname
+ ' ' + classname)
for k in sorted(common.keys()):
c = common[k]
diff --git a/bin/restore.sh b/bin/restore.sh
index 4b96852..49c95bc 100644
--- a/bin/restore.sh
+++ b/bin/restore.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env sh
#
-# Simple hack script to restore __revision__, __COPYRIGHT_, 2.5.1
+# Simple hack script to restore __revision__, __COPYRIGHT_, 3.0.0
# and other similar variables to what gets checked in to source. This
# comes in handy when people send in diffs based on the released source.
#
@@ -22,9 +22,9 @@ header() {
for i in `find $DIRS -name '*.py'`; do
header $i
ed $i <<EOF
-g/Copyright (c) 2001.*SCons Foundation/s//Copyright (c) 2001 - 2016 The SCons Foundation/p
+g/Copyright (c) 2001.*SCons Foundation/s//Copyright (c) 2001 - 2017 The SCons Foundation/p
w
-/^__revision__ = /s/= .*/= "bin/restore.sh rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"/p
+/^__revision__ = /s/= .*/= "bin/restore.sh rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"/p
w
q
EOF
@@ -33,9 +33,9 @@ done
for i in `find $DIRS -name 'scons.bat'`; do
header $i
ed $i <<EOF
-g/Copyright (c) 2001.*SCons Foundation/s//Copyright (c) 2001 - 2016 The SCons Foundation/p
+g/Copyright (c) 2001.*SCons Foundation/s//Copyright (c) 2001 - 2017 The SCons Foundation/p
w
-/^@REM src\/script\/scons.bat/s/@REM .* knight/@REM bin/restore.sh rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog/p
+/^@REM src\/script\/scons.bat/s/@REM .* knight/@REM bin/restore.sh rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog/p
w
q
EOF
@@ -44,13 +44,13 @@ done
for i in `find $DIRS -name '__init__.py' -o -name 'scons.py' -o -name 'sconsign.py'`; do
header $i
ed $i <<EOF
-/^__version__ = /s/= .*/= "2.5.1"/p
+/^__version__ = /s/= .*/= "3.0.0"/p
w
-/^__build__ = /s/= .*/= "rel_2.5.1:3735:9dc6cee5c168[MODIFIED]"/p
+/^__build__ = /s/= .*/= "rel_3.0.0:4395:8972f6a2f699"/p
w
-/^__buildsys__ = /s/= .*/= "mongodog"/p
+/^__buildsys__ = /s/= .*/= "ubuntu-16"/p
w
-/^__date__ = /s/= .*/= "2016/11/03 14:02:02"/p
+/^__date__ = /s/= .*/= "2017/09/18 12:59:24"/p
w
/^__developer__ = /s/= .*/= "bdbaddog"/p
w
@@ -61,7 +61,7 @@ done
for i in `find $DIRS -name 'setup.py'`; do
header $i
ed $i <<EOF
-/^ *version = /s/= .*/= "2.5.1",/p
+/^ *version = /s/= .*/= "3.0.0",/p
w
q
EOF
@@ -70,11 +70,11 @@ done
for i in `find $DIRS -name '*.txt'`; do
header $i
ed $i <<EOF
-g/Copyright (c) 2001.*SCons Foundation/s//Copyright (c) 2001 - 2016 The SCons Foundation/p
+g/Copyright (c) 2001.*SCons Foundation/s//Copyright (c) 2001 - 2017 The SCons Foundation/p
w
-/# [^ ]* 0.96.[CD][0-9]* [0-9\/]* [0-9:]* knight$/s/.*/# bin/restore.sh rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog/p
+/# [^ ]* 0.96.[CD][0-9]* [0-9\/]* [0-9:]* knight$/s/.*/# bin/restore.sh rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog/p
w
-/Version [0-9][0-9]*\.[0-9][0-9]*/s//Version 2.5.1/p
+/Version [0-9][0-9]*\.[0-9][0-9]*/s//Version 3.0.0/p
w
q
EOF
@@ -83,7 +83,7 @@ done
for i in `find $DIRS -name '*.xml'`; do
header $i
ed $i <<EOF
-g/Copyright (c) 2001.*SCons Foundation/s//Copyright (c) 2001 - 2016 The SCons Foundation/p
+g/Copyright (c) 2001.*SCons Foundation/s//Copyright (c) 2001 - 2017 The SCons Foundation/p
w
q
EOF
diff --git a/bin/scons-diff.py b/bin/scons-diff.py
index 1e4bca0..182b726 100644
--- a/bin/scons-diff.py
+++ b/bin/scons-diff.py
@@ -8,6 +8,7 @@
# etc. so that you can diff trees without having to ignore changes in
# version lines.
#
+from __future__ import print_function
import difflib
import getopt
@@ -43,7 +44,7 @@ def diff_line(left, right):
opts = ' ' + ' '.join(diff_options)
else:
opts = ''
- print 'diff%s %s %s' % (opts, left, right)
+ print('diff%s %s %s' % (opts, left, right))
for o, a in opts:
if o in ('-c', '-u'):
@@ -51,7 +52,7 @@ for o, a in opts:
context = int(a)
diff_options.append(o)
elif o in ('-h', '--help'):
- print Usage
+ print(Usage)
sys.exit(0)
elif o in ('-n'):
diff_options.append(o)
@@ -161,9 +162,9 @@ def diff_file(left, right):
else:
if text:
diff_line(left, right)
- print text,
+ print(text)
elif report_same:
- print 'Files %s and %s are identical' % (left, right)
+ print('Files %s and %s are identical' % (left, right))
def diff_dir(left, right):
llist = os.listdir(left)
@@ -173,16 +174,16 @@ def diff_dir(left, right):
u[l] = 1
for r in rlist:
u[r] = 1
- for x in sorted([ x for x in u.keys() if x[-4:] != '.pyc' ]):
+ for x in sorted([ x for x in list(u.keys()) if x[-4:] != '.pyc' ]):
if x in llist:
if x in rlist:
do_diff(os.path.join(left, x),
os.path.join(right, x),
recursive)
else:
- print 'Only in %s: %s' % (left, x)
+ print('Only in %s: %s' % (left, x))
else:
- print 'Only in %s: %s' % (right, x)
+ print('Only in %s: %s' % (right, x))
do_diff(left, right, True)
diff --git a/bin/scons-proc.py b/bin/scons-proc.py
index d6a770b..e09c853 100644
--- a/bin/scons-proc.py
+++ b/bin/scons-proc.py
@@ -9,6 +9,8 @@
# DocBook-formatted generated XML files containing the summary text
# and/or .mod files containing the ENTITY definitions for each item.
#
+from __future__ import print_function
+
import getopt
import os
import re
@@ -225,10 +227,15 @@ class Proxy(object):
"""Retrieve the entire wrapped object"""
return self.__subject
- def __cmp__(self, other):
+ def __eq__(self, other):
if issubclass(other.__class__, self.__subject.__class__):
- return cmp(self.__subject, other)
- return cmp(self.__dict__, other.__dict__)
+ return self.__subject == other
+ return self.__dict__ == other.__dict__
+
+ ## def __lt__(self, other):
+ ## if issubclass(other.__class__, self.__subject.__class__):
+ ## return self.__subject < other
+ ## return self.__dict__ < other.__dict__
class SConsThing(Proxy):
def idfunc(self):
@@ -340,25 +347,25 @@ def write_output_files(h, buildersfiles, functionsfiles,
processor_class = SCons_XML
# Step 1: Creating entity files for builders, functions,...
-print "Generating entity files..."
+print("Generating entity files...")
h = parse_docs(args, False)
write_output_files(h, buildersfiles, functionsfiles, toolsfiles,
variablesfiles, SCons_XML.write_mod)
# Step 2: Validating all input files
-print "Validating files against SCons XSD..."
+print("Validating files against SCons XSD...")
if SConsDoc.validate_all_xml(['src']):
- print "OK"
+ print("OK")
else:
- print "Validation failed! Please correct the errors above and try again."
+ print("Validation failed! Please correct the errors above and try again.")
# Step 3: Creating actual documentation snippets, using the
# fully resolved and updated entities from the *.mod files.
-print "Updating documentation for builders, tools and functions..."
+print("Updating documentation for builders, tools and functions...")
h = parse_docs(args, True)
write_output_files(h, buildersfiles, functionsfiles, toolsfiles,
variablesfiles, SCons_XML.write)
-print "Done"
+print("Done")
# Local Variables:
# tab-width:4
diff --git a/bin/scons-test.py b/bin/scons-test.py
index 046cf4b..dd54dd1 100644
--- a/bin/scons-test.py
+++ b/bin/scons-test.py
@@ -14,6 +14,7 @@
# relevant information about the system, the Python version, etc.,
# so that problems on different platforms can be identified sooner.
#
+from __future__ import print_function
import atexit
import getopt
@@ -60,7 +61,7 @@ for o, a in opts:
outdir = a
elif o == '-v' or o == '--verbose':
def printname(x):
- print x
+ print(x)
elif o == '--xml':
format = o
@@ -148,34 +149,34 @@ else:
if format == '--xml':
- print "<scons_test_run>"
- print " <sys>"
+ print("<scons_test_run>")
+ print(" <sys>")
sys_keys = ['byteorder', 'exec_prefix', 'executable', 'maxint', 'maxunicode', 'platform', 'prefix', 'version', 'version_info']
for k in sys_keys:
- print " <%s>%s</%s>" % (k, sys.__dict__[k], k)
- print " </sys>"
+ print(" <%s>%s</%s>" % (k, sys.__dict__[k], k))
+ print(" </sys>")
fmt = '%a %b %d %H:%M:%S %Y'
- print " <time>"
- print " <gmtime>%s</gmtime>" % time.strftime(fmt, time.gmtime())
- print " <localtime>%s</localtime>" % time.strftime(fmt, time.localtime())
- print " </time>"
+ print(" <time>")
+ print(" <gmtime>%s</gmtime>" % time.strftime(fmt, time.gmtime()))
+ print(" <localtime>%s</localtime>" % time.strftime(fmt, time.localtime()))
+ print(" </time>")
- print " <tempdir>%s</tempdir>" % tempdir
+ print(" <tempdir>%s</tempdir>" % tempdir)
def print_version_info(tag, module):
- print " <%s>" % tag
- print " <version>%s</version>" % module.__version__
- print " <build>%s</build>" % module.__build__
- print " <buildsys>%s</buildsys>" % module.__buildsys__
- print " <date>%s</date>" % module.__date__
- print " <developer>%s</developer>" % module.__developer__
- print " </%s>" % tag
-
- print " <scons>"
+ print(" <%s>" % tag)
+ print(" <version>%s</version>" % module.__version__)
+ print(" <build>%s</build>" % module.__build__)
+ print(" <buildsys>%s</buildsys>" % module.__buildsys__)
+ print(" <date>%s</date>" % module.__date__)
+ print(" <developer>%s</developer>" % module.__developer__)
+ print(" </%s>" % tag)
+
+ print(" <scons>")
print_version_info("script", scons)
print_version_info("engine", SCons)
- print " </scons>"
+ print(" </scons>")
environ_keys = [
'PATH',
@@ -213,37 +214,37 @@ if format == '--xml':
'USER',
]
- print " <environment>"
+ print(" <environment>")
for key in sorted(environ_keys):
value = os.environ.get(key)
if value:
- print " <variable>"
- print " <name>%s</name>" % key
- print " <value>%s</value>" % value
- print " </variable>"
- print " </environment>"
+ print(" <variable>")
+ print(" <name>%s</name>" % key)
+ print(" <value>%s</value>" % value)
+ print(" </variable>")
+ print(" </environment>")
command = '"%s" runtest.py -q -o - --xml %s' % (sys.executable, runtest_args)
- #print command
+ #print(command)
os.system(command)
- print "</scons_test_run>"
+ print("</scons_test_run>")
else:
def print_version_info(tag, module):
- print "\t%s: v%s.%s, %s, by %s on %s" % (tag,
+ print("\t%s: v%s.%s, %s, by %s on %s" % (tag,
module.__version__,
module.__build__,
module.__date__,
module.__developer__,
- module.__buildsys__)
+ module.__buildsys__))
- print "SCons by Steven Knight et al.:"
+ print("SCons by Steven Knight et al.:")
print_version_info("script", scons)
print_version_info("engine", SCons)
command = '"%s" runtest.py %s' % (sys.executable, runtest_args)
- #print command
+ #print(command)
os.system(command)
# Local Variables:
diff --git a/bin/scons-unzip.py b/bin/scons-unzip.py
index d4ec4bf..a64179f 100644
--- a/bin/scons-unzip.py
+++ b/bin/scons-unzip.py
@@ -7,6 +7,7 @@
# I'm using this to make it more convenient to manage working on multiple
# changes on Windows, where I don't have access to my Aegis tools.
#
+from __future__ import print_function
import getopt
import os.path
@@ -32,7 +33,7 @@ for o, a in opts:
outdir = a
elif o == '-v' or o == '--verbose':
def printname(x):
- print x
+ print(x)
if len(args) != 1:
sys.stderr.write("scons-unzip.py: \n")
diff --git a/bin/scons_dev_master.py b/bin/scons_dev_master.py
index 3c41ac0..3d67cb5 100644
--- a/bin/scons_dev_master.py
+++ b/bin/scons_dev_master.py
@@ -3,6 +3,7 @@
# A script for turning a generic Ubuntu system into a master for
# SCons development.
+from __future__ import print_function
import getopt
import sys
@@ -10,7 +11,7 @@ import sys
from Command import CommandRunner, Usage
INITIAL_PACKAGES = [
- 'subversion',
+ 'mercurial',
]
INSTALL_PACKAGES = [
@@ -22,6 +23,14 @@ PYTHON_PACKAGES = [
'gcc',
'make',
'zlib1g-dev',
+ 'libreadline-gplv2-dev',
+ 'libncursesw5-dev',
+ 'libssl-dev',
+ 'libsqlite3-dev',
+ 'tk-dev',
+ 'libgdbm-dev',
+ 'libc6-dev',
+ 'libbz2-dev'
]
BUILDING_PACKAGES = [
@@ -85,7 +94,7 @@ TESTING_PACKAGES = [
]
BUILDBOT_PACKAGES = [
- 'buildbot',
+ 'buildbot-worker',
'cron',
]
@@ -122,7 +131,7 @@ Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER]
buildbot Install packages for running BuildBot
"""
- scons_url = 'http://scons.tigris.org/svn/scons/trunk'
+ scons_url = 'https://bdbaddog@bitbucket.org/scons/scons'
sudo = 'sudo'
password = '""'
username = 'guest'
@@ -131,12 +140,12 @@ Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER]
try:
try:
opts, args = getopt.getopt(argv[1:], short_options, long_options)
- except getopt.error, msg:
+ except getopt.error as msg:
raise Usage(msg)
for o, a in opts:
if o in ('-h', '--help'):
- print helpstr
+ print(helpstr)
sys.exit(0)
elif o in ('-n', '--no-exec'):
CommandRunner.execute = CommandRunner.do_not_execute
@@ -148,7 +157,7 @@ Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER]
username = a
elif o in ('-y', '--yes', '--assume-yes'):
yesflag = o
- except Usage, err:
+ except Usage as err:
sys.stderr.write(str(err.msg) + '\n')
sys.stderr.write('use -h to get help\n')
return 2
@@ -162,6 +171,7 @@ Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER]
testing_packages = ' '.join(TESTING_PACKAGES)
buildbot_packages = ' '.join(BUILDBOT_PACKAGES)
python_packages = ' '.join(PYTHON_PACKAGES)
+ doc_packages = ' '.join(DOCUMENTATION_PACKAGES)
cmd = CommandRunner(locals())
@@ -170,9 +180,11 @@ Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER]
cmd.run('%(sudo)s apt-get %(yesflag)s upgrade')
elif arg == 'checkout':
cmd.run('%(sudo)s apt-get %(yesflag)s install %(initial_packages)s')
- cmd.run('svn co --username guest --password "" %(scons_url)s')
+ cmd.run('hg clone" %(scons_url)s')
elif arg == 'building':
cmd.run('%(sudo)s apt-get %(yesflag)s install %(building_packages)s')
+ elif arg == 'docs':
+ cmd.run('%(sudo)s apt-get %(yesflag)s install %(doc_packages)s')
elif arg == 'testing':
cmd.run('%(sudo)s apt-get %(yesflag)s install %(testing_packages)s')
elif arg == 'buildbot':
diff --git a/bin/sfsum b/bin/sfsum
index 2dfa422..142793a 100644
--- a/bin/sfsum
+++ b/bin/sfsum
@@ -22,6 +22,7 @@
#
# https://sourceforge.net/projects/sitedocs/
#
+from __future__ import print_function
import xml.sax
import xml.sax.saxutils
@@ -121,9 +122,9 @@ if __name__ == '__main__':
# generalized once we figure out other things for this script to do.
bugs = [x for x in Artifacts['Bugs'] if x.status == 'Open']
- print list(Artifacts.keys())
+ print(list(Artifacts.keys()))
- print "%d open bugs" % len(bugs)
+ print("%d open bugs" % len(bugs))
# Sort them into a separate list for each assignee.
Assigned = {}
@@ -141,7 +142,7 @@ if __name__ == '__main__':
except KeyError:
pass
else:
- print " %s" % a
- b.sort(lambda x, y: cmp(x.artifact_id, y.artifact_id))
+ print(" %s" % a)
+ b.sort(key=lambda x, y: (x.artifact_id, y.artifact_id))
for bug in b:
- print " %-6s %s" % (bug.artifact_id, bug.summary)
+ print(" %-6s %s" % (bug.artifact_id, bug.summary))
diff --git a/bin/svn-bisect.py b/bin/svn-bisect.py
index 77bda58..dbf8dd9 100755
--- a/bin/svn-bisect.py
+++ b/bin/svn-bisect.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- Python -*-
-from __future__ import division
+from __future__ import division, print_function
import sys
from math import log, ceil
@@ -28,22 +28,22 @@ script = script_args[2:]
# print an error message and quit
def error(s):
- print >>sys.stderr, "******", s, "******"
+ print("******", s, "******", file=sys.stderr)
sys.exit(1)
# update to the specified version and run test
def testfail(revision):
"Return true if test fails"
- print "Updating to revision", revision
+ print("Updating to revision", revision)
if subprocess.call(["svn","up","-qr",str(revision)]) != 0:
m = "SVN did not update properly to revision %d"
raise RuntimeError(m % revision)
return subprocess.call(script,shell=False) != 0
# confirm that the endpoints are different
-print "****** Checking upper bracket", upper
+print("****** Checking upper bracket", upper)
upperfails = testfail(upper)
-print "****** Checking lower bracket", lower
+print("****** Checking lower bracket", lower)
lowerfails = testfail(lower)
if upperfails == lowerfails:
error("Upper and lower revisions must bracket the failure")
@@ -51,7 +51,7 @@ if upperfails == lowerfails:
# binary search for transition
msg = "****** max %d revisions to test (bug bracketed by [%d,%d])"
while upper-lower > 1:
- print msg % (ceil(log(upper-lower,2)), lower, upper)
+ print(msg % (ceil(log(upper-lower,2)), lower, upper))
mid = (lower + upper)//2
midfails = testfail(mid)
@@ -64,7 +64,7 @@ while upper-lower > 1:
# show which revision was first to fail
if upperfails != lowerfails: lower = upper
-print "The error was caused by revision", lower
+print("The error was caused by revision", lower)
# Local Variables:
# tab-width:4
diff --git a/bin/update-release-info.py b/bin/update-release-info.py
index aee481e..a4096d1 100644
--- a/bin/update-release-info.py
+++ b/bin/update-release-info.py
@@ -36,7 +36,7 @@ In 'post' mode, files are prepared for the next release cycle:
src/Announce.txt.
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -56,8 +56,9 @@ In 'post' mode, files are prepared for the next release cycle:
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+from __future__ import print_function
-__revision__ = "bin/update-release-info.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "bin/update-release-info.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
import os
import sys
@@ -73,14 +74,14 @@ if len(sys.argv) < 2:
else:
mode = sys.argv[1]
if mode not in ['develop', 'release', 'post']:
- print("""ERROR: `%s' as a parameter is invalid; it must be one of
-\tdevelop, release, or post. The default is develop.""" % mode)
+ print(("""ERROR: `%s' as a parameter is invalid; it must be one of
+\tdevelop, release, or post. The default is develop.""" % mode))
sys.exit(1)
# Get configuration information
config = dict()
-exec open('ReleaseConfig').read() in globals(), config
+exec(open('ReleaseConfig').read(), globals(), config)
try:
version_tuple = config['version_tuple']
@@ -90,9 +91,9 @@ except KeyError:
print('''ERROR: Config file must contain at least version_tuple,
\tunsupported_python_version, and deprecated_python_version.''')
sys.exit(1)
-if DEBUG: print 'version tuple', version_tuple
-if DEBUG: print 'unsupported Python version', unsupported_version
-if DEBUG: print 'deprecated Python version', deprecated_version
+if DEBUG: print('version tuple', version_tuple)
+if DEBUG: print('unsupported Python version', unsupported_version)
+if DEBUG: print('deprecated Python version', deprecated_version)
try:
release_date = config['release_date']
@@ -102,9 +103,9 @@ else:
if len(release_date) == 3:
release_date = release_date + time.localtime()[3:6]
if len(release_date) != 6:
- print '''ERROR: Invalid release date''', release_date
+ print('''ERROR: Invalid release date''', release_date)
sys.exit(1)
-if DEBUG: print 'release date', release_date
+if DEBUG: print('release date', release_date)
if mode == 'develop' and version_tuple[3] != 'alpha':
version_tuple == version_tuple[:3] + ('alpha', 0)
@@ -119,11 +120,11 @@ if len(version_tuple) > 3:
version_type = version_tuple[3]
else:
version_type = 'final'
-if DEBUG: print 'version string', version_string
+if DEBUG: print('version string', version_string)
if version_type not in ['alpha', 'beta', 'candidate', 'final']:
- print("""ERROR: `%s' is not a valid release type in version tuple;
-\tit must be one of alpha, beta, candidate, or final""" % version_type)
+ print(("""ERROR: `%s' is not a valid release type in version tuple;
+\tit must be one of alpha, beta, candidate, or final""" % version_type))
sys.exit(1)
try:
@@ -133,13 +134,13 @@ except KeyError:
month_year = 'MONTH YEAR'
else:
month_year = time.strftime('%B %Y', release_date + (0,0,0))
-if DEBUG: print 'month year', month_year
+if DEBUG: print('month year', month_year)
try:
copyright_years = config['copyright_years']
except KeyError:
copyright_years = '2001 - %d'%(release_date[0] + 1)
-if DEBUG: print 'copyright years', copyright_years
+if DEBUG: print('copyright years', copyright_years)
class UpdateFile(object):
"""
@@ -151,7 +152,7 @@ class UpdateFile(object):
'''
if orig is None: orig = file
try:
- self.content = open(orig, 'rU').read()
+ self.content = open(orig, 'r').read()
except IOError:
# Couldn't open file; don't try to write anything in __del__
self.file = None
@@ -218,7 +219,7 @@ class UpdateFile(object):
XXX
'''
if self.file is not None and self.content != self.orig:
- print 'Updating ' + self.file + '...'
+ print('Updating ' + self.file + '...')
open(self.file, 'w').write(self.content)
if mode == 'post':
diff --git a/bin/xmlagenda.py b/bin/xmlagenda.py
index b3cd520..fcfe53e 100755
--- a/bin/xmlagenda.py
+++ b/bin/xmlagenda.py
@@ -18,6 +18,7 @@
# Grab the sort bar on the far left (just above the "1" for row one)
# and move it down one row. (Row one becomes a floating header)
# Voila!
+from __future__ import print_function
# The team members
# FIXME: These names really should be external to this script
@@ -89,7 +90,7 @@ for issue in issues:
writer.writerow(['','','','','','',''])
for member in team: writer.writerow(['','',member,'','','',''])
-print "Exported %d issues to editlist.csv. Ready to upload to Google."%len(issues)
+print("Exported %d issues to editlist.csv. Ready to upload to Google."%len(issues))
# Local Variables:
# tab-width:4