77import os
88import subprocess
99import urllib
10+ import uptime
11+ from gpiozero import CPUTemperature , Device
1012
1113import connexion
1214from flask import Response , request , send_file
@@ -54,17 +56,8 @@ def get_status():
5456 (Cached method)
5557 """
5658
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 ()
6861
6962 internet_status = False
7063 try :
@@ -84,18 +77,35 @@ def get_info():
8477 """
8578 device = {}
8679 serial = get_serial ()
87-
80+ board_info_dict = {}
8881 try :
8982 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+
91100 except Exception :
92101 pass
93102
94103 return { 'release_commit' : device .get ("commit" ),
95104 'coderbot_version' : os .getenv ("CODERBOT_VERSION" ),
96105 'update_status' : device .get ("status" ),
97106 'kernel' : device .get ("os_version" ),
98- 'serial' : serial }
107+ 'serial' : serial ,
108+ 'board_info' : board_info_dict }
99109
100110prog = None
101111prog_engine = ProgramEngine .get_instance ()
0 commit comments