fix db creation not working, publish docker img action
parent
adb13c9305
commit
f669b899ce
|
|
@ -0,0 +1,34 @@
|
||||||
|
name: Publish Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
paths: ["velconnect/**"]
|
||||||
|
jobs:
|
||||||
|
push_to_registry:
|
||||||
|
name: Push Docker image to Docker Hub
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out the repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Log in to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: velaboratory/velconnect
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: ./velconnect
|
||||||
|
file: ./velconnect/Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
name: Publish to Verdaccio
|
name: Publish to Verdaccio
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: ["main"]
|
||||||
- master
|
paths: ["unity_package/**"]
|
||||||
jobs:
|
jobs:
|
||||||
publish-npm:
|
publish-npm:
|
||||||
name: publish to npm.ugavel.com
|
name: publish to npm.ugavel.com
|
||||||
|
|
@ -9,7 +9,7 @@ class DB:
|
||||||
|
|
||||||
def create_or_connect(self):
|
def create_or_connect(self):
|
||||||
create = False
|
create = False
|
||||||
if not os.path.exists(self.db_name, ):
|
if not os.path.exists(self.db_name):
|
||||||
create = True
|
create = True
|
||||||
|
|
||||||
conn = sqlite3.connect(self.db_name)
|
conn = sqlite3.connect(self.db_name)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
docker build --tag velconnect .
|
||||||
|
docker rm web
|
||||||
|
docker run -p 8081:80 --name web velconnect
|
||||||
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
docker build --tag velconnect .
|
||||||
|
docker rm web
|
||||||
|
docker run -p 8081:80 --name web velconnect
|
||||||
|
|
||||||
|
|
@ -92,7 +92,8 @@ def get_device_by_pairing_code(pairing_code: str):
|
||||||
|
|
||||||
|
|
||||||
def get_device_by_pairing_code_dict(pairing_code: str) -> dict | None:
|
def get_device_by_pairing_code_dict(pairing_code: str) -> dict | None:
|
||||||
values = db.query("SELECT * FROM `Device` WHERE `pairing_code`=:pairing_code;", {'pairing_code': pairing_code})
|
values = db.query(
|
||||||
|
"SELECT * FROM `Device` WHERE `pairing_code`=:pairing_code;", {'pairing_code': pairing_code})
|
||||||
if len(values) == 1:
|
if len(values) == 1:
|
||||||
device = dict(values[0])
|
device = dict(values[0])
|
||||||
parse_data(device)
|
parse_data(device)
|
||||||
|
|
@ -101,7 +102,8 @@ def get_device_by_pairing_code_dict(pairing_code: str) -> dict | None:
|
||||||
|
|
||||||
|
|
||||||
def get_user_for_device(hw_id: str) -> dict:
|
def get_user_for_device(hw_id: str) -> dict:
|
||||||
values = db.query("""SELECT * FROM `UserDevice` WHERE `hw_id`=:hw_id;""", {'hw_id': hw_id})
|
values = db.query(
|
||||||
|
"""SELECT * FROM `UserDevice` WHERE `hw_id`=:hw_id;""", {'hw_id': hw_id})
|
||||||
if len(values) == 1:
|
if len(values) == 1:
|
||||||
user_id = dict(values[0])['user_id']
|
user_id = dict(values[0])['user_id']
|
||||||
user = get_user_dict(user_id=user_id)
|
user = get_user_dict(user_id=user_id)
|
||||||
|
|
@ -149,7 +151,7 @@ def get_device_data(request: Request, response: Response, hw_id: str):
|
||||||
room_data = get_data(response, key=room_key, user_id=user['id'])
|
room_data = get_data(response, key=room_key, user_id=user['id'])
|
||||||
|
|
||||||
if "error" in room_data:
|
if "error" in room_data:
|
||||||
response.status_code = None # this really isn't an error, so we reset the status code
|
response.status_code = None # this really isn't an error, so we reset the status code
|
||||||
set_data(request, data={}, key=room_key,
|
set_data(request, data={}, key=room_key,
|
||||||
modified_by=None, category="room")
|
modified_by=None, category="room")
|
||||||
room_data = get_data(response, key=room_key, user_id=user['id'])
|
room_data = get_data(response, key=room_key, user_id=user['id'])
|
||||||
|
|
@ -264,21 +266,21 @@ def set_data(request: fastapi.Request, data: dict, key: str = None, owner: str =
|
||||||
old_data: dict = json.loads(old_data_query[0]["data"])
|
old_data: dict = json.loads(old_data_query[0]["data"])
|
||||||
data = {**old_data, **data}
|
data = {**old_data, **data}
|
||||||
|
|
||||||
# add the data to the db
|
# add the data to the db
|
||||||
db.insert("""
|
db.insert("""
|
||||||
REPLACE INTO `DataBlock` (id, owner_id, category, modified_by, data, last_modified)
|
UPDATE `DataBlock` SET
|
||||||
VALUES(:id, :owner_id, :category, :modified_by, :data, CURRENT_TIMESTAMP);
|
category = :category,
|
||||||
""", {"id": key, "owner_id": owner, "category": category, "modified_by": modified_by, "data": json.dumps(data)})
|
modified_by = :modified_by,
|
||||||
|
data = :data,
|
||||||
# # add the data to the db
|
last_modified = CURRENT_TIMESTAMP
|
||||||
# db.insert("""
|
WHERE id=:id AND owner_id = :owner_id;
|
||||||
# REPLACE INTO `DataBlock` SET
|
""", {"id": key, "category": category, "modified_by": modified_by, "owner_id": owner, "data": json.dumps(data)})
|
||||||
# category = :category,
|
else:
|
||||||
# modified_by = :modified_by,
|
# add the data to the db
|
||||||
# data = :data,
|
db.insert("""
|
||||||
# last_modified = CURRENT_TIMESTAMP
|
INSERT INTO `DataBlock` (id, owner_id, category, modified_by, data, last_modified)
|
||||||
# WHERE id=:id AND owner_id = :owner_id;
|
VALUES(:id, :owner_id, :category, :modified_by, :data, CURRENT_TIMESTAMP);
|
||||||
# """, {"id": key, "category": category, "modified_by": modified_by, "owner_id": owner, "data": json.dumps(data)})
|
""", {"id": key, "owner_id": owner, "category": category, "modified_by": modified_by, "data": json.dumps(data)})
|
||||||
|
|
||||||
return {'key': key}
|
return {'key': key}
|
||||||
|
|
||||||
|
|
@ -349,7 +351,8 @@ def get_user(response: Response, user_id: str):
|
||||||
|
|
||||||
|
|
||||||
def get_user_dict(user_id: str) -> dict | None:
|
def get_user_dict(user_id: str) -> dict | None:
|
||||||
values = db.query("SELECT * FROM `User` WHERE `id`=:user_id;", {'user_id': user_id})
|
values = db.query(
|
||||||
|
"SELECT * FROM `User` WHERE `id`=:user_id;", {'user_id': user_id})
|
||||||
if len(values) == 1:
|
if len(values) == 1:
|
||||||
user = dict(values[0])
|
user = dict(values[0])
|
||||||
parse_data(user)
|
parse_data(user)
|
||||||
|
|
@ -379,7 +382,8 @@ async def upload_file(request: fastapi.Request, file: UploadFile, key: str | Non
|
||||||
content = await file.read() # async read
|
content = await file.read() # async read
|
||||||
await out_file.write(content) # async write
|
await out_file.write(content) # async write
|
||||||
# add a datablock to link to the file
|
# add a datablock to link to the file
|
||||||
set_data(request, data={'filename': file.filename}, key=key, category='file', modified_by=modified_by)
|
set_data(request, data={'filename': file.filename},
|
||||||
|
key=key, category='file', modified_by=modified_by)
|
||||||
return {"filename": file.filename, 'key': key}
|
return {"filename": file.filename, 'key': key}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue