@@ -123,47 +123,47 @@ def get_info():
123
123
124
124
def stop ():
125
125
bot .stop ()
126
- return 200
126
+ return {}
127
127
128
128
def move (body ):
129
129
speed = body .get ("speed" )
130
130
elapse = body .get ("elapse" )
131
131
distance = body .get ("distance" )
132
132
if (speed is None or speed == 0 ) or (elapse is not None and distance is not None ):
133
- return 400
133
+ return None , 400
134
134
bot .move (speed = speed , elapse = elapse , distance = distance )
135
- return 200
135
+ return {}
136
136
137
137
def turn (body ):
138
138
speed = body .get ("speed" )
139
139
elapse = body .get ("elapse" )
140
140
distance = body .get ("distance" )
141
141
if (speed is None or speed == 0 ) or (elapse is not None and distance is not None ):
142
- return 400
142
+ return None , 400
143
143
bot .turn (speed = speed , elapse = elapse , distance = distance )
144
- return 200
144
+ return {}
145
145
146
146
def takePhoto ():
147
147
try :
148
148
cam .photo_take ()
149
149
audio_device .say (settings .get ("sound_shutter" ))
150
- return 200
150
+ return {}
151
151
except Exception as e :
152
152
logging .warning ("Error: %s" , e )
153
153
154
154
def recVideo ():
155
155
try :
156
156
cam .video_rec ()
157
157
audio_device .say (settings .get ("sound_shutter" ))
158
- return 200
158
+ return {}
159
159
except Exception as e :
160
160
logging .warning ("Error: %s" , e )
161
161
162
162
def stopVideo ():
163
163
try :
164
164
cam .video_stop ()
165
165
audio_device .say (settings .get ("sound_shutter" ))
166
- return 200
166
+ return {}
167
167
except Exception as e :
168
168
logging .warning ("Error: %s" , e )
169
169
@@ -172,24 +172,24 @@ def speak(body):
172
172
locale = body .get ("locale" , "" )
173
173
logging .debug ("say: " + text + " in: " + locale )
174
174
audio_device .say (text , locale )
175
- return 200
175
+ return {}
176
176
177
177
def reset ():
178
178
Balena .get_instance ().purge ()
179
- return 200
179
+ return {}
180
180
181
181
def halt ():
182
182
audio_device .say (what = settings .get ("sound_stop" ))
183
183
Balena .get_instance ().shutdown ()
184
- return 200
184
+ return {}
185
185
186
186
def restart ():
187
187
Balena .get_instance ().restart ()
188
188
189
189
def reboot ():
190
190
audio_device .say (what = settings .get ("sound_stop" ))
191
191
Balena .get_instance ().reboot ()
192
- return 200
192
+ return {}
193
193
194
194
def video_stream (a_cam ):
195
195
while True :
@@ -223,22 +223,22 @@ def getPhoto(name):
223
223
return send_file (media_file , mimetype = mimetype .get (name [:- 3 ], 'image/jpeg' ), max_age = 0 )
224
224
except picamera .exc .PiCameraError as e :
225
225
logging .error ("Error: %s" , str (e ))
226
- return 503
226
+ return { "exception" : str ( e )}, 503
227
227
except FileNotFoundError :
228
- return 404
228
+ return None , 404
229
229
230
230
def savePhoto (name , body ):
231
231
try :
232
232
cam .update_photo ({"name" : name , "tag" : body .get ("tag" )})
233
233
except FileNotFoundError :
234
- return 404
234
+ return None , 404
235
235
236
236
def deletePhoto (name ):
237
237
logging .debug ("photo delete" )
238
238
try :
239
239
cam .delete_photo (name )
240
240
except FileNotFoundError :
241
- return 404
241
+ return None , 404
242
242
243
243
def restoreSettings ():
244
244
Config .restore ()
@@ -249,14 +249,14 @@ def loadSettings():
249
249
250
250
def saveSettings (body ):
251
251
Config .write (body )
252
- return 200
252
+ return Config . write ( body )
253
253
254
254
def updateFromPackage ():
255
255
os .system ('sudo bash /home/pi/clean-update.sh' )
256
256
file_to_upload = connexion .request .files ['file_to_upload' ]
257
257
file_to_upload .save (os .path .join ('/home/pi/' , 'update.tar' ))
258
258
os .system ('sudo reboot' )
259
- return 200
259
+ return {}
260
260
261
261
def listMusicPackages ():
262
262
"""
@@ -291,7 +291,7 @@ def deleteMusicPackage(name):
291
291
"""
292
292
musicPkg = MusicPackageManager .get_instance ()
293
293
musicPkg .deletePackage (name )
294
- return 200
294
+ return {}
295
295
296
296
## Programs
297
297
@@ -305,14 +305,14 @@ def saveProgram(name, body):
305
305
return "defaultCannotOverwrite" , 400
306
306
program = Program (name = body .get ("name" ), code = body .get ("code" ), dom_code = body .get ("dom_code" ), modified = datetime .now (), status = "active" )
307
307
prog_engine .save (program )
308
- return 200
308
+ return {}
309
309
310
310
def loadProgram (name ):
311
311
existing_program = prog_engine .load (name )
312
312
if existing_program :
313
313
return existing_program .as_dict (), 200
314
314
else :
315
- return 404
315
+ return None , 404
316
316
317
317
def deleteProgram (name ):
318
318
prog_engine .delete (name , logical = True )
@@ -415,18 +415,18 @@ def deleteCNNModel(name):
415
415
416
416
def cloudSyncRequest ():
417
417
CloudManager .get_instance ().sync ()
418
- return 200
418
+ return {}
419
419
420
420
def cloudSyncStatus ():
421
421
return CloudManager .get_instance ().sync_status ()
422
422
423
423
def cloudRegistrationRequest (body ):
424
424
CloudManager .get_instance ().register (body )
425
- return 200
425
+ return {}
426
426
427
427
def cloudRegistrationDelete ():
428
428
CloudManager .get_instance ().unregister ()
429
- return 200
429
+ return {}
430
430
431
431
def cloudRegistrationStatus ():
432
432
registration = cloud_settings .get ('registration' , {})
0 commit comments