Commit 03541e24 authored by vaisakh.nair's avatar vaisakh.nair 🎯

template, dockerfile and requirements added.

parent 4731bf6a
# Use an official Python runtime as the base image
FROM python:3.9
# Set the working directory in the container
WORKDIR /app
# Copy the code files into the container
COPY app.py utils config.yml .env ./
# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Run the application
CMD ["python", "app.py"]
import logging
from utils.create_report import DailyReportGenerator
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def generate_daily_report():
# Create an instance of DailyReportGenerator
report_generator = DailyReportGenerator()
# Generate the daily report
report_path = report_generator.create_excel_report()
return report_path
if __name__ == "__main__":
try:
report_path = generate_daily_report()
logger.info(f"Generated Daily Report: {report_path}")
except Exception as e:
logger.error("Error generating daily report:", exc_info=True)
pandas==1.1.5
pymongo==3.11.4
PyYAML==6.0
openpyxl==3.1.2
\ No newline at end of file
...@@ -34,11 +34,11 @@ class DailyReportGenerator: ...@@ -34,11 +34,11 @@ class DailyReportGenerator:
hour = timestamp.hour hour = timestamp.hour
if 6 <= hour < 14: if 6 <= hour < 14:
return 'Shift A' return 'Shift - A'
elif 14 <= hour < 22: elif 14 <= hour < 22:
return 'Shift B' return 'Shift - B'
else: else:
return 'Shift C' return 'Shift - C'
def get_packer_name(self, camera_name): def get_packer_name(self, camera_name):
...@@ -87,11 +87,11 @@ class DailyReportGenerator: ...@@ -87,11 +87,11 @@ class DailyReportGenerator:
# Define the shifts and their respective time ranges # Define the shifts and their respective time ranges
shifts = { shifts = {
'Shift A': (datetime(current_time.year, current_time.month, current_time.day -1 , 6, 0, 0), 'Shift - A': (datetime(current_time.year, current_time.month, current_time.day -1 , 6, 0, 0),
datetime(current_time.year, current_time.month, current_time.day -1, 14, 0, 0)), datetime(current_time.year, current_time.month, current_time.day -1, 14, 0, 0)),
'Shift B': (datetime(current_time.year, current_time.month, current_time.day -1, 14, 0, 0), 'Shift - B': (datetime(current_time.year, current_time.month, current_time.day -1, 14, 0, 0),
datetime(current_time.year, current_time.month, current_time.day -1, 22, 0, 0)), datetime(current_time.year, current_time.month, current_time.day -1, 22, 0, 0)),
'Shift C': (datetime(current_time.year, current_time.month, current_time.day- 1, 22, 0, 0), 'Shift - C': (datetime(current_time.year, current_time.month, current_time.day- 1, 22, 0, 0),
datetime(current_time.year, current_time.month, current_time.day, 6, 0, 0)) datetime(current_time.year, current_time.month, current_time.day, 6, 0, 0))
} }
...@@ -111,8 +111,8 @@ class DailyReportGenerator: ...@@ -111,8 +111,8 @@ class DailyReportGenerator:
# Fill in the data in respective cells # Fill in the data in respective cells
sheet[f'A{row}'] = serial_number sheet[f'A{row}'] = serial_number
sheet[f'B{row}'] = end_time.date() sheet[f'B{row}'] = end_time.date()
sheet[f'C{row}'] = shift sheet[f'C{row}'] = packer_name
sheet[f'D{row}'] = packer_name sheet[f'D{row}'] = shift
sheet[f'E{row}'] = count sheet[f'E{row}'] = count
total_count += count # Accumulate the count total_count += count # Accumulate the count
...@@ -135,13 +135,3 @@ class DailyReportGenerator: ...@@ -135,13 +135,3 @@ class DailyReportGenerator:
# Return the absolute path of the generated report file # Return the absolute path of the generated report file
file_path = os.path.abspath(report_file) file_path = os.path.abspath(report_file)
return file_path return file_path
# Create an instance of DailyReportGenerator
report_generator = DailyReportGenerator()
# Generate the daily report
report_path = report_generator.create_excel_report()
# Print the path of the generated report
print(f"Generated Daily Report: {report_path}")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment