Compare commits
4 Commits
dev
...
57d6b1a607
| Author | SHA1 | Date | |
|---|---|---|---|
| 57d6b1a607 | |||
| 8b5fa414d7 | |||
| 0412ca1321 | |||
| f5abf68bb6 |
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
FROM python:3.9-slim-buster
|
||||
|
||||
# Install cron
|
||||
RUN apt-get update && apt-get -y install cron
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
# Make entrypoint script executable
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
|
||||
# Set the entrypoint
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
1
crontab
Normal file
1
crontab
Normal file
@@ -0,0 +1 @@
|
||||
0 8,13,18 * * * python /app/main.py >> /var/log/cron.log 2>&1
|
||||
7
docker-compose.yml
Normal file
7
docker-compose.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
gsheet-bot:
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./credentials.json:/app/credentials.json:ro
|
||||
11
entrypoint.sh
Normal file
11
entrypoint.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Load the cron job
|
||||
crontab /app/crontab
|
||||
|
||||
# Create the log file and set permissions
|
||||
touch /var/log/cron.log
|
||||
chmod 0666 /var/log/cron.log
|
||||
|
||||
# Start cron in the foreground
|
||||
cron -f
|
||||
2
main.py
2
main.py
@@ -7,7 +7,7 @@ from processing import process_all_rows
|
||||
def main():
|
||||
gsheet_api = GSheetAPI()
|
||||
|
||||
sheet_name = select_sheet(gsheet_api)
|
||||
sheet_name = select_sheet()
|
||||
if not sheet_name:
|
||||
return
|
||||
|
||||
|
||||
19
workflow.py
19
workflow.py
@@ -1,20 +1,13 @@
|
||||
import datetime
|
||||
from config import DOC_NAME, RESULT_DOC
|
||||
|
||||
def select_sheet(gsheet_api):
|
||||
"""Lists available sheets and prompts the user to select one."""
|
||||
print("📄 Pobieram listę arkuszy...")
|
||||
try:
|
||||
sheets = gsheet_api.list_sheets(DOC_NAME)
|
||||
for i, name in enumerate(sheets):
|
||||
print(f"{i+1}. {name}")
|
||||
|
||||
sheet_name = input("\nWybierz arkusz do przetworzenia: ")
|
||||
def select_sheet():
|
||||
"""Generates the sheet name based on the current month and year (MM.YYYY)."""
|
||||
now = datetime.datetime.now()
|
||||
sheet_name = now.strftime("%m.%Y")
|
||||
print(f"📄 Automatycznie wybrano arkusz: {sheet_name}")
|
||||
return sheet_name
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Błąd podczas pobierania listy arkuszy: {e}")
|
||||
return None
|
||||
|
||||
def get_sheet_data(gsheet_api, sheet_name):
|
||||
"""Fetches all data from a given sheet."""
|
||||
print(f"📋 Pobieram dane z arkusza: {sheet_name}")
|
||||
|
||||
Reference in New Issue
Block a user