From 8dd6d4755734ed37c1b98dfdefce3ca6bc65f1f6 Mon Sep 17 00:00:00 2001 From: Mathew Robinson Date: Tue, 19 Feb 2019 10:50:57 -0500 Subject: SERVER-32295 Support Python 3 --- src/mongo/installer/compass/install_compass.in | 21 +++++++++------------ src/mongo/installer/msi/SConscript | 8 ++++---- 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'src/mongo/installer') diff --git a/src/mongo/installer/compass/install_compass.in b/src/mongo/installer/compass/install_compass.in index 87f99dafd48..9f922bc8ce5 100755 --- a/src/mongo/installer/compass/install_compass.in +++ b/src/mongo/installer/compass/install_compass.in @@ -63,7 +63,7 @@ def download_pkg(link, pkg_format=''): ' to download the compass installer for your platform.' try: - out = subprocess.check_output(['file', filename]) + out = subprocess.check_output(['file', filename]).decode('utf-8') except subprocess.CalledProcessError as error: print 'Got an unexpected error checking file type %s' % error sys.exit(1) @@ -80,8 +80,9 @@ def install_mac(dmg): tmp = tempfile.mkdtemp() with open(os.devnull, 'w') as fnull: try: - subprocess.check_call(['hdiutil', 'attach', '-nobrowse', '-noautoopen', - '-mountpoint', tmp, dmg], stdout=fnull, stderr=fnull) + subprocess.check_call( + ['hdiutil', 'attach', '-nobrowse', '-noautoopen', '-mountpoint', tmp, dmg], + stdout=fnull, stderr=fnull) except subprocess.CalledProcessError as error: print 'Problem running hdiutil: %s' % error @@ -98,16 +99,13 @@ def install_mac(dmg): except IOError: print 'Unknown error copying MongoDB Compass to /Applications/' finally: - subprocess.check_call( - ['hdiutil', 'detach', tmp], stdout=fnull, stderr=fnull) + subprocess.check_call(['hdiutil', 'detach', tmp], stdout=fnull, stderr=fnull) if path.isdir('/Applications/MongoDB Compass.app'): - subprocess.check_call( - ['open', '/Applications/MongoDB Compass.app']) + subprocess.check_call(['open', '/Applications/MongoDB Compass.app']) return if path.isdir('/Applications/MongoDB Compass Community.app'): - subprocess.check_call( - ['open', '/Applications/MongoDB Compass Community.app']) + subprocess.check_call(['open', '/Applications/MongoDB Compass Community.app']) return @@ -135,9 +133,8 @@ def is_supported_distro(): if (distro_name == 'Ubuntu' and float(version_number) >= 14.04): return True - if ((distro_name == 'Red Hat Enterprise Linux Server' or - 'CentOS' in distro_name) and - (float(version_number) >= 7.0)): + if ((distro_name == 'Red Hat Enterprise Linux Server' or 'CentOS' in distro_name) + and (float(version_number) >= 7.0)): return True return False diff --git a/src/mongo/installer/msi/SConscript b/src/mongo/installer/msi/SConscript index 32efbc03893..84403c73c92 100644 --- a/src/mongo/installer/msi/SConscript +++ b/src/mongo/installer/msi/SConscript @@ -11,7 +11,7 @@ if not env.TargetOSIs('windows'): import re import subprocess -import _winreg +import winreg env = env.Clone() @@ -40,12 +40,12 @@ if programfilesx86 is None: programfilesx86 = "C:\\Program Files (x86)" # Use vswhere (it has a fixed stable path) to query where Visual Studio is installed. -vsinstall_path = subprocess.check_output([os.path.join(programfilesx86, "Microsoft Visual Studio", "Installer", "vswhere.exe"), "-version", "[15.0,16.0)", "-property", "installationPath", "-nologo"]).strip() +vsinstall_path = subprocess.check_output([os.path.join(programfilesx86, "Microsoft Visual Studio", "Installer", "vswhere.exe"), "-version", "[15.0,16.0)", "-property", "installationPath", "-nologo"]).decode('utf-8').strip() # Check the registry key that has the runtime lib version try: - vsruntime_key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64") - vslib_version,vslib_version_type = _winreg.QueryValueEx(vsruntime_key, "Version") + vsruntime_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64") + vslib_version,vslib_version_type = winreg.QueryValueEx(vsruntime_key, "Version") except WindowsError: print("Visual Studio Runtime not found in registry, disabling msi installer") Return() -- cgit v1.2.1