Skip to content

Commit 22746ad

Browse files
committed
Handled not existing log file
1 parent 0940e65 commit 22746ad

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

api.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@ def exec(data):
117117
def status():
118118
sts = get_status()
119119
# 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]
120+
try:
121+
with open('/home/pi/log/reset_trigger_service.log', 'r') as log_file:
122+
data = [x for x in log_file.read().split('\n') if x]
123+
except Exception:
124+
data = [] # if file doesn't exist, no restore as ever been performed. return empty data
122125

123126
return {
124127
"status": "ok",

0 commit comments

Comments
 (0)