Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
51f0346
sync setting, activities
previ Apr 10, 2023
c857b1a
wip
previ Apr 18, 2023
a2e6f39
wip
previ Apr 25, 2023
e17230d
wip
previ May 7, 2023
29b0dc4
wip
previ May 21, 2023
15d215d
wip
previ May 28, 2023
f5a4395
wip
previ May 29, 2023
57b2f03
wip
previ Jun 1, 2023
19a4398
wip
previ Jun 2, 2023
9377a57
wip
previ Jun 4, 2023
1cf11aa
wip
previ Jun 4, 2023
8f0e377
wip
previ Jun 4, 2023
0607076
wip
previ Jun 5, 2023
fba1635
wip
previ Jun 5, 2023
e5a2592
wip
previ Jun 5, 2023
870ea4b
wip
previ Jun 5, 2023
ab77159
wip
previ Jun 5, 2023
0b84abb
wip
previ Jun 5, 2023
cb8f7f9
wip
previ Jun 5, 2023
0645172
wip
previ Jun 5, 2023
304f221
wip
previ Jun 5, 2023
affa726
wip
previ Jun 5, 2023
b2999aa
wip
previ Jun 6, 2023
a430f2a
wip
previ Jun 11, 2023
639d4b9
wip
previ Aug 16, 2023
f23d78f
wip
previ Aug 16, 2023
1ba0456
update default config.json
previ Aug 19, 2023
bd2ee94
increase initial delay for testing
previ Aug 19, 2023
f1817f8
debug test api
previ Aug 19, 2023
16ffbad
debug tests
previ Aug 19, 2023
b49c58d
debug tests
previ Aug 19, 2023
24ef531
Update camera_test.py - fix tests
previ Aug 19, 2023
52f5dd1
Update coderbot_test.py - fix
previ Aug 19, 2023
f65bc87
Update camera_test.py fix
previ Aug 19, 2023
7c13bb3
Update coderbot_test.py fix
previ Aug 19, 2023
7070b18
Update coderbot_test.py -fix
previ Aug 19, 2023
14f6478
Update coderbot_test.py fix servo test
previ Aug 19, 2023
164da91
Update Dockerfile stub add CODERBOT_CLOUD_API_ENDPOINT
previ Aug 19, 2023
45e0bce
fixes
previ Aug 26, 2023
8198e09
fix
previ Aug 27, 2023
bfaa258
fix
previ Aug 27, 2023
6969fea
fix
previ Aug 27, 2023
f639184
fix
previ Aug 27, 2023
24dde58
fix
previ Aug 27, 2023
f50165b
wip
previ Dec 23, 2023
4967d4d
bumo deps
previ Dec 24, 2023
ffcb801
bump deps
previ Dec 24, 2023
b6a4401
bump deps
previ Dec 24, 2023
d8ef622
fix audio_devide
previ Dec 24, 2023
e929c0e
fix bot, cam
previ Dec 24, 2023
c89f25c
fix video stream
previ Dec 24, 2023
9ad1051
add uuid
previ Dec 28, 2023
f561d46
add uuid
previ Dec 28, 2023
5880e87
add uuid
previ Dec 28, 2023
2b1be19
add uuid
previ Dec 28, 2023
ca68f8f
fix sync activity, program
previ Dec 30, 2023
e0582ac
fix daveProgram case of null body
previ Dec 31, 2023
e214e59
sync settings
previ Dec 31, 2023
93735f7
fix detectMultiScale
previ Feb 28, 2024
13e081a
schemathesis==3.24.3
previ Mar 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
  • Loading branch information
previ committed Dec 23, 2023
commit f50165b60feea193ded918a31870b1c872564017
2 changes: 1 addition & 1 deletion coderbot/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def delete(self, name, logical = True):
if len(activities) > 0:
activity = activities[0]
if activity.get("default", False) is True:
self.activities.update({'default': True}, self.query.stock == True)
self.activities.update({'default': True}, self.query.kind == ACTIVITY_KIND_STOCK)
if logical:
activity["status"] = ACTIVITY_STATUS_DELETED
activity["modified"] = datetime.now().isoformat()
Expand Down
48 changes: 24 additions & 24 deletions coderbot/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,47 +123,47 @@ def get_info():

def stop():
bot.stop()
return 200
return {}

def move(body):
speed=body.get("speed")
elapse=body.get("elapse")
distance=body.get("distance")
if (speed is None or speed == 0) or (elapse is not None and distance is not None):
return 400
return None, 400
bot.move(speed=speed, elapse=elapse, distance=distance)
return 200
return {}

