Skip to content

Commit e929c0e

Browse files
committed
fix bot, cam
1 parent d8ef622 commit e929c0e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

coderbot/api.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def get_status():
6767

6868
internet_status = False
6969
try:
70-
urllib.request.urlopen("https://coderbot.org")
70+
urllib.request.urlopen("https://coderCoderBot.get_instance().org")
7171
internet_status = True
7272
except Exception:
7373
pass
@@ -104,7 +104,7 @@ def get_info():
104104
## Robot control
105105

106106
def stop():
107-
bot.stop()
107+
CoderBot.get_instance().stop()
108108
return {}
109109

110110
def move(body):
@@ -113,7 +113,7 @@ def move(body):
113113
distance=body.get("distance")
114114
if (speed is None or speed == 0) or (elapse is not None and distance is not None):
115115
return None, 400
116-
bot.move(speed=speed, elapse=elapse, distance=distance)
116+
CoderBot.get_instance().move(speed=speed, elapse=elapse, distance=distance)
117117
return {}
118118

119119
def turn(body):
@@ -122,28 +122,28 @@ def turn(body):
122122
distance=body.get("distance")
123123
if (speed is None or speed == 0) or (elapse is not None and distance is not None):
124124
return None, 400
125-
bot.turn(speed=speed, elapse=elapse, distance=distance)
125+
CoderBot.get_instance().turn(speed=speed, elapse=elapse, distance=distance)
126126
return {}
127127

128128
def takePhoto():
129129
try:
130-
cam.photo_take()
130+
Camera.get_instance().photo_take()
131131
Audio.get_instance().say(settings.get("sound_shutter"))
132132
return {}
133133
except Exception as e:
134134
logging.warning("Error: %s", e)
135135

136136
def recVideo():
137137
try:
138-
cam.video_rec()
138+
Camera.get_instance().video_rec()
139139
Audio.get_instance().say(settings.get("sound_shutter"))
140140
return {}
141141
except Exception as e:
142142
logging.warning("Error: %s", e)
143143

144144
def stopVideo():
145145
try:
146-
cam.video_stop()
146+
Camera.get_instance().video_stop()
147147
Audio.get_instance().say(settings.get("sound_shutter"))
148148
return {}
149149
except Exception as e:
@@ -196,12 +196,12 @@ def listPhotos():
196196
"""
197197
Expose the list of taken photos
198198
"""
199-
return cam.get_photo_list()
199+
return Camera.get_instance().get_photo_list()
200200

201201
def getPhoto(name):
202202
mimetype = {'jpg': 'image/jpeg', 'mp4': 'video/mp4'}
203203
try:
204-
media_file = cam.get_photo_file(name)
204+
media_file = Camera.get_instance().get_photo_file(name)
205205
return send_file(media_file, mimetype=mimetype.get(name[:-3], 'image/jpeg'), max_age=0)
206206
except picamera.exc.PiCameraError as e:
207207
logging.error("Error: %s", str(e))
@@ -211,14 +211,14 @@ def getPhoto(name):
211211

212212
def savePhoto(name, body):
213213
try:
214-
cam.update_photo({"name": name, "tag": body.get("tag")})
214+
Camera.get_instance().update_photo({"name": name, "tag": body.get("tag")})
215215
except FileNotFoundError:
216216
return None, 404
217217

218218
def deletePhoto(name):
219219
logging.debug("photo delete")
220220
try:
221-
cam.delete_photo(name)
221+
Camera.get_instance().delete_photo(name)
222222
except FileNotFoundError:
223223
return None, 404
224224

@@ -377,7 +377,7 @@ def trainCNNModel(body):
377377
cnn.train_new_model(model_name=body.get("model_name"),
378378
architecture=body.get("architecture"),
379379
image_tags=body.get("image_tags"),
380-
photos_meta=cam.get_photo_list(),
380+
photos_meta=Camera.get_instance().get_photo_list(),
381381
training_steps=body.get("training_steps"),
382382
learning_rate=body.get("learning_rate"))
383383

0 commit comments

Comments
 (0)