Skip to content

Commit 25ed139

Browse files
committed
Update Alfred-Workflow
1 parent da26aa8 commit 25ed139

File tree

5 files changed

+70
-70
lines changed

5 files changed

+70
-70
lines changed
Binary file not shown.

src/info.plist

+46-46
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,44 @@
4848
<dict>
4949
<key>config</key>
5050
<dict>
51-
<key>lastpathcomponent</key>
52-
<false/>
53-
<key>onlyshowifquerypopulated</key>
54-
<true/>
55-
<key>removeextension</key>
51+
<key>concurrently</key>
5652
<false/>
57-
<key>text</key>
58-
<string>{query}</string>
59-
<key>title</key>
60-
<string>Fixum</string>
53+
<key>escaping</key>
54+
<integer>102</integer>
55+
<key>script</key>
56+
<string>mode=$1
57+
datadir="$alfred_workflow_data"
58+
cachedir="$alfred_workflow_cache"
59+
blacklist="${datadir}/blacklist.txt"
60+
logfile="${cachedir}/net.deanishe.alfred.fixum.log"
61+
62+
# create data &amp; cache directories, logfile and blacklist
63+
test -d "$cachedir" || mkdir -p "$cachedir"
64+
test -f "$logfile" || touch "$logfile"
65+
66+
test -d "$datadir" || mkdir -p "$datadir"
67+
test -f "$blacklist" || cp blacklist.default.txt "$blacklist"
68+
69+
# script actions
70+
[[ "$mode" = dryrun ]] &amp;&amp; /usr/bin/python fixum.py --nothing
71+
[[ "$mode" = fix ]] &amp;&amp; /usr/bin/python fixum.py
72+
[[ "$mode" = blacklist ]] &amp;&amp; open "$blacklist"
73+
[[ "$mode" = log ]] &amp;&amp; open -a Console "$logfile"
74+
75+
exit 0</string>
76+
<key>scriptargtype</key>
77+
<integer>1</integer>
78+
<key>scriptfile</key>
79+
<string></string>
80+
<key>type</key>
81+
<integer>5</integer>
6182
</dict>
6283
<key>type</key>
63-
<string>alfred.workflow.output.notification</string>
84+
<string>alfred.workflow.action.script</string>
6485
<key>uid</key>
65-
<string>90302262-60E4-4C1C-AAEA-2A5C3F4C025A</string>
86+
<string>97033D94-9B6F-446C-94E5-AB677B5ABB4F</string>
6687
<key>version</key>
67-
<integer>1</integer>
88+
<integer>2</integer>
6889
</dict>
6990
<dict>
7091
<key>config</key>
@@ -116,44 +137,23 @@
116137
<dict>
117138
<key>config</key>
118139
<dict>
119-
<key>concurrently</key>
140+
<key>lastpathcomponent</key>
120141
<false/>
121-
<key>escaping</key>
122-
<integer>102</integer>
123-
<key>script</key>
124-
<string>mode=$1
125-
datadir="$alfred_workflow_data"
126-
cachedir="$alfred_workflow_cache"
127-
blacklist="${datadir}/blacklist.txt"
128-
logfile="${cachedir}/net.deanishe.alfred.fixum.log"
129-
130-
# create data &amp; cache directories, logfile and blacklist
131-
test -d "$cachedir" || mkdir -p "$cachedir"
132-
test -f "$logfile" || touch "$logfile"
133-
134-
test -d "$datadir" || mkdir -p "$datadir"
135-
test -f "$blacklist" || cp blacklist.default.txt "$blacklist"
136-
137-
# script actions
138-
[[ "$mode" = dryrun ]] &amp;&amp; /usr/bin/python fixum.py --nothing
139-
[[ "$mode" = fix ]] &amp;&amp; /usr/bin/python fixum.py
140-
[[ "$mode" = blacklist ]] &amp;&amp; open "$blacklist"
141-
[[ "$mode" = log ]] &amp;&amp; open -a Console "$logfile"
142-
143-
exit 0</string>
144-
<key>scriptargtype</key>
145-
<integer>1</integer>
146-
<key>scriptfile</key>
147-
<string></string>
148-
<key>type</key>
149-
<integer>5</integer>
142+
<key>onlyshowifquerypopulated</key>
143+
<true/>
144+
<key>removeextension</key>
145+
<false/>
146+
<key>text</key>
147+
<string>{query}</string>
148+
<key>title</key>
149+
<string>Fixum</string>
150150
</dict>
151151
<key>type</key>
152-
<string>alfred.workflow.action.script</string>
152+
<string>alfred.workflow.output.notification</string>
153153
<key>uid</key>
154-
<string>97033D94-9B6F-446C-94E5-AB677B5ABB4F</string>
154+
<string>90302262-60E4-4C1C-AAEA-2A5C3F4C025A</string>
155155
<key>version</key>
156-
<integer>2</integer>
156+
<integer>1</integer>
157157
</dict>
158158
</array>
159159
<key>readme</key>
@@ -185,7 +185,7 @@ It is primarily a workaround to fix bugs that are preventing the workflows from
185185
</dict>
186186
</dict>
187187
<key>version</key>
188-
<string>0.5</string>
188+
<string>0.6</string>
189189
<key>webaddress</key>
190190
<string></string>
191191
</dict>

src/workflow/version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.28
1+
1.28.1

src/workflow/workflow.py

