4 Commits
v0.0.1 ... main

Author SHA1 Message Date
35147d2248 Version Bump v0.0.3 2023-07-07 07:13:53 +05:30
30be98d6a5 Forgot to add the device name to the csv file. 2023-07-07 07:13:47 +05:30
05ad84cc99 Version Bump v0.0.2 2023-07-07 07:05:32 +05:30
d95b9d221d Fix: Edits were not committed 2023-07-07 07:03:07 +05:30
5 changed files with 30 additions and 8 deletions

View File

@ -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 RUN git clone --single-branch --depth 1 --branch latest https://git.tanshu.com/tanshu/gru.git /app
# Install Poetry # 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 && \ cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \ ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false poetry config virtualenvs.create false

View File

@ -2,7 +2,7 @@
# DO Community Playbooks: Docker # DO Community Playbooks: Docker
################################################# #################################################
--- ---
- hosts: gru - hosts: all
become: true become: true
vars_files: vars_files:
- "vars/gru.yml" - "vars/gru.yml"

View File

@ -8,7 +8,7 @@ import uvicorn
from fastapi import FastAPI, Form from fastapi import FastAPI, Form
from pydantic import BaseModel from pydantic import BaseModel
from .core.config import settings from .config import settings
app = FastAPI() app = FastAPI()
@ -18,6 +18,7 @@ class Reading(BaseModel):
temperature: float temperature: float
humidity: float humidity: float
age: int age: int
device: str
@app.post("/upload", response_model=Reading) @app.post("/upload", response_model=Reading)
@ -29,14 +30,14 @@ def add_reading(
): ):
current_datetime = datetime.datetime.now() current_datetime = datetime.datetime.now()
deducted_datetime = current_datetime - datetime.timedelta(milliseconds=age) deducted_datetime = current_datetime - datetime.timedelta(milliseconds=age)
append_to_csv(settings.FILE_PATH, temp, humidity, deducted_datetime) append_to_csv(settings.FILE_PATH, temp, humidity, deducted_datetime, device)
return Reading(temperature=temp, humidity=humidity, age=age) 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: with open(filename, "a", newline="") as csvfile:
writer = csv.writer(csvfile) writer = csv.writer(csvfile)
writer.writerow([temperature, humidity, datetime_var]) writer.writerow([temperature, humidity, datetime_var, device])
def init(): def init():

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "gru" name = "gru"
version = "0.0.1" version = "0.0.3"
description = "Sensor manager." description = "Sensor manager."
authors = ["tanshu <git@tanshu.com>"] authors = ["tanshu <git@tanshu.com>"]

21
version_bump.sh Executable file
View 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