From 0e77a1c32729b82ae15aeec0dc23bc5318e05944 Mon Sep 17 00:00:00 2001 From: ruffsl Date: Fri, 31 Mar 2023 16:06:09 +0000 Subject: [PATCH 1/2] Update shebang to python3 --- get_local_models.py | 2 +- webify_models_v2.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/get_local_models.py b/get_local_models.py index c4e0ca39..666a1401 100755 --- a/get_local_models.py +++ b/get_local_models.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 from __future__ import print_function import sys diff --git a/webify_models_v2.py b/webify_models_v2.py index 572c0bfc..c55aad5e 100755 --- a/webify_models_v2.py +++ b/webify_models_v2.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # A script to update gazebo models to be web-friendly. # It converts all textures to png format and make sure they are From a3b48582e93cbd89254502553e7ace07f74e3c8b Mon Sep 17 00:00:00 2001 From: ruffsl Date: Fri, 31 Mar 2023 16:07:31 +0000 Subject: [PATCH 2/2] Update code to python3 --- webify_models_v2.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/webify_models_v2.py b/webify_models_v2.py index c55aad5e..1903a493 100755 --- a/webify_models_v2.py +++ b/webify_models_v2.py @@ -56,14 +56,14 @@ if texture_dir != dest_dir: cmd = ['mv', dest_path, texture_dir] - print cmd + print(cmd) subprocess.check_call(cmd) # update texture path in dae files if format.lower() in ['dae']: sed_cmd = ["sed", "-i", "-e", 's/\(\.tga\|\.tiff\|\.tif\|\.jpg\|\.jpeg\|\.gif\)/\.png/g', file] - print sed_cmd + print(sed_cmd) subprocess.check_call(sed_cmd) # find relatvie path to texture dir @@ -79,21 +79,21 @@ # replace dae file png references to texture path sed_cmd = ["sed", "-i","-e", 's/\(>\)\(.*\/\)\(.*\.png\)/\\1'+ relative_path + 'materials\/textures\/\\3/g', file] - print sed_cmd + print(sed_cmd) subprocess.check_call(sed_cmd) sed_cmd = ["sed", "-i","-e", '/[a-zA-Z0-9_\.\/\-]\+materials\/textures/!s/\([a-zA-Z0-9_\-]\+\)\(\.png\W\)/'+ relative_path + 'materials\/textures\/\\1\\2/g', file] - print sed_cmd + print(sed_cmd) subprocess.check_call(sed_cmd) if format.lower() in ['material', 'txt', 'sdf']: sed_cmd = ["sed", "-i", "-e", 's/\(\.tga\|\.tiff\|\.tif\|\.jpg\|\.jpeg\|\.gif\)/\.png/g', file] - print sed_cmd + print(sed_cmd) subprocess.check_call(sed_cmd) - except Exception, e: - print "error %s" % e + except Exception as e: + print("error %s" % e) raise