Expanded browser section
* Support installing adblock for browsers with no profiles detected * Warn tech about missing browsers if profiles are detected
This commit is contained in:
parent
4130932d58
commit
a5a4278c3e
1 changed files with 24 additions and 25 deletions
|
|
@ -112,8 +112,8 @@ def archive_browser(name):
|
||||||
run_program(cmd)
|
run_program(cmd)
|
||||||
|
|
||||||
def backup_browsers():
|
def backup_browsers():
|
||||||
"""Create backup of all detected browsers."""
|
"""Create backup of all detected browser profiles."""
|
||||||
for name in sorted(browser_data):
|
for name in [k for k, v in sorted(browser_data.items()) if v['profiles']]:
|
||||||
try_and_print(message='{}...'.format(name),
|
try_and_print(message='{}...'.format(name),
|
||||||
function=archive_browser, name=name)
|
function=archive_browser, name=name)
|
||||||
|
|
||||||
|
|
@ -228,10 +228,6 @@ def get_browser_details(name):
|
||||||
profiles.append(
|
profiles.append(
|
||||||
{'name': 'Default', 'path': browser['user_data_path']})
|
{'name': 'Default', 'path': browser['user_data_path']})
|
||||||
|
|
||||||
# Skip browser if there's no profiles
|
|
||||||
if len(profiles) == 0:
|
|
||||||
raise NoProfilesError
|
|
||||||
|
|
||||||
# Get homepages
|
# Get homepages
|
||||||
if browser['base'] == 'ie':
|
if browser['base'] == 'ie':
|
||||||
# IE is set to only have one profile above
|
# IE is set to only have one profile above
|
||||||
|
|
@ -335,12 +331,17 @@ def install_adblock(indent=8, width=32):
|
||||||
for browser in sorted(browser_data):
|
for browser in sorted(browser_data):
|
||||||
exe_path = browser_data[browser].get('exe_path', None)
|
exe_path = browser_data[browser].get('exe_path', None)
|
||||||
function=run_program
|
function=run_program
|
||||||
if exe_path is None:
|
if not exe_path:
|
||||||
print_standard(
|
if browser_data[browser]['profiles']:
|
||||||
'{indent}{browser:<{width}}'.format(
|
print_standard(
|
||||||
indent=' '*indent, width=width, browser=browser+'...'),
|
'{indent}{browser:<{width}}'.format(
|
||||||
end='', flush=True)
|
indent=' '*indent, width=width, browser=browser+'...'),
|
||||||
print_warning('Not installed', timestamp=False)
|
end='', flush=True)
|
||||||
|
print_warning('Profile(s) detected but browser not installed',
|
||||||
|
timestamp=False)
|
||||||
|
else:
|
||||||
|
# Only warn if profile(s) are detected.
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
# Set urls to open
|
# Set urls to open
|
||||||
urls = []
|
urls = []
|
||||||
|
|
@ -391,7 +392,7 @@ def install_adblock(indent=8, width=32):
|
||||||
def list_homepages(indent=8, width=32):
|
def list_homepages(indent=8, width=32):
|
||||||
"""List current homepages for reference."""
|
"""List current homepages for reference."""
|
||||||
|
|
||||||
for browser in sorted(browser_data):
|
for browser in [k for k, v in sorted(browser_data.items()) if v['exe_path']]:
|
||||||
# Skip Chromium-based browsers
|
# Skip Chromium-based browsers
|
||||||
if browser_data[browser]['base'] == 'chromium':
|
if browser_data[browser]['base'] == 'chromium':
|
||||||
print_info(
|
print_info(
|
||||||
|
|
@ -402,27 +403,25 @@ def list_homepages(indent=8, width=32):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# All other browsers
|
# All other browsers
|
||||||
profiles = browser_data[browser].get('profiles', [])
|
print_info('{indent}{browser:<{width}}'.format(
|
||||||
if profiles:
|
indent=' '*indent, width=width, browser=browser+'...'))
|
||||||
print_info('{indent}{browser:<{width}}'.format(
|
for profile in browser_data[browser].get('profiles', []):
|
||||||
indent=' '*indent, width=width, browser=browser+'...'))
|
name = profile.get('name', '?')
|
||||||
for profile in profiles:
|
homepages = profile.get('homepages', [])
|
||||||
_name = profile.get('name', '?')
|
if len(homepages) == 0:
|
||||||
_homepages = profile.get('homepages', [])
|
|
||||||
if len(_homepages) == 0:
|
|
||||||
print_standard(
|
print_standard(
|
||||||
'{indent}{name:<{width}}'.format(
|
'{indent}{name:<{width}}'.format(
|
||||||
indent=' '*indent, width=width, name=_name),
|
indent=' '*indent, width=width, name=name),
|
||||||
end='', flush=True)
|
end='', flush=True)
|
||||||
print_warning('None found', timestamp=False)
|
print_warning('None found', timestamp=False)
|
||||||
else:
|
else:
|
||||||
for page in _homepages:
|
for page in homepages:
|
||||||
print_standard('{indent}{name:<{width}}{page}'.format(
|
print_standard('{indent}{name:<{width}}{page}'.format(
|
||||||
indent=' '*indent, width=width, name=_name, page=page))
|
indent=' '*indent, width=width, name=name, page=page))
|
||||||
|
|
||||||
def reset_browsers(indent=8, width=32):
|
def reset_browsers(indent=8, width=32):
|
||||||
"""Reset all detected browsers to safe defaults."""
|
"""Reset all detected browsers to safe defaults."""
|
||||||
for browser in sorted(browser_data):
|
for browser in [k for k, v in sorted(browser_data.items()) if v['profiles']]:
|
||||||
print_info('{indent}{name}'.format(indent=' '*indent, name=browser))
|
print_info('{indent}{name}'.format(indent=' '*indent, name=browser))
|
||||||
for profile in browser_data[browser]['profiles']:
|
for profile in browser_data[browser]['profiles']:
|
||||||
if browser_data[browser]['base'] == 'chromium':
|
if browser_data[browser]['base'] == 'chromium':
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue