-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix hanging background processes on Sierra #2
- Loading branch information
Showing
19 changed files
with
1,550 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Features: | ||
|
||
Bugs: | ||
|
||
|
||
|
||
___________________ | ||
Archive: | ||
- Notify user when an update is available. @done(17-04-01 17:41) @project(Features) |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# encoding: utf-8 | ||
# | ||
# Copyright © 2015 [email protected] | ||
# Copyright (c) 2015 [email protected] | ||
# | ||
# MIT Licence. See http://opensource.org/licenses/MIT | ||
# | ||
|
@@ -21,7 +21,7 @@ | |
-h, --help Show this message and exit. | ||
""" | ||
|
||
from __future__ import print_function, unicode_literals, absolute_import | ||
from __future__ import print_function, absolute_import | ||
|
||
from collections import namedtuple | ||
from operator import attrgetter | ||
|
@@ -30,10 +30,11 @@ | |
import sys | ||
|
||
import docopt | ||
from workflow import Workflow, ICON_WARNING | ||
from workflow import Workflow3, ICON_WARNING | ||
|
||
log = None | ||
|
||
ICON_UPDATE = 'update-available.png' | ||
UPDATE_SETTINGS = { | ||
'github_slug': 'deanishe/alfred-viscosity' | ||
} | ||
|
@@ -44,12 +45,10 @@ | |
def run_script(script_name, *args): | ||
"""Return output of script `script_name`. | ||
Script must reside in `./scripts` subdirectory and | ||
have extension `.scpt`. | ||
""" | ||
|
||
script = wf.workflowfile('scripts/{0}.scpt'.format(script_name)) | ||
cmd = ['/usr/bin/osascript', script.encode('utf-8')] | ||
cmd += [a.encode('utf-8') for a in args] | ||
|
@@ -70,7 +69,6 @@ def _load_connections(): | |
Returns a list of VPN tuples. | ||
""" | ||
|
||
connections = [] | ||
output = run_script('get_connections').strip() | ||
for line in output.split('\n'): | ||
|
@@ -93,7 +91,8 @@ def _load_connections(): | |
|
||
def load_connections(): | ||
"""Return list of VPN connections. Cache list for 5 seconds.""" | ||
return wf.cached_data('connections', _load_connections, max_age=5) | ||
return wf.cached_data('connections', _load_connections, max_age=0, | ||
session=True) | ||
|
||
|
||
def do_list(args): | ||
|
@@ -113,6 +112,14 @@ def do_list(args): | |
|
||
# --------------------------------------------------------- | ||
# Display active connections at the top if there's no query | ||
nouids = False | ||
if wf.update_available: | ||
nouids = True | ||
wf.add_item('Update available!', | ||
'Action this item to update the workflow', | ||
autocomplete='workflow:update', | ||
valid=False, | ||
icon=ICON_UPDATE) | ||
if not query: | ||
|
||
if len(active_connections) > 1: | ||
|
@@ -124,7 +131,7 @@ def do_list(args): | |
) | ||
|
||
for con in active_connections: | ||
arg = 'disconnect {0}'.format(pipes.quote(con.name)) | ||
arg = u'disconnect {0}'.format(pipes.quote(con.name)) | ||
wf.add_item( | ||
con.name, | ||
'↩ to disconnect', | ||
|
@@ -148,10 +155,10 @@ def do_list(args): | |
if con.active: | ||
continue | ||
|
||
arg = 'connect {0}'.format(pipes.quote(con.name)) | ||
arg = u'connect {0}'.format(pipes.quote(con.name)) | ||
# Only add UID if there are no connected VPNs | ||
# to ensure connected VPNs are shown first | ||
if connected: | ||
if connected or nouids: | ||
uid = None | ||
else: | ||
uid = con.name | ||
|
@@ -181,7 +188,7 @@ def do_connect(args): | |
name = args.get('<name>') | ||
connections = filter_connections(False, name) | ||
for con in connections: | ||
log.debug('Connecting `%s` ...', con.name) | ||
log.debug(u'Connecting `%s` ...', con.name) | ||
run_script('connect_vpn', con.name) | ||
|
||
|
||
|
@@ -190,7 +197,7 @@ def do_disconnect(args): | |
name = args.get('<name>') | ||
connections = filter_connections(True, name) | ||
for con in connections: | ||
log.debug('Disconnecting `%s` ...', con.name) | ||
log.debug(u'Disconnecting `%s` ...', con.name) | ||
run_script('disconnect_vpn', con.name) | ||
|
||
|
||
|
@@ -212,6 +219,6 @@ def main(wf): | |
|
||
|
||
if __name__ == '__main__': | ||
wf = Workflow(update_settings=UPDATE_SETTINGS) | ||
wf = Workflow3(update_settings=UPDATE_SETTINGS) | ||
log = wf.logger | ||
sys.exit(wf.run(main)) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.