Skip to content

Commit 00d62b6

Browse files
committed
New route for reset, go returned along with status
1 parent e77a379 commit 00d62b6

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

api.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,16 @@ def exec(data):
116116

117117
def status():
118118
sts = get_status()
119+
# getting reset log file
120+
with open('/home/pi/log/reset_trigger_service.log', 'r') as log_file:
121+
data = [x for x in log_file.read().split('\n') if x]
119122

120123
return {
121124
"status": "ok",
122125
"internetConnectivity": sts["internet_status"],
123126
"temp": sts["temp"],
124127
"uptime": sts["uptime"],
128+
"log": data
125129
}
126130

127131
def info():
@@ -210,10 +214,8 @@ def reset():
210214
pi = pigpio.pi('localhost')
211215
pi.write(BUTTON_PIN, 0)
212216
pi.write(BUTTON_PIN, 1)
213-
with open('/home/pi/log/reset_trigger_service.log', 'r') as log_file:
214-
data = [x for x in log_file.read().split('\n') if x]
215217

216218
return {
217-
"log": data,
218-
"status": "ok"
219+
"status": "ok"
219220
}
221+

v2.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,21 @@ paths:
164164
/status:
165165
get:
166166
operationId: "api.status"
167-
summary: "Bot general informations and execution status"
167+
summary: "Bot general informations, execution status and reset log file"
168168
tags:
169169
- Status informations
170170
responses:
171171
200:
172172
description: "Bot status"
173+
/reset:
174+
get:
175+
operationId: "api.reset"
176+
summary: "Reset coderbot by restoring boot partition"
177+
tags:
178+
- Coderbot reset
179+
responses:
180+
200:
181+
description: "resets coderbot entirely"
173182
/info:
174183
get:
175184
operationId: "api.info"
@@ -179,15 +188,6 @@ paths:
179188
responses:
180189
200:
181190
description: "Bot status"
182-
/reset:
183-
get:
184-
operationId: "api.reset"
185-
summary: "Reset coderbot by restoring boot partition"
186-
tags:
187-
- Coderbot reset
188-
responses:
189-
200:
190-
description: "reset log file"
191191
/stop:
192192
post:
193193
operationId: "api.stop"

0 commit comments

Comments
 (0)