From bce2206cae2564eff2e610355711d90ea3d79d23 Mon Sep 17 00:00:00 2001 From: rayx_huang Date: Tue, 19 May 2026 15:45:24 +0800 Subject: [PATCH] fix: make onlbuilder compatible with Python 3 The onlbuilder script used Python 2 syntax (print statements, except comma syntax, identity comparison with literals) which fails on systems without Python 2 installed. - Change shebang to #!/usr/bin/env python - Convert print statements to print() function calls - Replace 'except Exception, e' with 'except Exception as e' - Replace 'is 0' with '== 0' --- docker/tools/onlbuilder | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/tools/onlbuilder b/docker/tools/onlbuilder index eec651df7..7126d2c7b 100755 --- a/docker/tools/onlbuilder +++ b/docker/tools/onlbuilder @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python import os import sys @@ -126,10 +126,10 @@ logger.debug('arguments: %s\n' % vars(ops)) if ops.pull: try: - print "Pulling %s..." % ops.image + print("Pulling %s..." % ops.image) x = subprocess.check_output(('docker', 'pull', ops.image), stderr=subprocess.STDOUT) - print "done." - except subprocess.CalledProcessError, e: + print("done.") + except subprocess.CalledProcessError as e: sys.stderr.write("** Failed to pull the docker image %s (%d):\n\n%s\n" % (ops.image, e.returncode, e.output)) sys.exit(1) @@ -174,7 +174,7 @@ else: g_docker_arguments = "docker run --privileged %(interactive)s -t -e DOCKER_IMAGE=%(image)s --name %(name)s %(ssh_options)s %(volume_options)s " % g_arg_d if ops.isolate is not None: - if len(ops.isolate) is 0: + if len(ops.isolate) == 0: ops.isolate.append(os.getcwd()) isolates = [ os.path.abspath(i) for i in ops.isolate ]