Skip to content

Commit

Permalink
Update Alfred-Workflow #5
Browse files Browse the repository at this point in the history
  • Loading branch information
deanishe committed Dec 18, 2017
1 parent 5b2d4ef commit d56a483
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion src/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ or Tunnelblick app from https://tunnelblick.net/</string>
<string>Viscosity</string>
</dict>
<key>version</key>
<string>3.0</string>
<string>3.0.1</string>
<key>webaddress</key>
<string>https://github.com/deanishe/alfred-vpn-manager</string>
</dict>
Expand Down
1 change: 1 addition & 0 deletions src/vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def info(self):
"""Return application info or `None` if not installed."""
if self._info is False:
self._info = appinfo(self.name)
log.debug('appinfo=%r', self._info)
return self._info

@property
Expand Down
30 changes: 12 additions & 18 deletions src/workflow/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,27 +232,21 @@ def appinfo(name):
Returns:
AppInfo: :class:`AppInfo` tuple or ``None`` if app isn't found.
"""
cmd = ['/usr/bin/lsappinfo', 'info', name]
output = run_command(cmd).strip()
if not output: # Application isn't installed
return None

path = bid = None
for line in output.split('\n'):
line = line.strip()
if '=' in line:
k, v = line.split('=', 1)
v = v.strip('"')
cmd = ['mdfind', '-onlyin', '/',
'(kMDItemContentTypeTree == com.apple.application &&'
'(kMDItemDisplayName == "{0}" || kMDItemFSName == "{0}.app"))'
.format(name)]

if k == 'bundleID':
bid = v
elif k == 'bundle path':
path = v.rstrip('/')
path = run_command(cmd).strip()
if not path:
return None

if bid and path:
return AppInfo(*[unicodify(s) for s in (name, path, bid)])
cmd = ['mdls', '-raw', '-name', 'kMDItemCFBundleIdentifier', path]
bid = run_command(cmd).strip()
if not bid: # pragma: no cover
return None

return None # pragma: no cover
return AppInfo(unicodify(name), unicodify(path), unicodify(bid))


@contextmanager
Expand Down
2 changes: 1 addition & 1 deletion src/workflow/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.31
1.32

0 comments on commit d56a483

Please sign in to comment.