diff options
Diffstat (limited to 'indra/newview/viewer_manifest.py')
-rwxr-xr-x | indra/newview/viewer_manifest.py | 109 |
1 files changed, 54 insertions, 55 deletions
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index a814bd2849..7426938454 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """\ @file viewer_manifest.py @author Ryan Williams @@ -75,7 +75,7 @@ class ViewerManifest(LLManifest): # include the extracted list of contributors contributions_path = "../../doc/contributions.txt" contributor_names = self.extract_names(contributions_path) - self.put_in_file(contributor_names, "contributors.txt", src=contributions_path) + self.put_in_file(contributor_names.encode(), "contributors.txt", src=contributions_path) # ... and the default camera position settings self.path("camera") @@ -114,17 +114,17 @@ class ViewerManifest(LLManifest): if sourceid: settings_install['sourceid'] = settings_template['sourceid'].copy() settings_install['sourceid']['Value'] = sourceid - print "Set sourceid in settings_install.xml to '%s'" % sourceid + print("Set sourceid in settings_install.xml to '%s'" % sourceid) if self.args.get('channel_suffix'): settings_install['CmdLineChannel'] = settings_template['CmdLineChannel'].copy() settings_install['CmdLineChannel']['Value'] = self.channel_with_pkg_suffix() - print "Set CmdLineChannel in settings_install.xml to '%s'" % self.channel_with_pkg_suffix() + print("Set CmdLineChannel in settings_install.xml to '%s'" % self.channel_with_pkg_suffix()) if self.args.get('grid'): settings_install['CmdLineGridChoice'] = settings_template['CmdLineGridChoice'].copy() settings_install['CmdLineGridChoice']['Value'] = self.grid() - print "Set CmdLineGridChoice in settings_install.xml to '%s'" % self.grid() + print("Set CmdLineGridChoice in settings_install.xml to '%s'" % self.grid()) # put_in_file(src=) need not be an actual pathname; it # only needs to be non-empty @@ -184,7 +184,7 @@ class ViewerManifest(LLManifest): #we likely no longer need the test, since we will throw an exception above, but belt and suspenders and we get the #return code for free. if not self.path2basename(os.pardir, "build_data.json"): - print "No build_data.json file" + print("No build_data.json file") def finish_build_data_dict(self, build_data_dict): return build_data_dict @@ -263,13 +263,13 @@ class ViewerManifest(LLManifest): return "icons/" + self.channel_type() def extract_names(self,src): + """Extract contributor names from source file, returns string""" try: - contrib_file = open(src,'r') + with open(src, 'r') as contrib_file: + lines = contrib_file.readlines() except IOError: - print "Failed to open '%s'" % src + print("Failed to open '%s'" % src) raise - lines = contrib_file.readlines() - contrib_file.close() # All lines up to and including the first blank line are the file header; skip them lines.reverse() # so that pop will pull from first to last line @@ -305,7 +305,7 @@ class ViewerManifest(LLManifest): """ Like ln -sf, but uses os.symlink() instead of running ln. This creates a symlink at 'dst' that points to 'src' -- see: - https://docs.python.org/2/library/os.html#os.symlink + https://docs.python.org/3/library/os.html#os.symlink If you omit 'dst', this creates a symlink with basename(src) at get_dst_prefix() -- in other words: put a symlink to this pathname @@ -367,11 +367,11 @@ class ViewerManifest(LLManifest): os.remove(dst) os.symlink(src, dst) elif os.path.isdir(dst): - print "Requested symlink (%s) exists but is a directory; replacing" % dst + print("Requested symlink (%s) exists but is a directory; replacing" % dst) shutil.rmtree(dst) os.symlink(src, dst) elif os.path.exists(dst): - print "Requested symlink (%s) exists but is a file; replacing" % dst + print("Requested symlink (%s) exists but is a file; replacing" % dst) os.remove(dst) os.symlink(src, dst) else: @@ -379,8 +379,8 @@ class ViewerManifest(LLManifest): raise except Exception as err: # report - print "Can't symlink %r -> %r: %s: %s" % \ - (dst, src, err.__class__.__name__, err) + print("Can't symlink %r -> %r: %s: %s" % \ + (dst, src, err.__class__.__name__, err)) # if caller asked us not to catch, re-raise this exception if not catch: raise @@ -441,7 +441,7 @@ class WindowsManifest(ViewerManifest): else: raise Exception("Directories are not supported by test_CRT_and_copy_action()") else: - print "Doesn't exist:", src + print("Doesn't exist:", src) def test_for_no_msvcrt_manifest_and_copy_action(self, src, dst): # This is used to test that no manifest for the msvcrt exists. @@ -470,7 +470,7 @@ class WindowsManifest(ViewerManifest): else: raise Exception("Directories are not supported by test_CRT_and_copy_action()") else: - print "Doesn't exist:", src + print("Doesn't exist:", src) def construct(self): super(WindowsManifest, self).construct() @@ -508,8 +508,8 @@ class WindowsManifest(ViewerManifest): try: self.path("glod.dll") except RuntimeError as err: - print err.message - print "Skipping GLOD library (assumming linked statically)" + print(err.message) + print("Skipping GLOD library (assumming linked statically)") # Get fmodstudio dll if needed if self.args['fmodstudio'] == 'ON': @@ -691,8 +691,7 @@ class WindowsManifest(ViewerManifest): result = "" dest_files = [pair[1] for pair in self.file_list if pair[0] and os.path.isfile(pair[1])] # sort deepest hierarchy first - dest_files.sort(lambda a,b: cmp(a.count(os.path.sep),b.count(os.path.sep)) or cmp(a,b)) - dest_files.reverse() + dest_files.sort(key=lambda f: (f.count(os.path.sep), f), reverse=True) out_path = None for pkg_file in dest_files: rel_file = os.path.normpath(pkg_file.replace(self.get_dst_prefix()+os.path.sep,'')) @@ -715,8 +714,7 @@ class WindowsManifest(ViewerManifest): for d in deleted_file_dirs: deleted_dirs.extend(path_ancestors(d)) # sort deepest hierarchy first - deleted_dirs.sort(lambda a,b: cmp(a.count(os.path.sep),b.count(os.path.sep)) or cmp(a,b)) - deleted_dirs.reverse() + deleted_dirs.sort(key=lambda f: (f.count(os.path.sep), f), reverse=True) prev = None for d in deleted_dirs: if d != prev: # skip duplicates @@ -802,19 +800,19 @@ class WindowsManifest(ViewerManifest): installer_created=False nsis_attempts=3 nsis_retry_wait=15 - for attempt in xrange(nsis_attempts): + for attempt in range(nsis_attempts): try: self.run_command([NSIS_path, '/V2', self.dst_path_of(tempfile)]) except ManifestError as err: if attempt+1 < nsis_attempts: - print >> sys.stderr, "nsis failed, waiting %d seconds before retrying" % nsis_retry_wait + print("nsis failed, waiting %d seconds before retrying" % nsis_retry_wait, file=sys.stderr) time.sleep(nsis_retry_wait) nsis_retry_wait*=2 else: # NSIS worked! Done! break else: - print >> sys.stderr, "Maximum nsis attempts exceeded; giving up" + print("Maximum nsis attempts exceeded; giving up", file=sys.stderr) raise self.sign(installer_file) @@ -826,10 +824,10 @@ class WindowsManifest(ViewerManifest): python = os.environ.get('PYTHON', sys.executable) if os.path.exists(sign_py): dst_path = self.dst_path_of(exe) - print "about to run signing of: ", dst_path + print("about to run signing of: ", dst_path) self.run_command([python, sign_py, dst_path]) else: - print "Skipping code signing of %s %s: %s not found" % (self.dst_path_of(exe), exe, sign_py) + print("Skipping code signing of %s %s: %s not found" % (self.dst_path_of(exe), exe, sign_py)) def escape_slashes(self, path): return path.replace('\\', '\\\\\\\\') @@ -873,14 +871,15 @@ class DarwinManifest(ViewerManifest): if bugsplat_db: # Inject BugsplatServerURL into Info.plist if provided. Info_plist = self.dst_path_of("Info.plist") - Info = plistlib.readPlist(Info_plist) - # https://www.bugsplat.com/docs/platforms/os-x#configuration - Info["BugsplatServerURL"] = \ - "https://{}.bugsplat.com/".format(bugsplat_db) - self.put_in_file( - plistlib.writePlistToString(Info), - os.path.basename(Info_plist), - "Info.plist") + with open(Info_plist, 'rb') as f: + Info = plistlib.load(f) + # https://www.bugsplat.com/docs/platforms/os-x#configuration + Info["BugsplatServerURL"] = \ + "https://{}.bugsplat.com/".format(bugsplat_db) + self.put_in_file( + plistlib.dumps(Info), + os.path.basename(Info_plist), + "Info.plist") # CEF framework goes inside Contents/Frameworks. # Remember where we parked this car. @@ -1006,10 +1005,10 @@ class DarwinManifest(ViewerManifest): added = [os.path.relpath(d, self.get_dst_prefix()) for s, d in self.file_list[oldlen:]] except MissingError as err: - print >> sys.stderr, "Warning: "+err.msg + print("Warning: "+err.msg, file=sys.stderr) added = [] if not added: - print "Skipping %s" % dst + print("Skipping %s" % dst) return added # dylibs is a list of all the .dylib files we expect to need @@ -1203,7 +1202,7 @@ class DarwinManifest(ViewerManifest): # mount the image and get the name of the mount point and device node try: - hdi_output = subprocess.check_output(['hdiutil', 'attach', '-private', sparsename]) + hdi_output = subprocess.check_output(['hdiutil', 'attach', '-private', sparsename], text=True) except subprocess.CalledProcessError as err: sys.exit("failed to mount image at '%s'" % sparsename) @@ -1228,11 +1227,11 @@ class DarwinManifest(ViewerManifest): if not os.path.exists (self.src_path_of(dmg_template)): dmg_template = os.path.join ('installers', 'darwin', 'release-dmg') - for s,d in {self.get_dst_prefix():app_name + ".app", + for s,d in list({self.get_dst_prefix():app_name + ".app", os.path.join(dmg_template, "_VolumeIcon.icns"): ".VolumeIcon.icns", os.path.join(dmg_template, "background.jpg"): "background.jpg", - os.path.join(dmg_template, "_DS_Store"): ".DS_Store"}.items(): - print "Copying to dmg", s, d + os.path.join(dmg_template, "_DS_Store"): ".DS_Store"}.items()): + print("Copying to dmg", s, d) self.copy_action(self.src_path_of(s), os.path.join(volpath, d)) # Hide the background image, DS_Store file, and volume icon file (set their "visible" bit) @@ -1257,7 +1256,7 @@ class DarwinManifest(ViewerManifest): # and invalidate the signatures. if 'signature' in self.args: app_in_dmg=os.path.join(volpath,self.app_name()+".app") - print "Attempting to sign '%s'" % app_in_dmg + print("Attempting to sign '%s'" % app_in_dmg) identity = self.args['signature'] if identity == '': identity = 'Developer ID Application' @@ -1308,11 +1307,11 @@ class DarwinManifest(ViewerManifest): signed=True # if no exception was raised, the codesign worked except ManifestError as err: if sign_attempts: - print >> sys.stderr, "codesign failed, waiting %d seconds before retrying" % sign_retry_wait + print("codesign failed, waiting %d seconds before retrying" % sign_retry_wait, file=sys.stderr) time.sleep(sign_retry_wait) sign_retry_wait*=2 else: - print >> sys.stderr, "Maximum codesign attempts exceeded; giving up" + print("Maximum codesign attempts exceeded; giving up", file=sys.stderr) raise self.run_command(['spctl', '-a', '-texec', '-vvvv', app_in_dmg]) self.run_command([self.src_path_of("installers/darwin/apple-notarize.sh"), app_in_dmg]) @@ -1321,7 +1320,7 @@ class DarwinManifest(ViewerManifest): # Unmount the image even if exceptions from any of the above self.run_command(['hdiutil', 'detach', '-force', devfile]) - print "Converting temp disk image to final disk image" + print("Converting temp disk image to final disk image") self.run_command(['hdiutil', 'convert', sparsename, '-format', 'UDZO', '-imagekey', 'zlib-level=9', '-o', finalname]) # get rid of the temp file @@ -1378,7 +1377,7 @@ class LinuxManifest(ViewerManifest): # Get the icons based on the channel type icon_path = self.icon_path() - print "DEBUG: icon_path '%s'" % icon_path + print("DEBUG: icon_path '%s'" % icon_path) with self.prefix(src=icon_path) : self.path("secondlife_256.png","secondlife_icon.png") with self.prefix(dst="res-sdl") : @@ -1399,7 +1398,7 @@ class LinuxManifest(ViewerManifest): # llcommon if not self.path("../llcommon/libllcommon.so", "lib/libllcommon.so"): - print "Skipping llcommon.so (assuming llcommon was linked statically)" + print("Skipping llcommon.so (assuming llcommon was linked statically)") self.path("featuretable_linux.txt") @@ -1434,14 +1433,14 @@ class LinuxManifest(ViewerManifest): '--numeric-owner', '-cjf', tempname + '.tar.bz2', installer_name]) else: - print "Skipping %s.tar.bz2 for non-Release build (%s)" % \ - (installer_name, self.args['buildtype']) + print("Skipping %s.tar.bz2 for non-Release build (%s)" % \ + (installer_name, self.args['buildtype'])) finally: self.run_command(["mv", tempname, realname]) def strip_binaries(self): if self.args['buildtype'].lower() == 'release' and self.is_packaging_viewer(): - print "* Going strip-crazy on the packaged binaries, since this is a RELEASE build" + print("* Going strip-crazy on the packaged binaries, since this is a RELEASE build") # makes some small assumptions about our packaged dir structure self.run_command( ["find"] + @@ -1508,7 +1507,7 @@ class Linux_i686_Manifest(LinuxManifest): self.path("libtcmalloc.so*") #formerly called google perf tools pass except: - print "tcmalloc files not found, skipping" + print("tcmalloc files not found, skipping") pass if self.args['fmodstudio'] == 'ON': @@ -1518,7 +1517,7 @@ class Linux_i686_Manifest(LinuxManifest): self.path("libfmod.so") pass except: - print "Skipping libfmod.so - not found" + print("Skipping libfmod.so - not found") pass # Vivox runtimes @@ -1547,9 +1546,9 @@ class Linux_x86_64_Manifest(LinuxManifest): if __name__ == "__main__": # Report our own command line so that, in case of trouble, a developer can # manually rerun the same command. - print('%s \\\n%s' % + print(('%s \\\n%s' % (sys.executable, - ' '.join((("'%s'" % arg) if ' ' in arg else arg) for arg in sys.argv))) + ' '.join((("'%s'" % arg) if ' ' in arg else arg) for arg in sys.argv)))) # fmodstudio and openal can be used simultaneously and controled by environment extra_arguments = [ dict(name='bugsplat', description="""BugSplat database to which to post crashes, |