Skip to content

Commit 20e0728

Browse files
committed
Update Alfred-Workflow & add self-updating
1 parent 49c1e4e commit 20e0728

File tree

8 files changed

+206
-69
lines changed

8 files changed

+206
-69
lines changed
Binary file not shown.

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
Alfred Fixum
33
============
44

5-
Fix Alfred 3 Python workflows affected by [the Sierra background process bug][bug] in [Alfred-Workflow][aw].
5+
Fix Alfred 3 Python workflows affected by bugs in [Alfred-Workflow][aw], in particular the [the Sierra background process bug][bug].
66

7-
If you're not running Sierra, you don't need to run Fixum.
8-
9-
Fixum analyses your installed workflows to see if any use an old, buggy version of the Alfred-Workflow library. If they do, it can update them with a newer, working version.
7+
Fixum analyses your installed workflows to see if any use an old version of the Alfred-Workflow library. If they do, it can update them with a newer, working version.
108

119

1210
Installation
@@ -34,6 +32,8 @@ If everything looks good, run **Fix Workflows**.
3432
### Alfred commands ###
3533

3634
- `fixnum` — Show available actions
35+
- **A newer version of Fixum is available** — Shown if an update
36+
for Fixum is available.
3737
- **Dry Run** — Analyse installed workflows, but don't change anything
3838
- **View Log File** — See what the workflow would change/has changed
3939
- **Edit Blacklist** — Change the list of bundle IDs that should not be updated (e.g. your own workflows)

src/fixum.py

+68-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""fixum [options]
1212
1313
Usage:
14+
fixum list <query>
1415
fixum [-n]
1516
fixum -h|--help
1617
fixum --version
@@ -33,7 +34,15 @@
3334
import sys
3435

3536
import docopt
36-
from workflow import Workflow3
37+
from workflow import (
38+
ICON_WARNING,
39+
MATCH_STARTSWITH,
40+
MATCH_CAPITALS,
41+
MATCH_ATOM,
42+
MATCH_INITIALS_STARTSWITH,
43+
MATCH_SUBSTRING,
44+
Workflow3,
45+
)
3746
from workflow.update import Version
3847

3948

@@ -44,8 +53,11 @@
4453
'net.deanishe.alfred.fixum', # this workflow
4554
]
4655

56+
ICON_UPDATE = 'update-available.png'
57+
4758
# version of AW in this workflow
48-
MIN_VERSION = Version('1.25.2')
59+
VERSION_FILE = os.path.join(os.path.dirname(__file__), 'workflow/version')
60+
MIN_VERSION = Version(open(VERSION_FILE).read())
4961

5062
# path to good copy of Alfred-Workflow
5163
WF_DIR = os.path.join(os.path.dirname(__file__), 'workflow')
@@ -64,6 +76,11 @@
6476

6577
HELP_URL = 'https://github.com/deanishe/alfred-fixum/issues'
6678

79+
MATCH = (MATCH_STARTSWITH |
80+
MATCH_CAPITALS |
81+
MATCH_ATOM |
82+
MATCH_INITIALS_STARTSWITH |
83+
MATCH_SUBSTRING)
6784

6885
Workflow = namedtuple('Workflow', 'name id dir aw_version aw_dir')
6986
AWInfo = namedtuple('AWInfo', 'path version')
@@ -180,9 +197,58 @@ def update_workflow(info):
180197
log.info(' installed new version of Alfred-Workflow')
181198

182199

200+
def list_actions(opts):
201+
"""Show available workflow actions."""
202+
query = opts['<query>']
203+
log.debug('query=%r', query)
204+
205+
if wf.update_available:
206+
wf.add_item('A newer version of Fixum is available',
207+
u'⇥ or ↩ to install update',
208+
valid=False,
209+
autocomplete='workflow:update',
210+
icon=ICON_UPDATE)
211+
212+
items = [
213+
dict(title='Dry Run',
214+
subtitle='Show what the workflow would update',
215+
arg='dryrun',
216+
valid=True),
217+
dict(title='View Log File',
218+
subtitle='Open the log file in Console.app',
219+
arg='log',
220+
valid=True),
221+
dict(title='Edit Blacklist',
222+
subtitle='List of workflows to *not* update',
223+
arg='blacklist',
224+
valid=True),
225+
dict(title='Fix Workflows',
226+
subtitle=('Replace broken versions of Alfred-Workflow '
227+
'within your workflows'),
228+
arg='fix',
229+
valid=True),
230+
]
231+
232+
if query:
233+
items = wf.filter(query, items, key=lambda d: d['title'],
234+
match_on=MATCH, min_score=50)
235+
236+
if not items:
237+
wf.add_item('No matching actions', 'Try a different query',
238+
icon=ICON_WARNING)
239+
240+
for d in items:
241+
wf.add_item(**d)
242+
243+
wf.send_feedback()
244+
245+
183246
def main(wf):
184247
"""Run workflow script."""
185248
opts = docopt.docopt(__doc__, argv=wf.args, version=wf.version)
249+
if opts['list']:
250+
return list_actions(opts)
251+
186252
dry_run = opts['--nothing']
187253
log.info('=' * 50)
188254
log.debug('opts=%r', opts)

src/info.plist

