Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nengyuanzhang committed Dec 27, 2024
2 parents 69f31dc + 5feee88 commit 60c9a0c
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]
### Added
-
### Changed
- updated dockerfiles to reduce images size
- updated command actions in myems-api
### Fixed
-
### Removed
-

## [v4.12.0] - 2024-12-21
### Added
Expand Down
2 changes: 1 addition & 1 deletion myems-admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM nginx:latest

RUN apt update && apt install -y nano telnet
# RUN apt update && apt install -y nano telnet

# remove the default config
RUN rm /etc/nginx/conf.d/default.conf && \
Expand Down
2 changes: 1 addition & 1 deletion myems-aggregation/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.10-slim

RUN apt update && apt install -y nano telnet
# RUN apt update && apt install -y nano telnet

WORKDIR /app
COPY . /app
Expand Down
2 changes: 1 addition & 1 deletion myems-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.10-slim

RUN apt update && apt install -y nano telnet
# RUN apt update && apt install -y nano telnet

# todo: share upload folder with admin container on Docker

Expand Down
18 changes: 13 additions & 5 deletions myems-api/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def on_post(req, resp):
len(str.strip(new_values['data']['topic'])) == 0:
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_TOPIC')
topic = str.lower(str.strip(new_values['data']['topic']))
topic = str.strip(new_values['data']['topic'])

if 'payload' not in new_values['data'].keys() or \
not isinstance(new_values['data']['payload'], str) or \
Expand Down Expand Up @@ -331,7 +331,7 @@ def on_put(req, resp, id_):
len(str.strip(new_values['data']['topic'])) == 0:
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_TOPIC')
topic = str.lower(str.strip(new_values['data']['topic']))
topic = str.strip(new_values['data']['topic'])

if 'payload' not in new_values['data'].keys() or \
not isinstance(new_values['data']['payload'], str) or \
Expand Down Expand Up @@ -439,8 +439,6 @@ def on_put(req, resp, id_):
" WHERE id = %s ")
cursor.execute(query, (id_,))
row = cursor.fetchone()
cursor.close()
cnx.close()

if row is None:
raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
Expand All @@ -453,6 +451,16 @@ def on_put(req, resp, id_):
"payload": row[4],
"set_value": set_value if set_value is not None else row[5]}

update_row = (" UPDATE tbl_commands "
" SET set_value = %s "
" WHERE id = %s ")
cursor.execute(update_row, (set_value,
id_,))
cnx.commit()

cursor.close()
cnx.close()

mqc = None
try:
mqc = mqtt.Client(callback_api_version=mqtt.CallbackAPIVersion.VERSION2,
Expand Down Expand Up @@ -565,7 +573,7 @@ def on_post(req, resp):
len(str.strip(new_values['topic'])) == 0:
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_TOPIC')
topic = str.lower(str.strip(new_values['topic']))
topic = str.strip(new_values['topic'])

if 'payload' not in new_values.keys() or \
not isinstance(new_values['payload'], str) or \
Expand Down
2 changes: 1 addition & 1 deletion myems-cleaning/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.10-slim

RUN apt update && apt install -y nano telnet
# RUN apt update && apt install -y nano telnet

WORKDIR /app
COPY . /app
Expand Down
2 changes: 1 addition & 1 deletion myems-normalization/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.10-slim

RUN apt update && apt install -y nano telnet
# RUN apt update && apt install -y nano telnet

WORKDIR /app
COPY . /app
Expand Down
2 changes: 1 addition & 1 deletion myems-web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN npm run build

FROM nginx:latest AS production-stage

RUN apt update && apt install -y nano telnet
# RUN apt update && apt install -y nano telnet

# remove the default config
RUN rm /etc/nginx/conf.d/default.conf && rm /etc/nginx/nginx.conf
Expand Down

0 comments on commit 60c9a0c

Please sign in to comment.