Skip to content

Commit

Permalink
Update Alfred-Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
deanishe committed Sep 19, 2017
1 parent da26aa8 commit 25ed139
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 70 deletions.
Binary file not shown.
92 changes: 46 additions & 46 deletions src/info.plist
Expand Up @@ -48,23 +48,44 @@
<dict>
<key>config</key>
<dict>
<key>lastpathcomponent</key>
<false/>
<key>onlyshowifquerypopulated</key>
<true/>
<key>removeextension</key>
<key>concurrently</key>
<false/>
<key>text</key>
<string>{query}</string>
<key>title</key>
<string>Fixum</string>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>mode=$1
datadir="$alfred_workflow_data"
cachedir="$alfred_workflow_cache"
blacklist="${datadir}/blacklist.txt"
logfile="${cachedir}/net.deanishe.alfred.fixum.log"
# create data &amp; cache directories, logfile and blacklist
test -d "$cachedir" || mkdir -p "$cachedir"
test -f "$logfile" || touch "$logfile"
test -d "$datadir" || mkdir -p "$datadir"
test -f "$blacklist" || cp blacklist.default.txt "$blacklist"
# script actions
[[ "$mode" = dryrun ]] &amp;&amp; /usr/bin/python fixum.py --nothing
[[ "$mode" = fix ]] &amp;&amp; /usr/bin/python fixum.py
[[ "$mode" = blacklist ]] &amp;&amp; open "$blacklist"
[[ "$mode" = log ]] &amp;&amp; open -a Console "$logfile"
exit 0</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>5</integer>
</dict>
<key>type</key>
<string>alfred.workflow.output.notification</string>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>90302262-60E4-4C1C-AAEA-2A5C3F4C025A</string>
<string>97033D94-9B6F-446C-94E5-AB677B5ABB4F</string>
<key>version</key>
<integer>1</integer>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
Expand Down Expand Up @@ -116,44 +137,23 @@
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<key>lastpathcomponent</key>
<false/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>mode=$1
datadir="$alfred_workflow_data"
cachedir="$alfred_workflow_cache"
blacklist="${datadir}/blacklist.txt"
logfile="${cachedir}/net.deanishe.alfred.fixum.log"
# create data &amp; cache directories, logfile and blacklist
test -d "$cachedir" || mkdir -p "$cachedir"
test -f "$logfile" || touch "$logfile"
test -d "$datadir" || mkdir -p "$datadir"
test -f "$blacklist" || cp blacklist.default.txt "$blacklist"
# script actions
[[ "$mode" = dryrun ]] &amp;&amp; /usr/bin/python fixum.py --nothing
[[ "$mode" = fix ]] &amp;&amp; /usr/bin/python fixum.py
[[ "$mode" = blacklist ]] &amp;&amp; open "$blacklist"
[[ "$mode" = log ]] &amp;&amp; open -a Console "$logfile"
exit 0</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>5</integer>
<key>onlyshowifquerypopulated</key>
<true/>
<key>removeextension</key>
<false/>
<key>text</key>
<string>{query}</string>
<key>title</key>
<string>Fixum</string>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<string>alfred.workflow.output.notification</string>
<key>uid</key>
<string>97033D94-9B6F-446C-94E5-AB677B5ABB4F</string>
<string>90302262-60E4-4C1C-AAEA-2A5C3F4C025A</string>
<key>version</key>
<integer>2</integer>
<integer>1</integer>
</dict>
</array>
<key>readme</key>
Expand Down Expand Up @@ -185,7 +185,7 @@ It is primarily a workaround to fix bugs that are preventing the workflows from
</dict>
</dict>
<key>version</key>
<string>0.5</string>
<string>0.6</string>
<key>webaddress</key>
<string></string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion src/workflow/version
@@ -1 +1 @@
1.28
1.28.1
31 changes: 16 additions & 15 deletions src/workflow/workflow.py
Expand Up @@ -2242,15 +2242,16 @@ def run(self, func, text_errors=False):
# Call workflow's entry function/method within a try-except block
# to catch any errors and display an error message in Alfred
try:

if self.version:
self.logger.debug('workflow version: %s', self.version)
self.logger.debug('---------- %s (%s) ----------',
self.name, self.version)
else:
self.logger.debug('---------- %s ----------', self.name)

# Run update check if configured for self-updates.
# This call has to go in the `run` try-except block, as it will
# initialise `self.settings`, which will raise an exception
# if `settings.json` isn't valid.

