Skip to content

Commit

Permalink
Fix exception when there are no local sources given
Browse files Browse the repository at this point in the history
  • Loading branch information
anned20 committed Jun 10, 2019
1 parent 77d51da commit 65d78b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions begoneads/begoneads.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def install(sources, local_sources):
'This program needs to be run as root to work properly')

sources = [i.strip() for i in sources.split(',')]
local_sources = [i.strip() for i in local_sources.split(',')]

if local_sources:
local_sources = [i.strip() for i in local_sources.split(',')]

url_pattern = re.compile(
r'^(?:http|ftp)s?://' # http:// or https://
Expand Down Expand Up @@ -73,19 +75,22 @@ def install(sources, local_sources):

print('✓ Remote hosts collected')

# Collect local host files
local_collector = LocalCollector(local_sources)
local_hosts = ""

if local_sources:
# Collect local host files
local_collector = LocalCollector(local_sources)

print('⋯ Collecting and parsing local hosts')
local_hosts = local_collector.get_result()
print('⋯ Collecting and parsing local hosts')
local_hosts = local_collector.get_result()

print('✓ Local hosts collected')

hosts = "\n".join([
remote_hosts,
local_hosts
])

print('✓ Local hosts collected')

if sys.platform.startswith('win'):
path = r'c:\windows\system32\drivers\etc\hosts'
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def readme():

setup(
name='begoneads',
version='0.0.5',
version='0.0.6',
description='BeGoneAds puts some popular hosts file lists into the hosts file as a adblocker measure.',
long_description=readme(),
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 65d78b3

Please sign in to comment.