-
Notifications
You must be signed in to change notification settings - Fork 14
/
sysinfo.py
59 lines (42 loc) · 1.65 KB
/
sysinfo.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
import plistlib
import os
import sys
import platform
from objc_util import ObjCClass, on_main_thread
import clipboard
def get_pythonista_version_info():
version = None
bundle_version = None
try:
plist_path = os.path.abspath(os.path.join(sys.executable, '..', 'Info.plist'))
plist = plistlib.readPlist(plist_path)
version = plist['CFBundleShortVersionString']
bundle_version = plist['CFBundleVersion']
except Exception:
pass
return 'Pythonista {} ({})'.format(version or 'N/A', bundle_version or 'N/A')
def get_python_interpreter_info():
return 'Default interpreter {}.{}.{}'.format(*sys.version_info)
def get_device_info():
device = ObjCClass('UIDevice').currentDevice()
main_screen = ObjCClass('UIScreen').mainScreen()
native_size = main_screen.nativeBounds().size
return 'iOS {}, model {}, resolution (portrait) {} x {} @ {}'.format(
device.systemVersion(), platform.machine(),
native_size.width, native_size.height, main_screen.nativeScale()
)
@on_main_thread # clipboard.set or freeze
def main():
separator = '--- SYSTEM INFORMATION ---'
info = '\n'.join([
'**System Information**',
'',
'* {}, {}'.format(get_pythonista_version_info(), get_python_interpreter_info()),
'* {}'.format(get_device_info()),
])
print('\n'.join([separator, info, separator]))
print('Please, attach everything between {} to your GitHub issue, many thanks.'.format(separator))
clipboard.set(info)
print('System information was just stored in the system clipboard. You can paste it with Cmd V.')
if __name__ == '__main__':
main()