Skip to content

Commit

Permalink
使用系統變數傳遞機敏資訊對應的修改
Browse files Browse the repository at this point in the history
  • Loading branch information
rita0124 committed Sep 27, 2023
1 parent 1de0040 commit a152ab3
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -141,3 +141,4 @@ cython_debug/
.aws_credentials
config.ini
ppt/
users/mail.ini
15 changes: 15 additions & 0 deletions 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"]
6 changes: 1 addition & 5 deletions libs/chart.py
@@ -1,3 +1,4 @@
# -*- coding:utf-8 -*-
import plotly.express as px
import pandas as pd

Expand All @@ -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)
6 changes: 4 additions & 2 deletions libs/kanban.py
@@ -1,3 +1,4 @@
import os
import asana
import configparser
from asana.rest import ApiException
Expand All @@ -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)
Expand Down Expand Up @@ -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()
self.get_tasks_in_project()
18 changes: 11 additions & 7 deletions libs/sendmail.py
@@ -1,3 +1,4 @@
import os
import re
import smtplib
from configparser import ConfigParser
Expand All @@ -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
Expand Down
17 changes: 17 additions & 0 deletions 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

0 comments on commit a152ab3

Please sign in to comment.