Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Commit

Permalink
fixed cacheing bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
atticusmatticus committed Jun 3, 2020
1 parent d7d6d32 commit c8426f0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
Binary file modified MullvadVPN.alfredworkflow
Binary file not shown.
9 changes: 9 additions & 0 deletions src/mullvad.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ def get_version():

def connection_status():
for status in get_connection():
# print 'status:', status
stat = str(status.split()[2])
# print 'stat:', stat
if stat == 'Connected':
countryString, cityString = get_country_city()
# print '{} to: {} {}'.format(stat, cityString, countryString).decode('utf8')
# print ' '.join(status.split()[4:])+'. Select to Disconnect.'
wf.add_item('{} to: {} {}'.format(stat, cityString, countryString).decode('utf8'),
subtitle=' '.join(status.split()[4:])+'. Select to Disconnect.',
arg='/usr/local/bin/mullvad disconnect',
Expand All @@ -72,16 +76,21 @@ def connection_status():

def get_country_city():
countryCodeSearch = '({})'.format(get_protocol()[-1])
# print countryCodeSearch
cityCodeSearch = '({})'.format(get_protocol()[-2][0:3])
# print cityCodeSearch
countries = wf.cached_data('mullvad_country_list',
get_country_list,
max_age=432000)
# print countries
index = [i for i,s in enumerate(countries) if countryCodeSearch in s][0]
relayList = wf.cached_data('mullvad_relay_list',
get_relay_list,
max_age=432000)
countryString = countries[index].split()[:-1][0]
# print countryString
cityString = ' '.join([city[0] for city in relayList[index][1:] if cityCodeSearch in city[0]][0].split()[:-1])
# print cityString
return countryString, cityString


Expand Down
2 changes: 1 addition & 1 deletion src/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1
0.2
Binary file added src/workflow/update.pyc
Binary file not shown.

0 comments on commit c8426f0

Please sign in to comment.