Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
4 changes: 2 additions & 2 deletions src/docopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def formal_usage(printable_usage):

def extras(help, version, options, doc):
if help and any((o.name in ('-h', '--help')) and o.value for o in options):
print(doc.strip("\n"))
print((doc.strip("\n")))
sys.exit()
if version and any(o.name == '--version' and o.value for o in options):
print(version)
Expand All @@ -487,7 +487,7 @@ def extras(help, version, options, doc):

class Dict(dict):
def __repr__(self):
return '{%s}' % ',\n '.join('%r: %r' % i for i in sorted(self.items()))
return '{%s}' % ',\n '.join('%r: %r' % i for i in sorted(self.items(), key=lambda x: str(x)))


def docopt(doc, argv=None, help=True, version=None, options_first=False):
Expand Down
10 changes: 5 additions & 5 deletions src/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<key>escaping</key>
<integer>0</integer>
<key>script</key>
<string>/usr/bin/python vpn.py $action "$1"</string>
<string>/usr/bin/python3 vpn.py $action "$1"</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
Expand Down Expand Up @@ -166,7 +166,7 @@
<key>runningsubtext</key>
<string>Loading VPN information…</string>
<key>script</key>
<string>/usr/bin/python vpn.py list "$1"</string>
<string>/usr/bin/python3 vpn.py list "$1"</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
Expand Down Expand Up @@ -213,7 +213,7 @@
<key>runningsubtext</key>
<string>Loading apps…</string>
<key>script</key>
<string>/usr/bin/python vpn.py conf "$1"</string>
<string>/usr/bin/python3 vpn.py conf "$1"</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
Expand Down Expand Up @@ -337,7 +337,7 @@
echo "query=$query" &gt;&amp;2
app=$( echo "$query" | cut -d: -f2 )

/usr/bin/python vpn.py app "$app"
/usr/bin/python3 vpn.py app "$app"

echo "$app"</string>
<key>scriptargtype</key>
Expand Down Expand Up @@ -477,7 +477,7 @@ or Tunnelblick app from https://tunnelblick.net/</string>
<string>VPN_APP</string>
</array>
<key>version</key>
<string>3.2</string>
<string>3.3</string>
<key>webaddress</key>
<string>https://github.com/deanishe/alfred-vpn-manager</string>
</dict>
Expand Down
36 changes: 17 additions & 19 deletions src/vpn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# encoding: utf-8
#
# Copyright (c) 2015 deanishe@deanishe.net
Expand All @@ -23,7 +23,7 @@
-h, --help Show this message and exit.
"""

from __future__ import print_function, absolute_import


import abc
from collections import namedtuple
Expand Down Expand Up @@ -92,11 +92,9 @@ def timed(name=None):
# 88 88 88
# dP dP dP

class VPNApp(object):
class VPNApp(object, metaclass=abc.ABCMeta):
"""Base class for application classes."""

__metaclass__ = abc.ABCMeta

def __init__(self):
"""Create new initialised `VPNApp`."""
self._info = False
Expand Down Expand Up @@ -142,7 +140,7 @@ def connect(self, name):
"""Connect to named VPN."""
connections = self.filter_connections(name=name, active=False)
for c in connections:
log.info(u'connecting "%s" ...', c.name)
log.info('connecting "%s" ...', c.name)

cmd = self.program + ['connect', c.name]
run_command(cmd)
Expand All @@ -151,7 +149,7 @@ def disconnect(self, name):
"""Disconnect from named VPN."""
connections = self.filter_connections(name=name, active=True)
for c in connections:
log.info(u'disconnecting "%s" ...', c.name)
log.info('disconnecting "%s" ...', c.name)

cmd = self.program + ['disconnect', c.name]
run_command(cmd)
Expand Down Expand Up @@ -204,7 +202,7 @@ def _fetch_connections(self):

data = json.loads(run_command(cmd))

for t in data.items():
for t in list(data.items()):
connections.append(VPN(*t))

return connections
Expand Down Expand Up @@ -291,7 +289,7 @@ def show_update():
"""Add an 'update available!' item."""
if wf.update_available:
wf.add_item('Workflow Update Available!',
u'↩ or ⇥ to install update',
'↩ or ⇥ to install update',
autocomplete='workflow:update',
valid=False,
icon=ICON_UPDATE_AVAILABLE)
Expand All @@ -314,7 +312,7 @@ def do_config(query):

items.append(dict(
title=title,
subtitle=u'↩ or ⇥ to install update',
subtitle='↩ or ⇥ to install update',
autocomplete='workflow:update',
valid=False,
icon=icon,
Expand All @@ -325,26 +323,26 @@ def do_config(query):
for app in get_all_apps():
if app.selected and app.installed:
items.append(dict(
title=u'{} (active)'.format(app.name),
subtitle=u'{} is the active application'.format(app.name),
title='{} (active)'.format(app.name),
subtitle='{} is the active application'.format(app.name),
icon=app.info.path,
icontype='fileicon',
valid=False,
))
else:
if app.installed:
items.append(dict(
title=u'{}'.format(app.name),
subtitle=u'↩ to use {}'.format(app.name),
title='{}'.format(app.name),
subtitle='↩ to use {}'.format(app.name),
icon=app.info.path,
icontype='fileicon',
arg='app:' + app.name,
valid=True,
))
else:
items.append(dict(
title=u'{} (not installed)'.format(app.name),
subtitle=u'↩ to get {}'.format(app.name),
title='{} (not installed)'.format(app.name),
subtitle='↩ to get {}'.format(app.name),
icon=ICON_WEB,
arg=app.download_url,
valid=True,
Expand Down Expand Up @@ -404,7 +402,7 @@ def do_list(query):
try:
app = get_app()
except NotInstalled as err:
wf.add_item(err.message,
wf.add_item(str(err),
'Use "vpnconf" to change the application',
valid=False,
icon=ICON_WARNING)
Expand Down Expand Up @@ -473,7 +471,7 @@ def do_list(query):

it = wf.add_item(
con.name,
u'↩ to connect',
'↩ to connect',
uid=uid,
arg=con.name,
valid=True,
Expand Down Expand Up @@ -512,7 +510,7 @@ def main(wf):
"""Run workflow."""
args = docopt.docopt(__doc__, wf.args, version=wf.version)

log.debug('args : %r', args)
log.debug('args : !r', args)

if args['list']:
return do_list(args.get('<query>'))
Expand Down
2 changes: 1 addition & 1 deletion src/workflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# encoding: utf-8
#
# Copyright (c) 2014 Dean Jackson <deanishe@deanishe.net>
Expand Down
12 changes: 6 additions & 6 deletions src/workflow/background.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# encoding: utf-8
#
# Copyright (c) 2014 deanishe@deanishe.net
Expand All @@ -17,15 +17,15 @@
and examples.
"""