if self._update_settings:
self.check_update()

Expand All @@ -2273,7 +2274,7 @@ def run(self, func, text_errors=False):
self._items = []
if self._name:
name = self._name
elif self._bundleid:
elif self._bundleid: # pragma: no cover
name = self._bundleid
else: # pragma: no cover
name = os.path.dirname(__file__)
Expand All @@ -2284,7 +2285,7 @@ def run(self, func, text_errors=False):
return 1

finally:
self.logger.debug('workflow finished in %0.3f seconds',
self.logger.debug('---------- finished in %0.3fs ----------',
time.time() - start)

return 0
Expand Down Expand Up @@ -2522,12 +2523,12 @@ def check_update(self, force=False):
if self.prereleases:
cmd.append('--prereleases')

self.logger.info('Checking for update ...')
self.logger.info('checking for update ...')

run_in_background('__workflow_update_check', cmd)

else:
self.logger.debug('Update check not due')
self.logger.debug('update check not due')

def start_update(self):
"""Check for update and download and install new workflow file.
Expand Down Expand Up @@ -2562,7 +2563,7 @@ def start_update(self):
if self.prereleases:
cmd.append('--prereleases')

self.logger.debug('Downloading update ...')
self.logger.debug('downloading update ...')
run_in_background('__workflow_update_install', cmd)

return True
Expand Down Expand Up @@ -2596,14 +2597,14 @@ def save_password(self, account, password, service=None):
try:
self._call_security('add-generic-password', service, account,
'-w', password)
self.logger.debug('Saved password : %s:%s', service, account)
self.logger.debug('saved password : %s:%s', service, account)

except PasswordExists:
self.logger.debug('Password exists : %s:%s', service, account)
self.logger.debug('password exists : %s:%s', service, account)
current_password = self.get_password(account, service)

if current_password == password:
self.logger.debug('Password unchanged')
self.logger.debug('password unchanged')

else:
self.delete_password(account, service)
Expand Down Expand Up @@ -2646,7 +2647,7 @@ def get_password(self, account, service=None):
if h:
password = unicode(binascii.unhexlify(h), 'utf-8')

self.logger.debug('Got password : %s:%s', service, account)
self.logger.debug('got password : %s:%s', service, account)

return password

Expand All @@ -2668,7 +2669,7 @@ def delete_password(self, account, service=None):

self._call_security('delete-generic-password', service, account)

self.logger.debug('Deleted password : %s:%s', service, account)
self.logger.debug('deleted password : %s:%s', service, account)

####################################################################
# Methods for workflow:* magic args
Expand Down Expand Up @@ -2812,7 +2813,7 @@ def clear_settings(self):
"""Delete workflow's :attr:`settings_path`."""
if os.path.exists(self.settings_path):
os.unlink(self.settings_path)
self.logger.debug('Deleted : %r', self.settings_path)
self.logger.debug('deleted : %r', self.settings_path)

def reset(self):
"""Delete workflow settings, cache and data.
Expand Down Expand Up @@ -2949,7 +2950,7 @@ def _delete_directory_contents(self, dirpath, filter_func):
shutil.rmtree(path)
else:
os.unlink(path)
self.logger.debug('Deleted : %r', path)
self.logger.debug('deleted : %r', path)

def _load_info_plist(self):
"""Load workflow info from ``info.plist``."""
Expand Down
15 changes: 7 additions & 8 deletions src/workflow/workflow3.py
Expand Up @@ -469,7 +469,10 @@ def __init__(self, **kwargs):
Workflow.__init__(self, **kwargs)
self.variables = {}
self._rerun = 0
self._session_id = None
# Get session ID from environment if present
self._session_id = os.getenv('_WF_SESSION_ID') or None
if self._session_id:
self.setvar('_WF_SESSION_ID', self._session_id)

@property
def _default_cachedir(self):
Expand Down Expand Up @@ -513,13 +516,9 @@ def session_id(self):
"""
if not self._session_id:
sid = os.getenv('_WF_SESSION_ID')
if not sid:
from uuid import uuid4
sid = uuid4().hex
self.setvar('_WF_SESSION_ID', sid)

self._session_id = sid
from uuid import uuid4
self._session_id = uuid4().hex
self.setvar('_WF_SESSION_ID', self._session_id)

return self._session_id

Expand Down

0 comments on commit 25ed139

Please sign in to comment.