-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdevice_info.py
More file actions
43 lines (30 loc) · 912 Bytes
/
device_info.py
File metadata and controls
43 lines (30 loc) · 912 Bytes
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
# Pythonista
from objc_util import *
UIDevice = ObjCClass('UIDevice')
CUR_DEVICE = UIDevice.currentDevice()
###
def battery_level():
CUR_DEVICE.setBatteryMonitoringEnabled_(True)
battery_percent = CUR_DEVICE.batteryLevel() * 100
CUR_DEVICE.setBatteryMonitoringEnabled_(False)
# return '%0.1f%%' % battery_percent
return '%d %%' % int(battery_percent)
def device_name():
return str(CUR_DEVICE.name())
def system_version():
return str(CUR_DEVICE.systemVersion())
def device_uuid():
return str(CUR_DEVICE.identifierForVendor())
def all_info():
all_dict = {'device_name': device_name(),
'battery_level': battery_level(),
'system_version': system_version(),
'uuid': device_uuid()}
return all_dict
def main():
print(battery_level())
print(device_name())
print(system_version())
print(device_uuid())
if __name__ == '__main__':
main()