diff --git a/Dockerfile b/Dockerfile index 033c969..2e21507 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM python:3.6-alpine3.7 -ADD [".", "/app"] +ADD ["src", "requirements.txt", "/app/"] WORKDIR /app RUN apk add --update g++ gfortran openblas-dev libpng-dev musl-dev freetype-dev libpng openblas libstdc++ && \ pip install -r requirements.txt --no-cache-dir && \ diff --git a/docker-compose.yml b/docker-compose.yml index 67d2da9..930c9e3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,6 @@ version: "2" services: doorbot: build: . - image: fswiai/doorbot:0.3.2 + image: fswiai/doorbot:0.4 volumes: - ./settings.json:/app/settings.json \ No newline at end of file diff --git a/bot.py b/src/bot.py similarity index 100% rename from bot.py rename to src/bot.py diff --git a/plot.py b/src/plot.py similarity index 100% rename from plot.py rename to src/plot.py diff --git a/sources.py b/src/sources.py similarity index 84% rename from sources.py rename to src/sources.py index d2bd8a4..716e3cb 100644 --- a/sources.py +++ b/src/sources.py @@ -10,7 +10,7 @@ class Source: raise NotImplementedError() def is_recent(self, status, **kwargs): - raise NotImplementedError() + return status.timestamp + datetime.timedelta(days=1) < datetime.datetime.today() class IsFsWIAIopen(Source): url = "https://isfswiaiopen.wiai.de?json" @@ -29,7 +29,4 @@ class IsFsWIAIopen(Source): return Status( doorstate=str(status['doorstate']), timestamp=self._parse_time(status['timestamp']), - text=self._get_text(str(status['doorstate']))) - - def is_recent(self, status, **kwargs): - return status.timestamp + datetime.timedelta(days=1) < datetime.datetime.today() \ No newline at end of file + text=self._get_text(str(status['doorstate']))) \ No newline at end of file diff --git a/targets.py b/src/targets.py similarity index 96% rename from targets.py rename to src/targets.py index 3df4708..cfcb7d0 100644 --- a/targets.py +++ b/src/targets.py @@ -7,17 +7,19 @@ from matrix_client.errors import MatrixError class Client: + def __init__(self): + raise NotImplementedError() + def post_image(self, file, name, content_type="image/png", targets=None): """Push to all targets""" self.post_image(file, name, content_type, targets) - #raise NotImplementedError() def send_image(self, target, file, name, content_type="image/png"): """Send an image to a room Args: target (str): The internal room id to post into - path (file): The image file object + file (file): The image file object name (str): The name for the file in the room content_type (str): Content-type of the image """ @@ -26,7 +28,6 @@ class Client: def post_text(self, text, targets=None): """Push to all targets""" self.post_text(text, targets) - #raise NotImplementedError() def send_text(self, target, text): """Send a text to a room