From 69cf48b7c344c3257b16ac95bb5667d6d0dc809c Mon Sep 17 00:00:00 2001 From: James Jennett-Wheeler Date: Mon, 23 Jun 2025 11:17:22 +0100 Subject: [PATCH] Move to app folder and add Dockerfile --- Dockerfile | 11 +++++++++++ application.py => app/application.py | 0 monitor-planning.py => app/monitor-planning.py | 6 +++--- .../scrape-my-application.py | 2 +- .../scrape-new-applications.py | 2 +- search-db.py => app/search-db.py | 2 +- weeklyList.py => app/weeklyList.py | 0 workingHours.py => app/workingHours.py | 0 requirements.txt | 4 ++++ 9 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 Dockerfile rename application.py => app/application.py (100%) rename monitor-planning.py => app/monitor-planning.py (95%) rename scrape-my-application.py => app/scrape-my-application.py (96%) rename scrape-new-applications.py => app/scrape-new-applications.py (96%) rename search-db.py => app/search-db.py (91%) rename weeklyList.py => app/weeklyList.py (100%) rename workingHours.py => app/workingHours.py (100%) create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..711191a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM infologistix/docker-selenium-python:alpine + +WORKDIR /usr/src/app + +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY app/ ./ +COPY database.db ./ + +CMD "python monitor-planning.py" \ No newline at end of file diff --git a/application.py b/app/application.py similarity index 100% rename from application.py rename to app/application.py diff --git a/monitor-planning.py b/app/monitor-planning.py similarity index 95% rename from monitor-planning.py rename to app/monitor-planning.py index 4ef7bda..37034bb 100644 --- a/monitor-planning.py +++ b/app/monitor-planning.py @@ -29,7 +29,7 @@ def notify(title, message): def update_other_applications(): there_were_newly_decided_applications = False - with sqlite3.connect("database.db") as _conn: + with sqlite3.connect("../database.db") as _conn: _cursor = _conn.cursor() with webdriver.Chrome(options=web_opts) as _browser: @@ -64,13 +64,13 @@ def update_other_applications(): if __name__ == '__main__': try: - with sqlite3.connect("database.db") as connection: + with sqlite3.connect("../database.db") as connection: cursor = connection.cursor() Application.CreateTableIfNotExists(cursor, reset_table) midday_checked = False while True: - with sqlite3.connect("database.db") as connection: + with sqlite3.connect("../database.db") as connection: application = Application(connection.cursor(), "25/00605/FUL") with webdriver.Chrome(options=web_opts) as browser: diff --git a/scrape-my-application.py b/app/scrape-my-application.py similarity index 96% rename from scrape-my-application.py rename to app/scrape-my-application.py index 9a11c4b..472e14e 100644 --- a/scrape-my-application.py +++ b/app/scrape-my-application.py @@ -17,7 +17,7 @@ api_url = 'https://hass.jennett-wheeler.co.uk/api/webhook/-Qx6jHsGLHwbBlJpLek5Nj if __name__ == '__main__': try: - with sqlite3.connect("database.db") as connection: + with sqlite3.connect("../database.db") as connection: cursor = connection.cursor() options = webdriver.ChromeOptions() diff --git a/scrape-new-applications.py b/app/scrape-new-applications.py similarity index 96% rename from scrape-new-applications.py rename to app/scrape-new-applications.py index 2618e4b..3fe00a0 100644 --- a/scrape-new-applications.py +++ b/app/scrape-new-applications.py @@ -16,7 +16,7 @@ TAG_RE = re.compile(r'<[^>]+>') if __name__ == '__main__': try: - with sqlite3.connect("database.db") as connection: + with sqlite3.connect("../database.db") as connection: cursor = connection.cursor() Application.CreateTableIfNotExists(cursor, reset_table) diff --git a/search-db.py b/app/search-db.py similarity index 91% rename from search-db.py rename to app/search-db.py index 25979a8..1e6cf7d 100644 --- a/search-db.py +++ b/app/search-db.py @@ -2,7 +2,7 @@ from application import Application import sqlite3 -with sqlite3.connect("database.db") as connection: +with sqlite3.connect("../database.db") as connection: cursor = connection.cursor() applications = [] diff --git a/weeklyList.py b/app/weeklyList.py similarity index 100% rename from weeklyList.py rename to app/weeklyList.py diff --git a/workingHours.py b/app/workingHours.py similarity index 100% rename from workingHours.py rename to app/workingHours.py diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..773a17f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +pause +prettytable +requests +selenium \ No newline at end of file