7
7
import os
8
8
import subprocess
9
9
import urllib
10
+ import uptime
11
+ from gpiozero import CPUTemperature , Device
10
12
11
13
import connexion
12
14
from flask import Response , request , send_file
@@ -54,17 +56,8 @@ def get_status():
54
56
(Cached method)
55
57
"""
56
58
57
- temp = "undefined"
58
- try :
59
- temp = os .popen ("vcgencmd measure_temp" ).readline ().replace ("temp=" , "" )
60
- except Exception :
61
- pass
62
-
63
- uptime = 0
64
- try :
65
- uptime = subprocess .check_output (["uptime" ]).decode ('utf-8' ).replace ('\n ' , '' )
66
- except Exception :
67
- pass
59
+ temp = str (CPUTemperature ().temperature )
60
+ uptime = uptime .uptime ()
68
61
69
62
internet_status = False
70
63
try :
@@ -84,18 +77,35 @@ def get_info():
84
77
"""
85
78
device = {}
86
79
serial = get_serial ()
87
-
80
+ board_info_dict = {}
88
81
try :
89
82
device = Balena .get_instance ().device ()
90
- logging .info ("device: %s" , str (device ))
83
+ logging .debug ("device: %s" , str (device ))
84
+ board_info = Device .pin_factory .board_info
85
+ board_info_dict ["model" ] = board_info .model
86
+ board_info_dict ["revision" ] = board_info .revision
87
+ board_info_dict ["released" ] = board_info .released
88
+ board_info_dict ["manufacturer" ] = board_info .manufacturer
89
+ board_info_dict ["soc" ] = board_info .soc
90
+ board_info_dict ["pcb_revision" ] = board_info .pcb_revision
91
+ board_info_dict ["memory" ] = board_info .memory
92
+ board_info_dict ["storage" ] = board_info .storage
93
+ board_info_dict ["usb" ] = board_info .usb
94
+ board_info_dict ["usb3" ] = board_info .usb3
95
+ board_info_dict ["ethernet" ] = board_info .ethernet
96
+ board_info_dict ["eth_speed" ] = board_info .eth_speed
97
+ board_info_dict ["wifi" ] = board_info .wifi
98
+ board_info_dict ["bluetooth" ] = board_info .bluetooth
99
+
91
100
except Exception :
92
101
pass
93
102
94
103
return { 'release_commit' : device .get ("commit" ),
95
104
'coderbot_version' : os .getenv ("CODERBOT_VERSION" ),
96
105
'update_status' : device .get ("status" ),
97
106
'kernel' : device .get ("os_version" ),
98
- 'serial' : serial }
107
+ 'serial' : serial ,
108
+ 'board_info' : board_info_dict }
99
109
100
110
prog = None
101
111
prog_engine = ProgramEngine .get_instance ()
0 commit comments