def turn(body):
speed=body.get("speed")
elapse=body.get("elapse")
distance=body.get("distance")
if (speed is None or speed == 0) or (elapse is not None and distance is not None):
return 400
return None, 400
bot.turn(speed=speed, elapse=elapse, distance=distance)
return 200
return {}

def takePhoto():
try:
cam.photo_take()
audio_device.say(settings.get("sound_shutter"))
return 200
return {}
except Exception as e:
logging.warning("Error: %s", e)

def recVideo():
try:
cam.video_rec()
audio_device.say(settings.get("sound_shutter"))
return 200
return {}
except Exception as e:
logging.warning("Error: %s", e)

def stopVideo():
try:
cam.video_stop()
audio_device.say(settings.get("sound_shutter"))
return 200
return {}
except Exception as e:
logging.warning("Error: %s", e)

Expand All @@ -172,24 +172,24 @@ def speak(body):
locale = body.get("locale", "")
logging.debug("say: " + text + " in: " + locale)
audio_device.say(text, locale)
return 200
return {}

def reset():
Balena.get_instance().purge()
return 200
return {}

def halt():
audio_device.say(what=settings.get("sound_stop"))
Balena.get_instance().shutdown()
return 200
return {}

def restart():
Balena.get_instance().restart()

def reboot():
audio_device.say(what=settings.get("sound_stop"))
Balena.get_instance().reboot()
return 200
return {}

def video_stream(a_cam):
while True:
Expand Down Expand Up @@ -223,22 +223,22 @@ def getPhoto(name):
return send_file(media_file, mimetype=mimetype.get(name[:-3], 'image/jpeg'), max_age=0)
except picamera.exc.PiCameraError as e:
logging.error("Error: %s", str(e))
return 503
return {"exception": str(e)}, 503
except FileNotFoundError:
return 404
return None, 404

def savePhoto(name, body):
try:
cam.update_photo({"name": name, "tag": body.get("tag")})
except FileNotFoundError:
return 404
return None, 404

def deletePhoto(name):
logging.debug("photo delete")
try:
cam.delete_photo(name)
except FileNotFoundError:
return 404
return None, 404

def restoreSettings():
Config.restore()
Expand All @@ -249,14 +249,14 @@ def loadSettings():

def saveSettings(body):
Config.write(body)
return 200
return Config.write(body)

def updateFromPackage():
os.system('sudo bash /home/pi/clean-update.sh')
file_to_upload = connexion.request.files['file_to_upload']
file_to_upload.save(os.path.join('/home/pi/', 'update.tar'))
os.system('sudo reboot')
return 200
return {}

def listMusicPackages():
"""
Expand Down Expand Up @@ -291,7 +291,7 @@ def deleteMusicPackage(name):
"""
musicPkg = MusicPackageManager.get_instance()
musicPkg.deletePackage(name)
return 200
return {}

## Programs

Expand All @@ -305,14 +305,14 @@ def saveProgram(name, body):
return "defaultCannotOverwrite", 400
program = Program(name=body.get("name"), code=body.get("code"), dom_code=body.get("dom_code"), modified=datetime.now(), status="active")
prog_engine.save(program)
return 200
return {}

def loadProgram(name):
existing_program = prog_engine.load(name)
if existing_program:
return existing_program.as_dict(), 200
else:
return 404
return None, 404

def deleteProgram(name):
prog_engine.delete(name, logical=True)
Expand Down Expand Up @@ -415,18 +415,18 @@ def deleteCNNModel(name):

def cloudSyncRequest():
CloudManager.get_instance().sync()
return 200
return {}

def cloudSyncStatus():
return CloudManager.get_instance().sync_status()

def cloudRegistrationRequest(body):
CloudManager.get_instance().register(body)
return 200
return {}

def cloudRegistrationDelete():
CloudManager.get_instance().unregister()
return 200
return {}

def cloudRegistrationStatus():
registration = cloud_settings.get('registration', {})
Expand Down
2 changes: 1 addition & 1 deletion coderbot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

# Serve a custom version of the swagger ui (Jinja2 templates) based on the default one
# from the folder 'swagger-ui'. Clone the 'swagger-ui' repository inside the backend folder
options = {"swagger_ui": False}
options = {"swagger_ui": True}
connexionApp = connexion.App(__name__, options=options)

# Connexion wraps FlaskApp, so app becomes connexionApp.app
Expand Down
4 changes: 4 additions & 0 deletions coderbot/v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ paths:
responses:
200:
description: "ok"
content:
application/json:
schema:
$ref: '#/components/schemas/Settings'
tags:
- CoderBot configuration
/settings/restore:
Expand Down