Skip to content

Commit a6b4b9d

Browse files
committed
Expose Kernel version, Coderbot version, Update status
1 parent 8ba926f commit a6b4b9d

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

api.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,36 @@ def status():
5252
"internetConnectivity": True,
5353
"temp": "40",
5454
"uptime": "5h",
55-
"status": "ok",
56-
"internetConnectivity": True,
57-
"temp": "40",
58-
"uptime": "5h",
5955
}
6056

61-
6257
# Hardware and software information (STUB)
6358
def info():
64-
backend_commit = subprocess.check_output(["git", "rev-parse", "HEAD"])[0:7].decode('utf-8')
59+
# [:-2] strips out '\n' (cat)
60+
try:
61+
backend_commit = subprocess.check_output(["git", "rev-parse", "HEAD"])[0:7].decode('utf-8')
62+
except:
63+
backend_commit = 'undefined'
64+
try:
65+
coderbot_version = subprocess.check_output(["cat", "/etc/coderbot/version"]).decode('utf-8')[:-2]
66+
except:
67+
coderbot_version = 'undefined'
68+
try:
69+
kernel = subprocess.check_output(["uname", "-r"]).decode('utf-8')[:-2]
70+
except:
71+
kernel = 'undefined'
72+
73+
try:
74+
update_status = subprocess.check_output(["cat", "/etc/coderbot/update_status"]).decode('utf-8')[:-2]
75+
except:
76+
update_status = 'undefined'
77+
6578
return {
6679
"model": 1,
6780
"serial": 2,
68-
"cbVersion": 3,
69-
"backendVersion": 4,
81+
"version": coderbot_version,
7082
"backend commit build": backend_commit,
71-
"vueVersion": 5,
72-
"kernel": 6,
83+
"kernel" : kernel,
84+
"update status": update_status,
7385
}
7486

7587

0 commit comments

Comments
 (0)