+50-32
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<string>net.deanishe.alfred.fixum</string>
77
<key>connections</key>
88
<dict>
9-
<key>1FFB6897-CFE2-4086-8920-CBEC8B411C31</key>
9+
<key>4FFEB019-EBD2-452B-AC8B-54E7C33ABE9F</key>
1010
<array>
1111
<dict>
1212
<key>destinationuid</key>
@@ -45,6 +45,49 @@
4545
<string>Fixum</string>
4646
<key>objects</key>
4747
<array>
48+
<dict>
49+
<key>config</key>
50+
<dict>
51+
<key>alfredfiltersresults</key>
52+
<false/>
53+
<key>argumenttype</key>
54+
<integer>1</integer>
55+
<key>escaping</key>
56+
<integer>102</integer>
57+
<key>keyword</key>
58+
<string>fixum</string>
59+
<key>queuedelaycustom</key>
60+
<integer>3</integer>
61+
<key>queuedelayimmediatelyinitially</key>
62+
<true/>
63+
<key>queuedelaymode</key>
64+
<integer>0</integer>
65+
<key>queuemode</key>
66+
<integer>1</integer>
67+
<key>runningsubtext</key>
68+
<string></string>
69+
<key>script</key>
70+
<string>/usr/bin/python fixum.py list "$1"</string>
71+
<key>scriptargtype</key>
72+
<integer>1</integer>
73+
<key>scriptfile</key>
74+
<string></string>
75+
<key>subtext</key>
76+
<string>Update Alfred-Workflow library in workflows using a buggy version</string>
77+
<key>title</key>
78+
<string>Fix Python Workflows</string>
79+
<key>type</key>
80+
<integer>0</integer>
81+
<key>withspace</key>
82+
<true/>
83+
</dict>
84+
<key>type</key>
85+
<string>alfred.workflow.input.scriptfilter</string>
86+
<key>uid</key>
87+
<string>4FFEB019-EBD2-452B-AC8B-54E7C33ABE9F</string>
88+
<key>version</key>
89+
<integer>2</integer>
90+
</dict>
4891
<dict>
4992
<key>config</key>
5093
<dict>
@@ -108,42 +151,17 @@ exit 0</string>
108151
<key>version</key>
109152
<integer>1</integer>
110153
</dict>
111-
<dict>
112-
<key>config</key>
113-
<dict>
114-
<key>argumenttype</key>
115-
<integer>1</integer>
116-
<key>fixedorder</key>
117-
<true/>
118-
<key>items</key>
119-
<string>[{"title":"Dry Run","arg":"dryrun","subtitle":"Show what the workflow would update"},{"title":"View Log File","arg":"log","subtitle":"Open the logfile in Console.app"},{"title":"Edit Blacklist","arg":"blacklist","subtitle":"List of workflows to *not* update"},{"title":"Fix Workflows","arg":"fix","subtitle":"Replace broken versions of Alfred-Workflow within your workflows"}]</string>
120-
<key>keyword</key>
121-
<string>fixum</string>
122-
<key>runningsubtext</key>
123-
<string></string>
124-
<key>subtext</key>
125-
<string>Update Alfred-Workflow library in workflows using a buggy version</string>
126-
<key>title</key>
127-
<string>Fix Python Workflows</string>
128-
<key>withspace</key>
129-
<true/>
130-
</dict>
131-
<key>type</key>
132-
<string>alfred.workflow.input.listfilter</string>
133-
<key>uid</key>
134-
<string>1FFB6897-CFE2-4086-8920-CBEC8B411C31</string>
135-
<key>version</key>
136-
<integer>1</integer>
137-
</dict>
138154
</array>
139155
<key>readme</key>
140-
<string></string>
156+
<string>This workflow upgrades the version of Alfred-Workflow used by your installed workflows.
157+
158+
It is primarily a workaround to fix bugs that are preventing the workflows from updating themselves or causing issues with Alfred.</string>
141159
<key>uidata</key>
142160
<dict>
143-
<key>1FFB6897-CFE2-4086-8920-CBEC8B411C31</key>
161+
<key>4FFEB019-EBD2-452B-AC8B-54E7C33ABE9F</key>
144162
<dict>
145163
<key>xpos</key>
146-
<integer>30</integer>
164+
<integer>20</integer>
147165
<key>ypos</key>
148166
<integer>30</integer>
149167
</dict>
@@ -163,7 +181,7 @@ exit 0</string>
163181
</dict>
164182
</dict>
165183
<key>version</key>
166-
<string>0.1.5</string>
184+
<string>0.2</string>
167185
<key>webaddress</key>
168186
<string></string>
169187
</dict>

src/update-available.png

3.77 KB
Loading

src/workflow/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Workflow objects
1616
from .workflow import Workflow, manager
17-
from .workflow3 import Workflow3
17+
from .workflow3 import Variables, Workflow3
1818

1919
# Exceptions
2020
from .workflow import PasswordNotFound, KeychainError
@@ -67,6 +67,7 @@
6767
__copyright__ = 'Copyright 2014 Dean Jackson'
6868

6969
__all__ = [
70+
'Variables',
7071
'Workflow',
7172
'Workflow3',
7273
'manager',

src/workflow/version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.25.2
1+
1.26

0 commit comments

Comments
 (0)