diff --git a/.gitignore b/.gitignore index 44c3361..187b77a 100644 --- a/.gitignore +++ b/.gitignore @@ -141,3 +141,4 @@ cython_debug/ .aws_credentials config.ini ppt/ +users/mail.ini diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ca77b5b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM amancevice/pandas + +ENV TZ=Asia/Taipei +RUN apt-get update -y +RUN apt-get install xfonts-utils -y +RUN wget https://www.twfont.com/chinese/font/TaipeiSans.ttf +RUN cp *.ttf /usr/share/fonts/truetype && cd /usr/share/fonts/truetype +RUN mkfontscale && mkfontdir && fc-cache + +WORKDIR /source_code +RUN mkdir pics libs ppt +COPY requirements.txt config.ini main.py /source_code +COPY ./libs /source_code/libs/ +RUN pip install -r requirements.txt +CMD ["python", "main.py"] diff --git a/libs/chart.py b/libs/chart.py index a0a51dd..8b36390 100644 --- a/libs/chart.py +++ b/libs/chart.py @@ -1,3 +1,4 @@ +# -*- coding:utf-8 -*- import plotly.express as px import pandas as pd @@ -10,16 +11,11 @@ def __init__(self): def load_data(self, tasks): self.dataframe = pd.DataFrame(tasks) - # self.dataframe = pd.DataFrame([ - # dict(Task = "工作1", Start = '2023-09-13', End = '2023-10-25', Assigned = "Rita", Difficulty = 70), - # dict(Task = "工作5", Start = '2024-01-01', End = '2024-09-28', Assigned = "奴隸 C", Difficulty = 80) - # ]) def create_chart(self): self.fig = px.timeline(self.dataframe, x_start="Start", x_end="End", y="Task", color="Assigned") # Tasks from top to bottom self.fig.update_yaxes(autorange = "reversed") - # self.fig.show() def save_chart(self, filename): self.fig.write_image(filename) diff --git a/libs/kanban.py b/libs/kanban.py index e22d17c..6d0acf0 100644 --- a/libs/kanban.py +++ b/libs/kanban.py @@ -1,3 +1,4 @@ +import os import asana import configparser from asana.rest import ApiException @@ -11,7 +12,8 @@ def __init__(self) -> None: configuration = asana.Configuration() config = configparser.ConfigParser() config.read('config.ini') - configuration.access_token = config['Asana']['asana_token'] + #configuration.access_token = config['Asana']['asana_token'] + configuration.access_token = os.environ['ASANA_TOKEN'] self.default = config['Default'] # create an instance of the API class self.client = asana.ApiClient(configuration) @@ -144,4 +146,4 @@ def get_all(self): self.get_workspaces() self.get_teams_in_workspace() self.get_projects_in_team() - self.get_tasks_in_project() \ No newline at end of file + self.get_tasks_in_project() diff --git a/libs/sendmail.py b/libs/sendmail.py index 45705b5..afce58b 100644 --- a/libs/sendmail.py +++ b/libs/sendmail.py @@ -1,3 +1,4 @@ +import os import re import smtplib from configparser import ConfigParser @@ -7,19 +8,22 @@ class MailSender: - def __init__(self, title=None, content=None, revicer_addr=None): + def __init__(self, title=None, content=None, receiver_addr=None): # 從指定路徑讀取信箱登入資訊 cfg = ConfigParser() cfg.read('users/mail.ini') # 設定信件內文格式 self.content = MIMEMultipart() - self.host = cfg['DEFAULT']['Host'] - self.sender = cfg['DEFAULT']['SenderAddress'] - self.sender_secret = cfg['DEFAULT']['SenderSecret'] - if not revicer_addr: - receiver_str = cfg['DEFAULT']['ReceiverAddress'] + #self.host = cfg['DEFAULT']['Host'] + #self.sender = cfg['DEFAULT']['SenderAddress'] + #self.sender_secret = cfg['DEFAULT']['SenderSecret'] + self.host = os.environ['MAIL_SERVER'] + self.sender = os.environ['MAIL_SENDER'] + self.sender_secret = os.environ['MAIL_SENDER_SECRET'] + if not receiver_addr: + receiver_str = os.environ['MAIL_RECEIVER'] else: - receiver_str = reciver_addr + receiver_str = receiver_addr self.receiver = re.findall(r"[\w\+]+@\w+[^,\s]*", receiver_str) # Setup receiver(s) self.content['from'] = self.sender diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..735f2e4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,17 @@ +asana==4.0.11 +certifi==2023.7.22 +kaleido==0.2.1 +lxml==4.9.3 +numpy==1.25.2 +packaging==23.1 +pandas==2.1.0 +Pillow==9.5.0 +plotly==5.17.0 +python-dateutil==2.8.2 +python-pptx==0.6.22 +pytz==2023.3.post1 +six==1.16.0 +tenacity==8.2.3 +tzdata==2023.3 +urllib3==2.0.4 +XlsxWriter==3.1.3