-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-preflightg.py
57 lines (34 loc) · 1.26 KB
/
run-preflightg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#MenuTitle: Run preflightg - G for Glyphs -
# -*- coding: utf-8 -*-
__doc__="""
Runs the preflightg - G for Glyphs - shell script from your chosen project folder
"""
__copyright__ = 'Copyright (c) 2018, SIL International (http://www.sil.org)'
__license__ = 'Released under the MIT License (http://opensource.org/licenses/MIT)'
__author__ = 'Nicolas Spalinger'
import GlyphsApp
from subprocess import Popen, PIPE
def runAppleScript(scpt, args=[]):
p = Popen(['osascript', '-'] + args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate(scpt)
if stderr:
print "AppleScript Error:"
print stderr.decode('utf-8')
return stdout
runpreflightg = """
tell application "Finder"
activate
set frontmost to true
set projectRoot to quoted form of POSIX path of (choose folder with prompt "Please select the project folder root, e.g. font-gentium" with invisibles)
tell application "Terminal"
activate
tell window 1
do script "cd " & projectRoot & "; ./preflightg"
end tell
end tell
end tell
tell application "Finder"
display notification "Running preflightg on your project, watch for errors in the output, when done you can close the window" with title "Preflightg" sound name "default"
end tell
"""
save = runAppleScript( runpreflightg )