From 54b52f78bfa3e1c070717b454bcdfd849a4c6fbd Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Sat, 15 Jan 2022 22:14:12 +0100 Subject: [PATCH] Dockerized and fixed errors --- Dockerfile | 12 ++++++++++++ {bot => app/bot}/__init__.py | 0 app/bot/api/__init__.py | 12 ++++++++++++ {bot => app/bot}/api/metmuseum.py | 0 {bot => app/bot}/api/reddit.py | 0 {bot => app/bot}/api/search.py | 0 {bot => app/bot}/api/weather.py | 0 {bot => app/bot}/commands/__init__.py | 0 {bot => app/bot}/commands/alias.py | 0 {bot => app/bot}/commands/clock.py | 0 {bot => app/bot}/commands/help.py | 0 {bot => app/bot}/commands/lists.py | 0 {bot => app/bot}/commands/plaintext.py | 0 {bot => app/bot}/commands/reddit.py | 0 {bot => app/bot}/commands/search.py | 0 {bot => app/bot}/commands/status.py | 0 {bot => app/bot}/commands/template.py | 0 {bot => app/bot}/commands/weather.py | 0 {bot => app/bot}/commands/zvv.py | 0 {bot => app/bot}/main.py | 2 +- {broadcast => app/broadcast}/__init__.py | 0 {broadcast => app/broadcast}/b_in.py | 0 {broadcast => app/broadcast}/b_out.py | 0 client.py => app/client.py | 0 {clock => app/clock}/__init__.py | 0 {clock => app/clock}/c_back.py | 0 {clock => app/clock}/c_in.py | 0 {clock => app/clock}/c_out.py | 0 {clock => app/clock}/hardware/__init__.py | 0 {clock => app/clock}/hardware/led.py | 0 {clock => app/clock}/hardware/neopixel.py | 0 {clock => app/clock}/hardware/sensors.py | 0 {clock => app/clock}/hardware/sim.py | 0 {clock => app/clock}/hardware/unicorn.py | 0 {clock => app/clock}/helpers/__init__.py | 0 {clock => app/clock}/helpers/computations.py | 0 {clock => app/clock}/helpers/shapes.py | 0 {clock => app/clock}/helpers/timer.py | 0 {clock => app/clock}/helpers/weather-icons.bmp | Bin launcher.py => app/launcher.py | 0 {persistence => app/persistence}/README.md | 0 {persistence => app/persistence}/__init__.py | 0 {persistence => app/persistence}/database.py | 10 ++++++++-- {persistence => app/persistence}/local_io.py | 0 {persistence => app/persistence}/models.py | 0 server.py => app/server.py | 4 ++-- bot/api/__init__.py | 6 ------ requirements.txt | Bin 430 -> 446 bytes 48 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 Dockerfile rename {bot => app/bot}/__init__.py (100%) create mode 100644 app/bot/api/__init__.py rename {bot => app/bot}/api/metmuseum.py (100%) rename {bot => app/bot}/api/reddit.py (100%) rename {bot => app/bot}/api/search.py (100%) rename {bot => app/bot}/api/weather.py (100%) rename {bot => app/bot}/commands/__init__.py (100%) rename {bot => app/bot}/commands/alias.py (100%) rename {bot => app/bot}/commands/clock.py (100%) rename {bot => app/bot}/commands/help.py (100%) rename {bot => app/bot}/commands/lists.py (100%) rename {bot => app/bot}/commands/plaintext.py (100%) rename {bot => app/bot}/commands/reddit.py (100%) rename {bot => app/bot}/commands/search.py (100%) rename {bot => app/bot}/commands/status.py (100%) rename {bot => app/bot}/commands/template.py (100%) rename {bot => app/bot}/commands/weather.py (100%) rename {bot => app/bot}/commands/zvv.py (100%) rename {bot => app/bot}/main.py (96%) rename {broadcast => app/broadcast}/__init__.py (100%) rename {broadcast => app/broadcast}/b_in.py (100%) rename {broadcast => app/broadcast}/b_out.py (100%) rename client.py => app/client.py (100%) rename {clock => app/clock}/__init__.py (100%) rename {clock => app/clock}/c_back.py (100%) rename {clock => app/clock}/c_in.py (100%) rename {clock => app/clock}/c_out.py (100%) rename {clock => app/clock}/hardware/__init__.py (100%) rename {clock => app/clock}/hardware/led.py (100%) rename {clock => app/clock}/hardware/neopixel.py (100%) rename {clock => app/clock}/hardware/sensors.py (100%) rename {clock => app/clock}/hardware/sim.py (100%) rename {clock => app/clock}/hardware/unicorn.py (100%) rename {clock => app/clock}/helpers/__init__.py (100%) rename {clock => app/clock}/helpers/computations.py (100%) rename {clock => app/clock}/helpers/shapes.py (100%) rename {clock => app/clock}/helpers/timer.py (100%) rename {clock => app/clock}/helpers/weather-icons.bmp (100%) rename launcher.py => app/launcher.py (100%) rename {persistence => app/persistence}/README.md (100%) rename {persistence => app/persistence}/__init__.py (100%) rename {persistence => app/persistence}/database.py (90%) rename {persistence => app/persistence}/local_io.py (100%) rename {persistence => app/persistence}/models.py (100%) rename server.py => app/server.py (91%) delete mode 100644 bot/api/__init__.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a2a7921 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.10-buster + + +RUN mkdir -p /app +COPY requirements.txt /app/ +RUN python3 -m pip install --upgrade pip && python3 -m pip install -r /app/requirements.txt + +COPY app/ /app/ +WORKDIR /app/ +ENV containterized true + +CMD ["python3", "server.py"] diff --git a/bot/__init__.py b/app/bot/__init__.py similarity index 100% rename from bot/__init__.py rename to app/bot/__init__.py diff --git a/app/bot/api/__init__.py b/app/bot/api/__init__.py new file mode 100644 index 0000000..7734fab --- /dev/null +++ b/app/bot/api/__init__.py @@ -0,0 +1,12 @@ +from . import reddit +from . import weather +from . import reddit +from . import search +from . import metmuseum +import os +if os.getenv("dockerized", "") == "true": + import sys + sys.path.append("/keys") + import api_keys as keys +else: + from . import keys \ No newline at end of file diff --git a/bot/api/metmuseum.py b/app/bot/api/metmuseum.py similarity index 100% rename from bot/api/metmuseum.py rename to app/bot/api/metmuseum.py diff --git a/bot/api/reddit.py b/app/bot/api/reddit.py similarity index 100% rename from bot/api/reddit.py rename to app/bot/api/reddit.py diff --git a/bot/api/search.py b/app/bot/api/search.py similarity index 100% rename from bot/api/search.py rename to app/bot/api/search.py diff --git a/bot/api/weather.py b/app/bot/api/weather.py similarity index 100% rename from bot/api/weather.py rename to app/bot/api/weather.py diff --git a/bot/commands/__init__.py b/app/bot/commands/__init__.py similarity index 100% rename from bot/commands/__init__.py rename to app/bot/commands/__init__.py diff --git a/bot/commands/alias.py b/app/bot/commands/alias.py similarity index 100% rename from bot/commands/alias.py rename to app/bot/commands/alias.py diff --git a/bot/commands/clock.py b/app/bot/commands/clock.py similarity index 100% rename from bot/commands/clock.py rename to app/bot/commands/clock.py diff --git a/bot/commands/help.py b/app/bot/commands/help.py similarity index 100% rename from bot/commands/help.py rename to app/bot/commands/help.py diff --git a/bot/commands/lists.py b/app/bot/commands/lists.py similarity index 100% rename from bot/commands/lists.py rename to app/bot/commands/lists.py diff --git a/bot/commands/plaintext.py b/app/bot/commands/plaintext.py similarity index 100% rename from bot/commands/plaintext.py rename to app/bot/commands/plaintext.py diff --git a/bot/commands/reddit.py b/app/bot/commands/reddit.py similarity index 100% rename from bot/commands/reddit.py rename to app/bot/commands/reddit.py diff --git a/bot/commands/search.py b/app/bot/commands/search.py similarity index 100% rename from bot/commands/search.py rename to app/bot/commands/search.py diff --git a/bot/commands/status.py b/app/bot/commands/status.py similarity index 100% rename from bot/commands/status.py rename to app/bot/commands/status.py diff --git a/bot/commands/template.py b/app/bot/commands/template.py similarity index 100% rename from bot/commands/template.py rename to app/bot/commands/template.py diff --git a/bot/commands/weather.py b/app/bot/commands/weather.py similarity index 100% rename from bot/commands/weather.py rename to app/bot/commands/weather.py diff --git a/bot/commands/zvv.py b/app/bot/commands/zvv.py similarity index 100% rename from bot/commands/zvv.py rename to app/bot/commands/zvv.py diff --git a/bot/main.py b/app/bot/main.py similarity index 96% rename from bot/main.py rename to app/bot/main.py index 82fbf79..6591462 100644 --- a/bot/main.py +++ b/app/bot/main.py @@ -66,4 +66,4 @@ class ChatBot(): self.telegram.start_polling( poll_interval=0.2, ) - # self.telegram.idle() + self.telegram.idle() diff --git a/broadcast/__init__.py b/app/broadcast/__init__.py similarity index 100% rename from broadcast/__init__.py rename to app/broadcast/__init__.py diff --git a/broadcast/b_in.py b/app/broadcast/b_in.py similarity index 100% rename from broadcast/b_in.py rename to app/broadcast/b_in.py diff --git a/broadcast/b_out.py b/app/broadcast/b_out.py similarity index 100% rename from broadcast/b_out.py rename to app/broadcast/b_out.py diff --git a/client.py b/app/client.py similarity index 100% rename from client.py rename to app/client.py diff --git a/clock/__init__.py b/app/clock/__init__.py similarity index 100% rename from clock/__init__.py rename to app/clock/__init__.py diff --git a/clock/c_back.py b/app/clock/c_back.py similarity index 100% rename from clock/c_back.py rename to app/clock/c_back.py diff --git a/clock/c_in.py b/app/clock/c_in.py similarity index 100% rename from clock/c_in.py rename to app/clock/c_in.py diff --git a/clock/c_out.py b/app/clock/c_out.py similarity index 100% rename from clock/c_out.py rename to app/clock/c_out.py diff --git a/clock/hardware/__init__.py b/app/clock/hardware/__init__.py similarity index 100% rename from clock/hardware/__init__.py rename to app/clock/hardware/__init__.py diff --git a/clock/hardware/led.py b/app/clock/hardware/led.py similarity index 100% rename from clock/hardware/led.py rename to app/clock/hardware/led.py diff --git a/clock/hardware/neopixel.py b/app/clock/hardware/neopixel.py similarity index 100% rename from clock/hardware/neopixel.py rename to app/clock/hardware/neopixel.py diff --git a/clock/hardware/sensors.py b/app/clock/hardware/sensors.py similarity index 100% rename from clock/hardware/sensors.py rename to app/clock/hardware/sensors.py diff --git a/clock/hardware/sim.py b/app/clock/hardware/sim.py similarity index 100% rename from clock/hardware/sim.py rename to app/clock/hardware/sim.py diff --git a/clock/hardware/unicorn.py b/app/clock/hardware/unicorn.py similarity index 100% rename from clock/hardware/unicorn.py rename to app/clock/hardware/unicorn.py diff --git a/clock/helpers/__init__.py b/app/clock/helpers/__init__.py similarity index 100% rename from clock/helpers/__init__.py rename to app/clock/helpers/__init__.py diff --git a/clock/helpers/computations.py b/app/clock/helpers/computations.py similarity index 100% rename from clock/helpers/computations.py rename to app/clock/helpers/computations.py diff --git a/clock/helpers/shapes.py b/app/clock/helpers/shapes.py similarity index 100% rename from clock/helpers/shapes.py rename to app/clock/helpers/shapes.py diff --git a/clock/helpers/timer.py b/app/clock/helpers/timer.py similarity index 100% rename from clock/helpers/timer.py rename to app/clock/helpers/timer.py diff --git a/clock/helpers/weather-icons.bmp b/app/clock/helpers/weather-icons.bmp similarity index 100% rename from clock/helpers/weather-icons.bmp rename to app/clock/helpers/weather-icons.bmp diff --git a/launcher.py b/app/launcher.py similarity index 100% rename from launcher.py rename to app/launcher.py diff --git a/persistence/README.md b/app/persistence/README.md similarity index 100% rename from persistence/README.md rename to app/persistence/README.md diff --git a/persistence/__init__.py b/app/persistence/__init__.py similarity index 100% rename from persistence/__init__.py rename to app/persistence/__init__.py diff --git a/persistence/database.py b/app/persistence/database.py similarity index 90% rename from persistence/database.py rename to app/persistence/database.py index ad80a00..31246e3 100644 --- a/persistence/database.py +++ b/app/persistence/database.py @@ -7,8 +7,14 @@ import logging logger = logging.getLogger(__name__) -from . import keys -dbk = keys.db_keys +import os +if os.getenv("dockerized", "") == "true": + import sys + sys.path.append("/keys") + import db_keys as keys +else: + from . import keys +dbk = keys.db_access diff --git a/persistence/local_io.py b/app/persistence/local_io.py similarity index 100% rename from persistence/local_io.py rename to app/persistence/local_io.py diff --git a/persistence/models.py b/app/persistence/models.py similarity index 100% rename from persistence/models.py rename to app/persistence/models.py diff --git a/server.py b/app/server.py similarity index 91% rename from server.py rename to app/server.py index 8ca3ba5..08a5d50 100644 --- a/server.py +++ b/app/server.py @@ -8,8 +8,8 @@ import logging import platform -if platform.uname().node == "ArchSpectre": - # development +import os +if os.getenv("dockerized", "") == "true" or platform.uname().node == "ArchSpectre": logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO ) diff --git a/bot/api/__init__.py b/bot/api/__init__.py deleted file mode 100644 index 97cff3a..0000000 --- a/bot/api/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from . import keys -from . import reddit -from . import weather -from . import reddit -from . import search -from . import metmuseum \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 8360100b0311e2cda74ab13711370232481dc4f6..58f60c19b136340f0c37a8227dadefdd95380259 100644 GIT binary patch delta 28 icmZ3-ypMT<7$dVXgTiD{#+f_;44Di$K$y=^&Hw;oUj{`0 delta 11 ScmdnTypDN;7~^Cq#u)$?76X6)