From adf892d08f7e8063bd0a80d2e54b1da6003b2462 Mon Sep 17 00:00:00 2001 From: sdarwin Date: Thu, 9 Apr 2026 14:31:12 -0600 Subject: [PATCH] Reports python2 -> python3 --- docker/python3.12/Dockerfile | 6 ++++++ docker/python3.12/build.sh | 10 +++++++++ reports/src/boost_wide_report.py | 24 +++++++++++---------- reports/src/utils/__init__.py | 24 +++++++++++---------- reports/src/utils/accept_args.py | 7 +++--- reports/src/utils/char_translation_table.py | 15 +++++++++---- reports/src/utils/checked_system.py | 2 +- reports/src/utils/log.py | 2 +- 8 files changed, 59 insertions(+), 31 deletions(-) create mode 100644 docker/python3.12/Dockerfile create mode 100755 docker/python3.12/build.sh diff --git a/docker/python3.12/Dockerfile b/docker/python3.12/Dockerfile new file mode 100644 index 0000000..eefa5da --- /dev/null +++ b/docker/python3.12/Dockerfile @@ -0,0 +1,6 @@ +FROM alpine:3.23 +CMD ["/bin/sh"] +RUN apk add --no-cache python3 py3-pip linux-headers git rsync openssh g++ zlib-dev \ + && ln -sf python3 /usr/bin/python \ + && ln -sf pip3 /usr/bin/pip +WORKDIR /root diff --git a/docker/python3.12/build.sh b/docker/python3.12/build.sh new file mode 100755 index 0000000..1cc59c1 --- /dev/null +++ b/docker/python3.12/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -xe +image=cppalliance/boost_regression_docker:1 +echo image is $image +docker build -t $image . +echo $? +# if [ "$?" = "0" ] ; then +# docker push $image +# fi diff --git a/reports/src/boost_wide_report.py b/reports/src/boost_wide_report.py index 3094f8f..23beb67 100644 --- a/reports/src/boost_wide_report.py +++ b/reports/src/boost_wide_report.py @@ -5,6 +5,8 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +from __future__ import print_function + import shutil import codecs import xml.sax.handler @@ -214,7 +216,7 @@ def _modtime_timestamp( file ): root_paths = [] def shorten( file_path ): - root_paths.sort( lambda x, y: cmp( len(y ), len( x ) ) ) + root_paths.sort( key=lambda x: len(x), reverse=True ) for root in root_paths: if file_path.lower().startswith( root.lower() ): return file_path[ len( root ): ].replace( "\\", "/" ) @@ -280,7 +282,7 @@ def update( self ): try: utils.log( ' Unzipping "%s" ... into "%s"' % ( shorten( self.source_ ), os.path.dirname( self.file_path_ ) ) ) self.unzip_func_( self.source_, os.path.dirname( self.file_path_ ) ) - except Exception, msg: + except Exception as msg: utils.log( ' Skipping "%s" due to errors (%s)' % ( self.source_, msg ) ) @@ -455,7 +457,7 @@ def build_reports( extended_test_results = os.path.join( output_dir, 'extended_test_results.xml' ) if filter_runners == None: - if default_filter_runners.has_key(tag): + if tag in default_filter_runners: filter_runners = default_filter_runners[tag] execute_tasks( @@ -511,7 +513,7 @@ def accept_args( args ): '--comment': '' , '--expected-results': '' , '--failures-markup': '' - , '--reports': string.join( report_types, ',' ) + , '--reports': ','.join( report_types ) , '--boost-report': None , '--tag': None , '--user': None @@ -520,10 +522,10 @@ def accept_args( args ): } utils.accept_args( args_spec, args, options, usage ) - if not options.has_key( '--results-dir' ): + if '--results-dir' not in options: options[ '--results-dir' ] = options[ '--locate-root' ] - if not options.has_key( '--results-prefix' ): + if '--results-prefix' not in options: options[ '--results-prefix' ] = 'all' warnings = [] @@ -536,19 +538,19 @@ def accept_args( args ): , options[ '--comment' ] , options[ '--results-dir' ] , options[ '--results-prefix' ] - , options.has_key( '--dont-collect-logs' ) + , '--dont-collect-logs' in options , options[ '--reports' ].split( ',' ) , options[ '--boost-report' ] , warnings , options[ '--user' ] - , options.has_key( '--upload' ) + , '--upload' in options , options[ '--filter-runners' ] ) def usage(): - print 'Usage: %s [options]' % os.path.basename( sys.argv[0] ) - print ''' + print('Usage: %s [options]' % os.path.basename( sys.argv[0] )) + print(''' \t--locate-root the same as --locate-root in compiler_status \t--tag the tag for the results (i.e. 'trunk') \t--expected-results the file with the results to be compared with @@ -578,7 +580,7 @@ def usage(): \t n - runner comment files \t--filter-runners use only those runners that match specified \t regex (case insensitive) -''' +''') def main(): build_reports( *accept_args( sys.argv[ 1 : ] ) ) diff --git a/reports/src/utils/__init__.py b/reports/src/utils/__init__.py index 6d54208..a862416 100644 --- a/reports/src/utils/__init__.py +++ b/reports/src/utils/__init__.py @@ -1,13 +1,15 @@ -from accept_args import * -from char_translation_table import * -from check_existance import * -from checked_system import * -from libxslt import * -from log import * -from makedirs import * -from rename import * -from tar import * -from zip import * +from __future__ import absolute_import -import sourceforge +from utils.accept_args import * +from utils.char_translation_table import * +from utils.check_existance import * +from utils.checked_system import * +from utils.libxslt import * +from utils.log import * +from utils.makedirs import * +from utils.rename import * +from utils.tar import * +from utils.zip import * + +from utils import sourceforge diff --git a/reports/src/utils/accept_args.py b/reports/src/utils/accept_args.py index b08739f..0f3ffd4 100644 --- a/reports/src/utils/accept_args.py +++ b/reports/src/utils/accept_args.py @@ -8,9 +8,10 @@ def accept_args( args_spec, args, options, usage ): defaults_num = len(options) ( option_pairs, rest_args ) = getopt.getopt( args, '', args_spec ) - map( lambda x: options.__setitem__( x[0], x[1] ), option_pairs ) + for x in option_pairs: + options.__setitem__( x[0], x[1] ) - if ( options.has_key( '--help' ) or len( options.keys() ) == defaults_num ): + if ( '--help' in options or len( options.keys() ) == defaults_num ): usage() sys.exit( 1 ) @@ -25,6 +26,6 @@ def accept_args( args_spec, args, options, usage ): if m: options[ '--%s' % m.group( 'name' ) ] = m.group( 'value' ) else: - raise 'Invalid format of config line "%s"' % l + raise Exception( 'Invalid format of config line "%s"' % l ) return rest_args diff --git a/reports/src/utils/char_translation_table.py b/reports/src/utils/char_translation_table.py index c2d8fb6..057753c 100644 --- a/reports/src/utils/char_translation_table.py +++ b/reports/src/utils/char_translation_table.py @@ -1,4 +1,5 @@ +import sys import string def chr_or_question_mark( c ): @@ -7,7 +8,13 @@ def chr_or_question_mark( c ): else: return '?' -char_translation_table = string.maketrans( - ''.join( map( chr, range(0, 256) ) ) - , ''.join( map( chr_or_question_mark, range(0, 256) ) ) - ) +if sys.version_info[0] >= 3: + char_translation_table = bytes.maketrans( + bytes(range(0, 256)) + , bytes( bytearray( chr_or_question_mark(c).encode('latin-1')[0] for c in range(0, 256) ) ) + ) +else: + char_translation_table = string.maketrans( + ''.join( map( chr, range(0, 256) ) ) + , ''.join( map( chr_or_question_mark, range(0, 256) ) ) + ) diff --git a/reports/src/utils/checked_system.py b/reports/src/utils/checked_system.py index bdb8e8f..b5f3cf6 100644 --- a/reports/src/utils/checked_system.py +++ b/reports/src/utils/checked_system.py @@ -6,7 +6,7 @@ def system( commands ): if sys.platform == 'win32': f = open( 'tmp.cmd', 'w' ) - f.write( string.join( commands, '\n' ) ) + f.write( '\n'.join( commands ) ) f.close() rc = os.system( 'tmp.cmd' ) return rc diff --git a/reports/src/utils/log.py b/reports/src/utils/log.py index 28b1366..458c6e8 100644 --- a/reports/src/utils/log.py +++ b/reports/src/utils/log.py @@ -6,7 +6,7 @@ def log_level(): frames = inspect.stack() level = 0 for i in frames[ 3: ]: - if i[0].f_locals.has_key( '__log__' ): + if '__log__' in i[0].f_locals: level = level + i[0].f_locals[ '__log__' ] return level