
生日提醒申請
該計劃檢查一個人是否在一周內有生日,並可選地將提醒發送給小組的其餘部分。它涉及驗證輸入和發送電子郵件的必要功能。該存儲庫包含2個模塊,其中bdayReminder.py在測試時涉及這些功能。在查看應用程序或功能,測試,CRON作業和其他字段之前,請參閱導入庫,軟件包和附加模塊的要求。
需要Python 3.9.12才能正確執行軟件包的模塊,導入的庫和定義的功能。還需要幾個庫,例如dotnet,pytest的名稱。在此處找到一些必需的版本,而二手python版本則附有未提及的版本。還要檢查環境變量和身份驗證,然後再進行進一步進行。為了適當使用該程序,您可能需要運行Python3 ,而不是建議使用python 。 1
1 Python或Python3取決於您在計算機上安裝Python的方式。
為了能夠發送電子郵件,您需要設置環境變量。要在本地執行此操作,請創建一個.env文件,並以有效值添加兩個Env變量,例如: 1
USR=<youremail>
PSW=<yourpassword> or <token>
1如果您要從Gmail發送,然後設置適當的環境變量密碼,則需要創建令牌。有關此基礎驗證部分的更多信息。
為了能夠在環境變量設置Gmail電子郵件之後發送電子郵件,您需要創建令牌。有關如何做的詳細信息,請參見此處。
滿足要求後,將在您的目錄處設置應用程序包並運行終端,您有四個選項1,2,3 :
>>> python bdayreminder.py <data_file_path>
Choose 1 to validate if input data file is correct or 2 to check for upcoming birthdays and send respective emails
>>> 1
ERROR: Invalid email for Laura Dreyfuss at row 6
ERROR: Empty name field is for email [email protected] at row 7
ERROR: Invalid date for Anna Higgins at row 11. Date given is 02-30
ERROR: Date is in the future for Tom Brady at row 12. Date given is 2075-10-22
ERROR: Invalid email for Ching Yeung Michael Tam at row 19
'''
'''
>>> python bdayreminder.py <data_file_path>
Choose 1 to validate if input data file is correct or 2 to check for upcoming birthdays and send respective emails
>>> 2
Kai Yuen Leung will have birthday in a week.
Patrick Kienzle will have birthday in a week.
Emails sent successfully.
>>> python bdayreminder.py <data_file_path> 3
Choose 1 to validate if input data file is correct or 2 to check for upcoming birthdays and send respective emails
>>> 3
Please choose either 1 or 2
>>> 1
ERROR: Invalid email for Laura Dreyfuss at row 6
ERROR: Empty name field is for email [email protected] at row 7
ERROR: Invalid date for Anna Higgins at row 11. Date given is 02-30
ERROR: Date is in the future for Tom Brady at row 12. Date given is 2075-10-22
ERROR: Invalid email for Ching Yeung Michael Tam at row 19
>>> python bdayreminder.py <data_file_path> 1
ERROR: Invalid email for Laura Dreyfuss at row 6
ERROR: Empty name field is for email [email protected] at row 7
ERROR: Invalid date for Anna Higgins at row 11. Date given is 02-30
ERROR: Date is in the future for Tom Brady at row 12. Date given is 2075-10-22
ERROR: Invalid email for Ching Yeung Michael Tam at row 19
>>> python bdayreminder.py <data_file_path> 2
Kai Yuen Leung will have birthday in a week.
Patrick Kienzle will have birthday in a week.
Emails sent successfully.
1 <data_file_path>應該看起來像這樣-DataSet/data_20.csv,但在您的目錄中。對我的完整道路是/Users/aurimasnausedas/documents/python/birthdayReminderapp/datasets/data_20.csv
2從控制台運行時,主模塊需要兩個參數。
3用於示例的數據是2022年6月23日的Data_20.csv。
在模塊中找到的功能的概述-BdayReminder.py :
可以在模塊-BdayReminder.py中找到對功能的深入解釋。
有三個可能使用的數據集。這些是20個收件人中的data_20,50個收件人中的數據_50和80個收件人中的數據_80。
在模塊中找到的功能的概述-Tests.py:
通過導航到提取的程序/應用程序文件夾-ThirmentReminderApp-保存tests.py之前的一個文件夾,可以運行以下測試命令:
>>> pyflakes .
>>> pyflakes Tests/tests.py
>>> python -m pytest Tests/tests.py
可能出現一些錯誤,例如:
>>> python bdayreminder.py Datasets/data_20.json 1
Traceback (most recent call last):
File "/Users/aurimasnausedas/Documents/Python/BirthdayReminderApp/bdayreminder.py", line 237, in <module>
run(arg_path, cron_input)
File "/Users/aurimasnausedas/Documents/Python/BirthdayReminderApp/bdayreminder.py", line 215, in run
raise Exception('ERROR: Wrong data format file')
Exception: ERROR: Wrong data format file
>>> python bdayreminder.py Datasets/data_13.csv 1
Traceback (most recent call last):
File "/Users/aurimasnausedas/Documents/Python/BirthdayReminderApp/bdayreminder.py", line 237, in <module>
run(arg_path, cron_input)
File "/Users/aurimasnausedas/Documents/Python/BirthdayReminderApp/bdayreminder.py", line 199, in run
raise Exception('ERROR: File doesn't exist')
Exception: ERROR: File doesn't exist
>>> python bdayreminder.py Datasets/data_20.csv versada
Argument passed not an integer
還有更多這些是最常見的。
在Mac終端運行中建立Cron Job:
>>> crontab -e
進入終端時Cronjob的語法可能看起來像: 1,2,3
>>> 0 6 * * * cd <directory_to_app> && <directory_to_python> bdayreminder.py <data_file_path> 2
[Optional] >>> 0 6 * * * cd <directory_to_app> && <directory_to_python> bdayreminder.py <data_file_path> 2 >> Public/birthdays.txt
1 <Directory_to_app> - 應該是firtherminderapp文件夾的目錄,例如/users/aurimasnausedas/documents/python/python/yaventreminderapp
2 <Directory_to_python>應該是您在計算機上安裝Python的位置,例如/users/aurimasnausedas/opt/miniconda3/envs/symmetric/symmetric/bin/python
3 <data_file_path>應該是應用程序目錄中的數據集,例如/users/aurimasnausedas/documents/python/python/pythrominderapp,將其設置為數據集/data_20.csv
可以在此處檢查Cron作業的語法自定義。
公共文件夾包含三個文件:
生日提醒申請的徽標可以在此處找到。
麻省理工學院許可證