-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-preglyphs.py
59 lines (35 loc) · 1.21 KB
/
run-preglyphs.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
58
59
#MenuTitle: Run preglyphs
# -*- coding: utf-8 -*-
__doc__="""
Runs preglyphs from your chosen project folder then shows the generated file in the Finder
"""
__copyright__ = 'Copyright (c) 2019, 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
runpreglyphs = """
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")
set sourcefolder to projectRoot & "source/"
tell application "Terminal"
activate
tell window 1
do script "cd " & projectRoot & "; ./preglyphs"
delay 10
do script "cd " & sourcefolder & "; open -R *.glyphs"
do script "cd " & sourcefolder & "; open -R masters/*.glyphs"
end tell
end tell
end tell
"""
save = runAppleScript( runpreglyphs )