Beispiel #1
0
async def count_hash(request, u_id):
    async with request.app['db_pool'].acquire() as conn:
        data = await db.get_data_by_id(conn, u_id)
    try:
        async with ClientSession() as session:
            md5_hash = await fetch(session, data['url'])
            md5_hash = str(hashlib.md5(md5_hash).hexdigest())

        async with request.app['db_pool'].acquire() as conn:
            await db.insert_hash(conn, u_id, 'done', md5_hash)
        if data['email']:
            sender.send_mail(data['email'], data['url'], md5_hash)
    except:
        async with request.app['db_pool'].acquire() as conn:
            await db.insert_hash(conn, u_id)
Beispiel #2
0
    def parseYuanZun(self):
        html = self.getHTMLText()
        try:
            # 解析html
            soup = BeautifulSoup(html, "html.parser")

            # 小说名称
            novelName = soup.find('div', attrs={"class": "book-info"}).find('em').text

            # 章节ID
            chapterID = re.findall(r'(\w*[0-9]+)\w*', soup.find('span', attrs={"id": "J-catalogCount"}).text)

            # 小说注册,db中键值都必须是字符串
            if self.db.get(novelName) is None:
                self.db[novelName] = str(self.record)

            # 章节详细信息
            chapterUpdate = soup.find('li', attrs={"class": "update"})

            # 更新信息
            chapterTitle = chapterUpdate.find(
                'a', attrs={
                    "class": "blue"
                }).get("title")

            # 更新时间
            lastUpdateTime = chapterUpdate.find(
                'em', attrs={
                    "class": "time"
                }).text

            # 更新到全局变量
            self.li_dataInfo.append(chapterID)
            self.li_dataInfo.append(chapterTitle)
            self.li_dataInfo.append(lastUpdateTime)
            self.li_dataInfo.append(novelName)

            # 保存+发送邮件
            self.send_mail()

        except Exception as e:
            # 打印异常的类型实例和信息
            t, v, tb = sys.exc_info()
            s = "工具发生错误\n类型:%s\n当前监视器实例:%s\n异常为:%s\n详细信息:%s" % (
                t, json.dumps(self), e, traceback.print_exc())
            logger.error(s)
            sender.send_mail('*****@*****.**', '小说监听器异常通知', s)
Beispiel #3
0
 def do_data(self, data):
     data = data.decode()
     self.detect_host(self.recipient.login)
     if self.our_client():
         '''Переименовать'''
         self.send_in_my_mailbox(data)
     else:
         print('Find Recipient SMTP')
         mail_exchanger = resolver.find_RR_MX(self.recipient.host)
         return sender.send_mail(mail_exchanger, data, self.recipient)
Beispiel #4
0
    def send_mail(self):

        # 获取章节数
        paper_num = int(self.li_dataInfo[0][0])

        # 读取记录章节数
        old_num = int(self.db[self.li_dataInfo[3]])

        # old_num = 0
        # 未更新
        if paper_num == old_num:
            pass
            logger.debug("Not updated")

        # 记录过大
        elif paper_num < old_num:

            # 拼接上小说
            s = "您的记录章节数:%s 大于最新章节数: %s! 特此通知!\n\n系统自动从最新章节:%s开始为您推送。\n" % (
                old_num, paper_num, paper_num) + self.getNovel()

            # 发送邮件
            sender.send_mail(self.toMail, self.li_dataInfo[3], s)

            # 章节异常这则重置阅读章节
            self.db[self.li_dataInfo[3]] = str(paper_num)


        # 小说更新
        elif paper_num > old_num:
            total = paper_num - old_num

            # 拼接上小说
            s = "更新到: %s 章\n%s\n\n最新更新时间: %s\n\n您共有%s章未读\n" % (
                self.li_dataInfo[0], self.li_dataInfo[1], self.li_dataInfo[2], total) + self.getNovel()

            # 发送邮件
            sender.send_mail(self.toMail, self.li_dataInfo[3], s)

            # 刷新库
            self.db[self.li_dataInfo[3]] = str(paper_num)
Beispiel #5
0
logger.log("Watcher started")

interval = CONN_CHECK_INTERVAL
connected = is_connected()

last_known_ssid = ""

if interval < 30:
    interval = 30

if connected:
    # SEND EMAIL ON BOOT
    ip = str(get_ip())
    ssid = str(get_ssid())
    last_known_ssid = ssid
    sender.send_mail("RaspIP", ssid + ": " + ip)
    logger.log("Email sent on boot with following data: " + ssid + ", " + ip)

while True:
    connected = is_connected()
    print("Connected: " + str(connected))
    if not connected:
        logger.log("Watcher triggering reconnect")
        os.system("python3 reconnect.py &")
    elif str(get_ssid()) != last_known_ssid:
        # Network has changed
        logger.log("Network has changed from " + last_known_ssid + " > " +
                   str(get_ssid()))
        sender.send_mail("RaspIP", str(get_ssid()) + ": " + str(get_ip()))
        last_known_ssid = str(get_ssid())
    sleep(interval)
Beispiel #6
0
#!/usr/bin/env python
# coding=utf-8
from urllib.request import Request, urlopen
from time import sleep
import sender

url = 'https://api.nanopool.org/v1/eth/reportedhashrate/0x0'

req = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
webpage = urlopen(req).read()
res = webpage.decode()
print(res.split(':')[2][:-2])
while True:

    req = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
    webpage = urlopen(req).read()
    res = webpage.decode()
    hash_r = res.split(':')[2][:-2]
    if float(hash_r) < 430:
        print('Hash rate < 430 : ', hash_r)
        message = 'Reported hash rate: ' + str(hash_r)
        sender.send_mail(text=message)

    sleep(300)
Beispiel #7
0
from time import sleep
from utils import get_ssid, get_ip, is_connected
import os
import logger
import sender


def reconnect():
    connectCmd = "wpa_cli -i wlan0 reconfigure &"
    logger.log("Reconnecting...")
    os.system(connectCmd)


if is_connected():
    ip = str(get_ip())
    ssid = str(get_ssid())
    sender.send_mail("RaspIP", ssid + ": " + ip)
else:
    reconnect()
Beispiel #8
0
from merger import merge
from sender import send_mail
from receiver import receive_mail

import io, os, imapclient, pyzmail, smtplib, ssl, PyPDF2
from os.path import basename
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
import config
from config import get_conf

conf_data = get_conf(config)
email = conf_data['email']
password = conf_data['password']
server = conf_data['server']
port = conf_data['port']

subject = 'RE:OCR'
text = 'Check your file at attachment\n\nCreated by automatic python merger\n\nPython Power by Dimkin'
basedir = 'c:\\!git\\PDFmerger\\process\\'
files = ['C:\\!git\\PDFmerger\\process\\combined.pdf']
to = [receive_mail(email, password, basedir)]

merge(basedir)
send_mail(email, to, subject, text, basedir, files, password, server, port)