from __future__ import print_function, unicode_literals


import signal
import sys
import os
import subprocess
import pickle

from workflow import Workflow
from .workflow import Workflow

__all__ = ['is_running', 'run_in_background']

Expand Down Expand Up @@ -96,7 +96,7 @@ def _job_pid(name):
if not os.path.exists(pidfile):
return

with open(pidfile, 'rb') as fp:
with open(pidfile, 'r') as fp:
pid = int(fp.read())

if _process_exists(pid):
Expand Down Expand Up @@ -143,7 +143,7 @@ def _fork_and_exit_parent(errmsg, wait=False, write=False):
if pid > 0:
if write: # write PID of child process to `pidfile`
tmp = pidfile + '.tmp'
with open(tmp, 'wb') as fp:
with open(tmp, 'w') as fp:
fp.write(str(pid))
os.rename(tmp, pidfile)
if wait: # wait for child process to exit
Expand Down Expand Up @@ -233,7 +233,7 @@ def run_in_background(name, args, **kwargs):
_log().debug('[%s] command cached: %s', name, argcache)

# Call this script
cmd = ['/usr/bin/python', __file__, name]
cmd = ['/usr/bin/python3', __file__, name]
_log().debug('[%s] passing job to background runner: %r', name, cmd)
retcode = subprocess.call(cmd)

Expand Down
6 changes: 3 additions & 3 deletions src/workflow/notify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# encoding: utf-8
#
# Copyright (c) 2015 deanishe@deanishe.net
Expand All @@ -23,7 +23,7 @@
icon and then calls the application to post notifications.
"""

from __future__ import print_function, unicode_literals


import os
import plistlib
Expand All @@ -34,7 +34,7 @@
import tempfile
import uuid

import workflow
from . import workflow


_wf = None
Expand Down
14 changes: 7 additions & 7 deletions src/workflow/update.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# encoding: utf-8
#
# Copyright (c) 2014 Fabio Niephaus <fabio.niephaus@gmail.com>,
Expand All @@ -21,7 +21,7 @@

"""

from __future__ import print_function, unicode_literals


from collections import defaultdict
from functools import total_ordering
Expand All @@ -31,8 +31,8 @@
import re
import subprocess

import workflow
import web
from . import workflow
from . import web

# __all__ = []

Expand Down Expand Up @@ -119,7 +119,7 @@ def from_releases(cls, js):
release['prerelease']))

valid = True
for ext, n in dupes.items():
for ext, n in list(dupes.items()):
if n > 1:
wf().logger.debug('ignored release "%s": multiple assets '
'with extension "%s"', tag, ext)
Expand All @@ -143,7 +143,7 @@ def __init__(self, url, filename, version, prerelease=False):
pre-release. Defaults to False.

"""
if isinstance(version, basestring):
if isinstance(version, str):
version = Version(version)

self.url = url
Expand Down Expand Up @@ -172,7 +172,7 @@ def __str__(self):
'version={dl.version!r}, '
'prerelease={dl.prerelease!r})'.format(dl=self))

return u.encode('utf-8')
return u

def __repr__(self):
"""Code-like representation of `Download`."""
Expand Down
Loading