Detect and update browsers in Install SW Bundle

* Fixes issue #65
This commit is contained in:
2Shirt 2019-03-19 20:31:00 -06:00
parent 1e21b1bd59
commit 26199cf271
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
3 changed files with 35 additions and 9 deletions

View file

@ -388,6 +388,12 @@ def install_adblock(indent=8, width=32, just_firefox=False):
cmd=[exe_path, *urls], check=False) cmd=[exe_path, *urls], check=False)
def is_installed(browser_name):
"""Checks if browser is installed based on exe_path, returns bool."""
browser_name = browser_name.replace(' Chromium', '')
return bool(browser_data.get(browser_name, {}).get('exe_path', False))
def list_homepages(indent=8, width=32): def list_homepages(indent=8, width=32):
"""List current homepages for reference.""" """List current homepages for reference."""
browser_list = [k for k, v in sorted(browser_data.items()) if v['exe_path']] browser_list = [k for k, v in sorted(browser_data.items()) if v['exe_path']]
@ -437,13 +443,20 @@ def reset_browsers(indent=8, width=32):
other_results=other_results, profile=profile) other_results=other_results, profile=profile)
def scan_for_browsers(just_firefox=False, skip_ie=False): def scan_for_browsers(just_firefox=False, silent=False, skip_ie=False):
"""Scan system for any supported browsers.""" """Scan system for any supported browsers."""
for name, details in sorted(SUPPORTED_BROWSERS.items()): for name, details in sorted(SUPPORTED_BROWSERS.items()):
if just_firefox and details['base'] != 'mozilla': if just_firefox and details['base'] != 'mozilla':
continue continue
if skip_ie and details['base'] == 'ie': if skip_ie and details['base'] == 'ie':
continue continue
if silent:
try:
get_browser_details(name)
except Exception:
# Ignore errors in silent mode
pass
else:
try_and_print(message='{}...'.format(name), try_and_print(message='{}...'.format(name),
function=get_browser_details, cs='Detected', function=get_browser_details, cs='Detected',
other_results=other_results, name=name) other_results=other_results, name=name)

View file

@ -1,5 +1,6 @@
# Wizard Kit: Functions - Setup # Wizard Kit: Functions - Setup
from functions.browsers import *
from functions.update import * from functions.update import *
from settings.setup import * from settings.setup import *
from settings.sources import * from settings.sources import *
@ -239,10 +240,18 @@ def install_firefox_extensions():
run_program(cmd) run_program(cmd)
def install_ninite_bundle(mse=False, libreoffice=False): def install_ninite_bundle(browsers_only=False, mse=False, libreoffice=False):
"""Run Ninite installer(s), returns list of Popen objects.""" """Run Ninite installer(s), returns list of Popen objects."""
popen_objects = [] popen_objects = []
if global_vars['OS']['Version'] in ('8', '8.1', '10'): if browsers_only:
installer_path = r'{BaseDir}\Installers\Extras\Web Browsers'.format(
**global_vars)
scan_for_browsers(skip_ie=True, silent=True)
for browser in ('Google Chrome', 'Mozilla Firefox', 'Opera Chromium'):
if is_installed(browser):
cmd = r'{}\{}.exe'.format(installer_path, browser)
popen_objects.append(popen_program(cmd))
elif global_vars['OS']['Version'] in ('8', '8.1', '10'):
# Modern selection # Modern selection
popen_objects.append( popen_objects.append(
popen_program(r'{BaseDir}\Installers\Extras\Bundles\Modern.exe'.format( popen_program(r'{BaseDir}\Installers\Extras\Bundles\Modern.exe'.format(

View file

@ -28,7 +28,7 @@ if __name__ == '__main__':
answer_extensions = D7_MODE or ask('Install Extensions?') answer_extensions = D7_MODE or ask('Install Extensions?')
answer_vcr = D7_MODE or ask('Install Visual C++ Runtimes?') answer_vcr = D7_MODE or ask('Install Visual C++ Runtimes?')
if D7_MODE: if D7_MODE:
answer_ninite = False answer_ninite = True
answer_mse = False answer_mse = False
else: else:
answer_ninite = ask('Install Ninite Bundle?') answer_ninite = ask('Install Ninite Bundle?')
@ -42,9 +42,13 @@ if __name__ == '__main__':
if answer_vcr: if answer_vcr:
install_vcredists() install_vcredists()
if answer_ninite: if answer_ninite:
result = try_and_print(message='Ninite bundle...', message='Ninite bundle...'
if D7_MODE:
message='Updating browsers...'
result = try_and_print(message=message,
function=install_ninite_bundle, cs='Started', function=install_ninite_bundle, cs='Started',
mse=answer_mse, other_results=other_results) browsers_only=D7_MODE, mse=answer_mse,
other_results=other_results)
for proc in result['Out']: for proc in result['Out']:
# Wait for all processes to finish # Wait for all processes to finish
proc.wait() proc.wait()