Supported by Python 2.6+ and required by Python 3.x. --- framework/core.py | 4 +++- framework/shader_test.py | 2 ++ framework/threadpool.py | 30 ++++++++++++++++-------------- piglit-merge-results.py | 4 +++- piglit-run.py | 19 ++++++++++--------- piglit-summary-html.py | 4 +++- 6 filer ändrade, 37 tillägg(+), 26 borttagningar(-)
diff --git a/framework/core.py b/framework/core.py index 2a3bffa..422fa02 100644 --- a/framework/core.py +++ b/framework/core.py @@ -22,6 +22,8 @@ # Piglit core +from __future__ import print_function + import errno import json import os @@ -198,7 +200,7 @@ def checkDir(dirname, failifexists): exists = False if exists and failifexists: - print >>sys.stderr, "%(dirname)s exists already.\nUse --overwrite if you want to overwrite it.\n" % locals() + print("%(dirname)s exists already.\nUse --overwrite if you want to overwrite it.\n" % locals(), file=sys.stderr) exit(1) try: diff --git a/framework/shader_test.py b/framework/shader_test.py index 37ed0f2..399d71f 100755 --- a/framework/shader_test.py +++ b/framework/shader_test.py @@ -23,6 +23,8 @@ # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +from __future__ import print_function + import json import os import os.path as path diff --git a/framework/threadpool.py b/framework/threadpool.py index 41b7105..88e275a 100644 --- a/framework/threadpool.py +++ b/framework/threadpool.py @@ -32,6 +32,8 @@ Website : http://chrisarndt.de/projects/threadpool/ """ +from __future__ import print_function + import sys import threading import traceback @@ -347,18 +349,18 @@ if __name__ == '__main__': # this will be called each time a result is available def print_result(request, result): - print "**** Result from request #%s: %r" % (request.requestID, result) + print("**** Result from request #%s: %r" % (request.requestID, result)) # this will be called when an exception occurs within a thread # this example exception handler does little more than the default handler def handle_exception(request, exc_info): if not isinstance(exc_info, tuple): # Something is seriously wrong... - print request - print exc_info + print(request) + print(exc_info) raise SystemExit - print "**** Exception occured in request #%s: %s" % \ - (request.requestID, exc_info) + print("**** Exception occured in request #%s: %s" % + (request.requestID, exc_info)) # assemble the arguments for each job to a list... data = [random.randint(1,10) for i in range(20)] @@ -378,13 +380,13 @@ if __name__ == '__main__': ) # we create a pool of 3 worker threads - print "Creating thread pool with 3 worker threads." + print("Creating thread pool with 3 worker threads.") main = ThreadPool(3) # then we put the work requests in the queue... for req in requests: main.putRequest(req) - print "Work request #%s added." % req.requestID + print("Work request #%s added." % req.requestID) # or shorter: # [main.putRequest(req) for req in requests] @@ -399,21 +401,21 @@ if __name__ == '__main__': try: time.sleep(0.5) main.poll() - print "Main thread working...", - print "(active worker threads: %i)" % (threading.activeCount()-1, ) + print("Main thread working...", end=' ') + print("(active worker threads: %i)" % (threading.activeCount()-1, )) if i == 10: - print "**** Adding 3 more worker threads..." + print("**** Adding 3 more worker threads...") main.createWorkers(3) if i == 20: - print "**** Dismissing 2 worker threads..." + print("**** Dismissing 2 worker threads...") main.dismissWorkers(2) i += 1 except KeyboardInterrupt: - print "**** Interrupted!" + print("**** Interrupted!") break except NoResultsPending: - print "**** No pending results." + print("**** No pending results.") break if main.dismissedWorkers: - print "Joining all dismissed worker threads..." + print("Joining all dismissed worker threads...") main.joinAllDismissedWorkers() diff --git a/piglit-merge-results.py b/piglit-merge-results.py index fea2307..c8091ec 100755 --- a/piglit-merge-results.py +++ b/piglit-merge-results.py @@ -22,6 +22,8 @@ # DEALINGS IN THE SOFTWARE. +from __future__ import print_function + from getopt import getopt, GetoptError import sys, os.path @@ -43,7 +45,7 @@ Options: Example: %(progName)s results/main > results/summary """ - print USAGE % {'progName': sys.argv[0]} + print(USAGE % {'progName': sys.argv[0]}) sys.exit(1) def main(): diff --git a/piglit-run.py b/piglit-run.py index 0a8ebc5..e882e41 100755 --- a/piglit-run.py +++ b/piglit-run.py @@ -21,6 +21,7 @@ # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +from __future__ import print_function import argparse import os.path as path @@ -115,12 +116,12 @@ def main(): if args.concurrent is not None: if (args.concurrent == '1' or args.concurrent == 'on'): args.concurrency = True - print "Warning: Option -c, --concurrent is deprecated, " \ - "concurrent test runs are on by default" + print("Warning: Option -c, --concurrent is deprecated, " + "concurrent test runs are on by default") elif (args.concurrent == '0' or args.concurrent == 'off'): args.concurrency = False - print "Warning: Option -c, --concurrent is deprecated, " \ - "use --no-concurrency for non-concurrent test runs" + print("Warning: Option -c, --concurrent is deprecated, " + "use --no-concurrency for non-concurrent test runs") # Ne need for else, since argparse restricts the arguments allowed # If the deprecated tests option was passed print a warning @@ -128,8 +129,8 @@ def main(): # This merges any options passed into the --tests option into the # ones passed into -t or --tests-include and throws out duplicates args.include_tests = list(set(args.include_tests + args.tests)) - print "Warning: Option --tests is deprecated, use " \ - "--include-tests instead" + print("Warning: Option --tests is deprecated, use " + "--include-tests instead") # If resume is requested attempt to load the results file # in the specified path @@ -218,9 +219,9 @@ def main(): json_writer.close_dict() json_writer.file.close() - print - print 'Thank you for running Piglit!' - print 'Results have been written to ' + result_filepath + print() + print('Thank you for running Piglit!') + print('Results have been written to ' + result_filepath) if __name__ == "__main__": diff --git a/piglit-summary-html.py b/piglit-summary-html.py index 299d4f9..c2c2df5 100755 --- a/piglit-summary-html.py +++ b/piglit-summary-html.py @@ -21,6 +21,8 @@ # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +from __future__ import print_function + from getopt import getopt, GetoptError import cgi import os, os.path @@ -281,7 +283,7 @@ Example list file: [ 'other.result' ] ] """ - print USAGE % {'progName': sys.argv[0]} + print(USAGE % {'progName': sys.argv[0]}) sys.exit(1) -- 1.7.10.4 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit