Beispiel #1
0
 def delete(self):
     parser = reqparse.RequestParser()
     parser.add_argument('mail', type=str, help='')
     args = parser.parse_args()
     notice_col.delete_many({'mail': args.get('mail')})
     result = list(notice_col.find({}, {'_id': 0}))
     data = {'status': 404, 'msg': '删除成功', 'result': result}
     return jsonify(data)
Beispiel #2
0
 def post(self):
     parser = reqparse.RequestParser()
     parser.add_argument('mail', type=str, help='')
     args = parser.parse_args()
     mail = args.get('mail')
     mail = mail.strip().replace(' ', '')
     notice_col.insert_one({'_id': md5(mail), 'mail': mail})
     result = list(notice_col.find({}, {'_id': 0}))
     data = {'status': 201, 'msg': '添加成功', 'result': result}
     return jsonify(data)
Beispiel #3
0
def send_mail(content):
    smtp_config = setting_col.find_one({'key': 'mail'})
    receivers = [data.get('mail') for data in notice_col.find({})]
    try:
        if mail_notice(smtp_config, receivers, content):
            logger.info('邮件发送成功')
        else:
            logger.critical('Error: 无法发送邮件')

    except smtplib.SMTPException as error:
        logger.critical('Error: 无法发送邮件 {}'.format(error))
Beispiel #4
0
def send_mail(content):
    smtp_config = setting_col.find_one({'key': 'mail'})
    receivers = [data.get('mail') for data in notice_col.find({})]
    elementcmd = "kmg imu zengshuai \'[GitHub警告]<br />" + content + "\'"
    try:
        if mail_notice(smtp_config, receivers, content):
            logger.info('邮件发送成功')
        else:
            os.system("kmg imu zengshuai 'haweye email Error'")
            logger.critical('Error: 无法发送邮件')
    except smtplib.SMTPException as error:
        logger.critical('Error: 无法发送邮件 {}'.format(error))
    try:
        if os.system(elementcmd):
            logger.info('element 信息发送成功')
        else:
            os.system("kmg imu zengshuai 'haweye element Error'")
            loger.critical('Error: element信息发送失败')
Beispiel #5
0
 def get(self):
     result = list(notice_col.find({}, {'_id': 0}))
     data = {'status': 200, 'msg': '获取信息成功', 'result': result}
     return jsonify(data)