Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 35147d2248 | |||
| 30be98d6a5 | |||
| 05ad84cc99 | |||
| d95b9d221d |
@ -5,7 +5,7 @@ ADD https://git.tanshu.com/api/v1/repos/tanshu/gru/tags /tags.json
|
||||
RUN git clone --single-branch --depth 1 --branch latest https://git.tanshu.com/tanshu/gru.git /app
|
||||
|
||||
# Install Poetry
|
||||
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | POETRY_HOME=/opt/poetry python && \
|
||||
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python && \
|
||||
cd /usr/local/bin && \
|
||||
ln -s /opt/poetry/bin/poetry && \
|
||||
poetry config virtualenvs.create false
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
# DO Community Playbooks: Docker
|
||||
#################################################
|
||||
---
|
||||
- hosts: gru
|
||||
- hosts: all
|
||||
become: true
|
||||
vars_files:
|
||||
- "vars/gru.yml"
|
||||
|
||||
11
gru/main.py
11
gru/main.py
@ -8,7 +8,7 @@ import uvicorn
|
||||
from fastapi import FastAPI, Form
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .core.config import settings
|
||||
from .config import settings
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
@ -18,6 +18,7 @@ class Reading(BaseModel):
|
||||
temperature: float
|
||||
humidity: float
|
||||
age: int
|
||||
device: str
|
||||
|
||||
|
||||
@app.post("/upload", response_model=Reading)
|
||||
@ -29,14 +30,14 @@ def add_reading(
|
||||
):
|
||||
current_datetime = datetime.datetime.now()
|
||||
deducted_datetime = current_datetime - datetime.timedelta(milliseconds=age)
|
||||
append_to_csv(settings.FILE_PATH, temp, humidity, deducted_datetime)
|
||||
return Reading(temperature=temp, humidity=humidity, age=age)
|
||||
append_to_csv(settings.FILE_PATH, temp, humidity, deducted_datetime, device)
|
||||
return Reading(temperature=temp, humidity=humidity, age=age, device=device)
|
||||
|
||||
|
||||
def append_to_csv(filename, temperature, humidity, datetime_var):
|
||||
def append_to_csv(filename, temperature, humidity, datetime_var, device):
|
||||
with open(filename, "a", newline="") as csvfile:
|
||||
writer = csv.writer(csvfile)
|
||||
writer.writerow([temperature, humidity, datetime_var])
|
||||
writer.writerow([temperature, humidity, datetime_var, device])
|
||||
|
||||
|
||||
def init():
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "gru"
|
||||
version = "0.0.1"
|
||||
version = "0.0.3"
|
||||
description = "Sensor manager."
|
||||
authors = ["tanshu <git@tanshu.com>"]
|
||||
|
||||
|
||||
21
version_bump.sh
Executable file
21
version_bump.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P )
|
||||
cd "$parent_path" || exit
|
||||
|
||||
if [ 1 -eq "$#" ]
|
||||
then
|
||||
echo "Version bump to $1"
|
||||
sed --in-place --regexp-extended 's/version = "([0-9]*.[0-9].[0-9])"/version = "'"$1"'"/g' pyproject.toml
|
||||
git add pyproject.toml
|
||||
git commit -m "Version Bump v$1"
|
||||
git tag "v$1"
|
||||
else
|
||||
echo "No version bump"
|
||||
fi
|
||||
git push
|
||||
git tag --delete latest
|
||||
git tag latest
|
||||
git push --delete origin latest
|
||||
git push --tags
|
||||
Reference in New Issue
Block a user