
生日提醒申请
该计划检查一个人是否在一周内有生日,并可选地将提醒发送给小组的其余部分。它涉及验证输入和发送电子邮件的必要功能。该存储库包含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作业的语法自定义。
公共文件夹包含三个文件:
生日提醒申请的徽标可以在此处找到。
麻省理工学院许可证