+16-15
Original file line numberDiff line numberDiff line change
@@ -2242,15 +2242,16 @@ def run(self, func, text_errors=False):
22422242
# Call workflow's entry function/method within a try-except block
22432243
# to catch any errors and display an error message in Alfred
22442244
try:
2245-
22462245
if self.version:
2247-
self.logger.debug('workflow version: %s', self.version)
2246+
self.logger.debug('---------- %s (%s) ----------',
2247+
self.name, self.version)
2248+
else:
2249+
self.logger.debug('---------- %s ----------', self.name)
22482250

22492251
# Run update check if configured for self-updates.
22502252
# This call has to go in the `run` try-except block, as it will
22512253
# initialise `self.settings`, which will raise an exception
22522254
# if `settings.json` isn't valid.
2253-
22542255
if self._update_settings:
22552256
self.check_update()
22562257

@@ -2273,7 +2274,7 @@ def run(self, func, text_errors=False):
22732274
self._items = []
22742275
if self._name:
22752276
name = self._name
2276-
elif self._bundleid:
2277+
elif self._bundleid: # pragma: no cover
22772278
name = self._bundleid
22782279
else: # pragma: no cover
22792280
name = os.path.dirname(__file__)
@@ -2284,7 +2285,7 @@ def run(self, func, text_errors=False):
22842285
return 1
22852286

22862287
finally:
2287-
self.logger.debug('workflow finished in %0.3f seconds',
2288+
self.logger.debug('---------- finished in %0.3fs ----------',
22882289
time.time() - start)
22892290

22902291
return 0
@@ -2522,12 +2523,12 @@ def check_update(self, force=False):
25222523
if self.prereleases:
25232524
cmd.append('--prereleases')
25242525

2525-
self.logger.info('Checking for update ...')
2526+
self.logger.info('checking for update ...')
25262527

25272528
run_in_background('__workflow_update_check', cmd)
25282529

25292530
else:
2530-
self.logger.debug('Update check not due')
2531+
self.logger.debug('update check not due')
25312532

25322533
def start_update(self):
25332534
"""Check for update and download and install new workflow file.
@@ -2562,7 +2563,7 @@ def start_update(self):
25622563
if self.prereleases:
25632564
cmd.append('--prereleases')
25642565

2565-
self.logger.debug('Downloading update ...')
2566+
self.logger.debug('downloading update ...')
25662567
run_in_background('__workflow_update_install', cmd)
25672568

25682569
return True
@@ -2596,14 +2597,14 @@ def save_password(self, account, password, service=None):
25962597
try:
25972598
self._call_security('add-generic-password', service, account,
25982599
'-w', password)
2599-
self.logger.debug('Saved password : %s:%s', service, account)
2600+
self.logger.debug('saved password : %s:%s', service, account)
26002601

26012602
except PasswordExists:
2602-
self.logger.debug('Password exists : %s:%s', service, account)
2603+
self.logger.debug('password exists : %s:%s', service, account)
26032604
current_password = self.get_password(account, service)
26042605

26052606
if current_password == password:
2606-
self.logger.debug('Password unchanged')
2607+
self.logger.debug('password unchanged')
26072608

26082609
else:
26092610
self.delete_password(account, service)
@@ -2646,7 +2647,7 @@ def get_password(self, account, service=None):
26462647
if h:
26472648
password = unicode(binascii.unhexlify(h), 'utf-8')
26482649

2649-
self.logger.debug('Got password : %s:%s', service, account)
2650+
self.logger.debug('got password : %s:%s', service, account)
26502651

26512652
return password
26522653

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

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

2671-
self.logger.debug('Deleted password : %s:%s', service, account)
2672+
self.logger.debug('deleted password : %s:%s', service, account)
26722673

26732674
####################################################################
26742675
# Methods for workflow:* magic args
@@ -2812,7 +2813,7 @@ def clear_settings(self):
28122813
"""Delete workflow's :attr:`settings_path`."""
28132814
if os.path.exists(self.settings_path):
28142815
os.unlink(self.settings_path)
2815-
self.logger.debug('Deleted : %r', self.settings_path)
2816+
self.logger.debug('deleted : %r', self.settings_path)
28162817

28172818
def reset(self):
28182819
"""Delete workflow settings, cache and data.
@@ -2949,7 +2950,7 @@ def _delete_directory_contents(self, dirpath, filter_func):
29492950
shutil.rmtree(path)
29502951
else:
29512952
os.unlink(path)
2952-
self.logger.debug('Deleted : %r', path)
2953+
self.logger.debug('deleted : %r', path)
29532954

29542955
def _load_info_plist(self):
29552956
"""Load workflow info from ``info.plist``."""

src/workflow/workflow3.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,10 @@ def __init__(self, **kwargs):
469469
Workflow.__init__(self, **kwargs)
470470
self.variables = {}
471471
self._rerun = 0
472-
self._session_id = None
472+
# Get session ID from environment if present
473+
self._session_id = os.getenv('_WF_SESSION_ID') or None
474+
if self._session_id:
475+
self.setvar('_WF_SESSION_ID', self._session_id)
473476

474477
@property
475478
def _default_cachedir(self):
@@ -513,13 +516,9 @@ def session_id(self):
513516
514517
"""
515518
if not self._session_id:
516-
sid = os.getenv('_WF_SESSION_ID')
517-
if not sid:
518-
from uuid import uuid4
519-
sid = uuid4().hex
520-
self.setvar('_WF_SESSION_ID', sid)
521-
522-
self._session_id = sid
519+
from uuid import uuid4
520+
self._session_id = uuid4().hex
521+
self.setvar('_WF_SESSION_ID', self._session_id)
523522

524523
return self._session_id
525524

0 commit comments

Comments
 (0)