Skip to content

Commit

Permalink
hot fix (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthemide authored Jun 7, 2023
1 parent 962df74 commit 6f246fa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion deployment/edge/ansible/deploy_vio_on_edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
repo: https://github.com/octo-technology/VIO.git
dest: "{{ REMOTE_VIO_DIR }}"
single_branch: yes
version: deploy_vio_on_edge
version: main
force: true

- name: Copy config on the remote machine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def __init__(self, id: str, settings: Dict[str, Union[str, Dict]]):

def capture(self) -> bytes:
resolution = '640x640'
img_save_path = "./test.jpg"
source = self.settings['source']
img_save_path = f"{source}.jpg".replace('/', '')
cmd = f'fswebcam -r {resolution} -S 3 --jpeg 50 --save {img_save_path} -d {source}'
cmd_feedback = subprocess.run([cmd], shell=True)
logger.info(f"Camera exit code: {cmd_feedback.returncode}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@
class GCPMetadataStorage(MetadataStorage):
def __init__(self):
self.storage_client = storage.Client()
self.prefix = os.environ.get('EDGE_NAME', '')
self.bucket = self.storage_client.get_bucket(os.getenv('GCP_BUCKET_NAME'))

def save_item_metadata(self, item: Item):
item_metadata = json.dumps(item.get_metadata())
blob = self.bucket.blob(f"{item.id}/metadata.json")
blob = self.bucket.blob(
os.path.join(self.prefix, item.id, "metadata.json")
)
blob.upload_from_string(item_metadata, content_type="application/json")

def get_item_metadata(self, item_id: str) -> Dict:
filename = f"{item_id}/metadata.json"
filename = os.path.join(self.prefix, item_id, "metadata.json")
blob = self.bucket.get_blob(filename)
if blob is None:
raise Exception("No file with this id exist")
Expand All @@ -32,7 +35,7 @@ def get_item_state(self, item_id: str) -> str:
def get_all_items_metadata(self) -> List[Dict]:
metadatas = []
for blob in self.bucket.list_blobs():
if "metadata.json" in blob.name:
if self.prefix in blob.name and "metadata.json" in blob.name:
metadata = json.loads(blob.download_as_string())
metadatas.append(metadata)
return metadatas

0 comments on commit 6f246fa

Please sign in to comment.