forked from cclauss/Ten-lines-or-less
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpythonista_version.py
42 lines (36 loc) · 1.4 KB
/
pythonista_version.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
# Output: Pythonista version 1.6 (160037) on iOS 9.2 on an iPad3,4.
# Pythonista version 2.0.1 (201000) on iOS 9.2.1 on a 64-bit iPad5,4 with a
# screen size of (1024 x 768) * 2
# Pythonista version 3.0 (300007) running Python 3.5.1 on iOS 9.3.1 on a 64-bit
# iPad5,4 with a screen size of (1024 x 768) * 2
# Pythonista version 3.0 (300007) running Python 2.7.5 on iOS 9.3.1 on a 64-bit
# iPad5,4 with a screen size of (1024 x 768) * 2
# Pythonista version 3.1 (301016) running Python 3.5.1 on iOS 10.2.1 on a 64-bit
# iPad5,4 with a screen size of (1024 x 768) * 2
#
# built on:
# https://forum.omz-software.com/topic/2444/determining-pythonista-s-version/3
import os, platform, plistlib, scene, sys # noqa
def pythonista_version(): # 2.0.1 (201000)
plist = plistlib.readPlist(
os.path.abspath(os.path.join(sys.executable, "..", "Info.plist"))
)
return "{CFBundleShortVersionString} ({CFBundleVersion})".format(**plist)
ios_ver, _, machine_model = platform.mac_ver()
bit = platform.architecture()[0].rstrip("bit") + "-bit"
rez = "({:.0f} x {:.0f})".format(*scene.get_screen_size())
fmt = (
"Pythonista version {} running Python {} on iOS {} on a {} {} with a "
"screen size of {} * {:.0f}"
)
print(
fmt.format(
pythonista_version(),
platform.python_version(),
ios_ver,
bit,
machine_model,
rez,
scene.get_screen_scale(),
)
)