Esempio n. 1
0
 def run(self):
     stockNow = ts.get_today_all()
     stockNow['code'] = stockNow['code'].astype(int)
     for row in self.__watchList[:]:
         if row[4] == False:
             #目标达成后
             continue
         printFlag = False
         name = stockNow[stockNow.code == row[0]]['name'].values[0]
         if row[1] == 'pe':
             if row[2] == '低':
                 if self.__stock.peNow(row[0]) <= row[3]:
                     printFlag = True
                     row[4] = False
             elif row[2] == '高':
                 if self.__stock.peNow(row[0]) >= row[3]:
                     printFlag = True
                     row[4] = False
         elif row[1] == 'price':
             price = stockNow[stockNow.code == row[0]]['trade'].values[0]
             if row[2] == '低':
                 if price <= row[3]:
                     printFlag = True
                     row[4] = False
             elif row[2] == '高':
                 if price >= row[3]:
                     printFlag = True
                     row[4] = False
         if printFlag:
             noticeText = "股票:%06d %s的%5s%s于%.2f" % (row[0], name, row[1],
                                                     row[2], row[3])
             print(noticeText)
             sm.sendMail(noticeText, noticeText)
     pass
Esempio n. 2
0
def dealVulIds(vulIds):
    try:
        keyWord = matching_keywords()
        all_key = getkeyWord()
        for vulId in vulIds:
            keyIdList = []
            url = 'http://butian.360.cn/vul/info/qid/%s' % vulId
            page = httpGet(url)
            flag = re.search(keyWord, page)
            if flag:
                for i in all_key.keys():
                    flag1 = re.search(all_key[i], page)
                    if flag1:
                        keyIdList.append(vulId)
            for vid in keyIdList:
                vulName = re.findall(
                    r"<title>(.+)- 补天 - - 全球最大的漏洞响应平台,帮助企业建立SRC</title>",
                    page)[0]
                vulTime = re.findall(
                    r'<dt>(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})</dt>', page)[0]
                xid = butian_insert(vulName, vulId, vulTime)
                butian_keyword_insert(xid, vid, all_key[vid])
                toMailAddr = getFollowMail(vid)
                sendMail(toMailAddr[0], all_key[vid],
                         'http://butian.360.cn/vul/info/qid/%s' % s)
    except Exception as e:
        print(e)
Esempio n. 3
0
def getGirlData(url):
    driver.get(url)
    time.sleep(5)
    title = driver.find_element_by_tag_name("h1").text
    Content = driver.find_element_by_class_name("post_text")
    print(title)
    pTags = Content.find_elements_by_tag_name("p")
    content = '''
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>'''
    for tag in pTags:
        if tag.text != "":
            content += "<p>" + tag.text + "</p>"
            print(tag.text)
        if tag.get_attribute("class") == "f_center":
            try:
                aImg = tag.find_element_by_tag_name("img")
            except:
                continue
            imgSrc = aImg.get_attribute("src")
            content += '''<img src="''' + imgSrc + '''" alt="">'''
            print(imgSrc)
    content += '''</body></html>'''
    sendMail.sendMail(title, content)
Esempio n. 4
0
 def PushSendMailBtn(self):
     global currentDetailData
     if len(self.myMailAddr.text()) > 0 and len(self.password.text()) > 0 and len(self.targetMailAddr.text()) > 0:
         if currentDetailData != None:
             sendMail.sendMail(currentDetailData, self.myMailAddr.text(), self.password.text(), self.targetMailAddr.text())
             self.dialog.destroy()
     pass
Esempio n. 5
0
def getExternalIP():
    #Read IP in IP-log.json
    with open('%s/IP-current.json' % currentDirectory) as jsonFileIPsRead:
        fileIP = json.load(jsonFileIPsRead)
    #Used to compare external_IP in file and the one retreived from the API.
    oldIP = fileIP["external_IP"]
    # Get the IP from the API endpoint.
    response = requests.get("https://api.myip.com")
    datas = response.json()
    external_IP = datas["ip"]
    hostname = socket.gethostname()
    ip_private = socket.gethostbyname(hostname)

    date = datetime.datetime.now()
    dateFormatted = date.strftime("%d-%m-%Y %X")

    #Create json object to be used in IP-log.json
    jsonExternalIP = {}
    jsonExternalIP = {
        'external_IP' : external_IP,
        'date' : dateFormatted
        }
    #Write IP in IP-current.json
    with open('%s/IP-current.json' % currentDirectory,'w') as jsonFileIPs:
        json.dump(jsonExternalIP, jsonFileIPs, indent=4)
    #function to compare IPs and define the $body
    if oldIP != external_IP:
        subject = "[Notification] - External IP"
        body = "New External IP: %s \nHostname: %s \nHost IP: %s \nOld External IP: %s" %(external_IP, hostname, ip_private, oldIP)
        sendMail.sendMail(subject, body, currentDirectory)
        return external_IP, hostname, ip_private, dateFormatted, oldIP
Esempio n. 6
0
def sendMail(mailset, to_mail_addr):
    smtp_server = mailset[0]
    smtp_post = mailset[1]
    user_mail = mailset[2]
    user_passwd = mailset[3]
    sendMail(smtp_server, smtp_post, user_mail, user_passwd, to_mail_addr,
             "你有新的漏洞信息,请注意查看")
Esempio n. 7
0
def main():
    sender = ""
    reciever = ""
    message = "listing.json"
    toScrape = ""
    scrapeSite.findWholeListing(toScrape)
    sendMail.sendMail(sender, reciever, message)
    print("Done!")
Esempio n. 8
0
def finish(result, pid):
    print 'in finish: %s' %(str(result.value))
    try:
        sendMail(email_address, 'huahai', 'SERVER DEAD!!!', '服务器没有回应心跳包')
        os.kill(int(pid), signal.SIGKILL)
    except Exception as e:
        print e
        reactor.stop()
Esempio n. 9
0
def preview():
    if request.method == 'POST':
        receiver = request.form["receiver"]
        title = request.form["title"]
        message = request.form[
            "message"] + "\n \n You should also try this game \n http://ccproiect2.azurewebsites.net/options"
        sendMail(receiver, title, message)
    return "Mail sent"
Esempio n. 10
0
    def checkToday(self):  #
        self.sendedList = recMail.checkMailList(7)  # 30 days
        url = 'http://movie.mtime.com/recent/#hottest'
        html = requests.get(url)
        selector = etree.HTML(html.text)
        content_field = selector.xpath('//div[@class="movietopmod"]')
        num = 20
        for each in content_field:
            num -= 1
            if num < 0:
                break
            syrq = each.xpath('div[@class="txtbox"]/p[@class="showday"]//text()')[0]
            dq = each.xpath('//p[contains(text(),"国家地区:")]/a/text()')[0]
            #dq = each.xpath('div[@class="txtbox"]/p[3]/a/text()')[0]
            #print(each.xpath('div[@class="txtbox"]/h3//text()')[0])
            #print(dq)
            sydq = syrq.split(' ')[1].split('(')[1].split(')')[0]
            syrq = syrq.split(' ')[1].split('(')[0]
            if (sydq) != '中国':
                continue
            if syrq[-1] == '年' or syrq[-1] == '月':
                continue
            '''
            print(syrq)
            print(dq)
            print(each.xpath('div[@class="txtbox"]/h3//text()')[0])
            '''

            t = (time.strptime(syrq, '%Y年%m月%d日'))
            day_time = datetime.date.today()
            oneday = datetime.timedelta(days=1)
            while day_time.weekday() != calendar.SATURDAY:
                day_time += oneday
            withinAWeek = day_time.timetuple()

            if t <= withinAWeek and dq != '中国':
                jqUrl = each.xpath('div[@class="txtbox"]/h3//@href')[0]
                jqHtml = requests.get(jqUrl + '/plots.html')
                # print(jqUrl + '/plots.html')
                jqSelector = etree.HTML(jqHtml.text)
                jqDivs = jqSelector.xpath('//div[@id="paragraphRegion"]/div/div')

                jqText = ''
                for txt in jqDivs[1:]:
                    texts = (txt.xpath('div[2]/p'))
                    for textP in texts:
                        txt = textP.xpath('string(.)')
                        jqText += txt + '\n'
                        #print(txt)
                dym = each.xpath('div[@class="txtbox"]/h3//text()')[0]
                print(dym)
                # print(jqUrl)
                # print(jqText)
                # print(syrq)
                sentTxt = '%s\n上映时间%s\n%s\n' %(jqUrl, syrq, jqText)
                print(sentTxt)
                if ('电影:'+dym) not in self.sendedList:
                    sendMail.sendMail('电影:'+dym, sentTxt)
	def emailQuote(self):
		msg = '''
		Ticker: %s
		price: %s
		numShares: %s
		
		BALANCE: %s
		''' % (self.ticker, data.get_last_trade_price(self.ticker), self.numShares, variables.balance)
		sendMail.sendMail(msg)		
Esempio n. 12
0
def getOnePageData(title, url):
    r = requests.get(url, headers=headersHtml)
    # print(r.text)
    data = re.findall(
        "(<div class=\"article_content\".*)<div class=\"article_other\"",
        r.text, re.S)[0]
    print(data)
    data = data.replace("data-original", "src")
    sendMail.sendMail(title, data)
Esempio n. 13
0
    def emailQuote(self):
        msg = '''
		Ticker: %s
		price: %s
		numShares: %s
		
		BALANCE: %s
		''' % (self.ticker, data.get_last_trade_price(
            self.ticker), self.numShares, variables.balance)
        sendMail.sendMail(msg)
Esempio n. 14
0
  def sendResult(self):
    file_content = self.openUrl('%s/portal_tests/TestTool_getResults' % self.portal_url)
    passes_re = re.compile('<th[^>]*>Tests passed</th>\n\s*<td[^>]*>([^<]*)')
    failures_re = re.compile('<th[^>]*>Tests failed</th>\n\s*<td[^>]*>([^<]*)')
    image_re = re.compile('<img[^>]*?>')
    error_title_re = re.compile('(?:error.gif.*?>|title status_failed"><td[^>]*>)([^>]*?)</td></tr>', re.S)
    result_re = re.compile('<div style="padding-top: 10px;">\s*<p>\s*'
                          '<img.*?</div>\s.*?</div>\s*', re.S)
    error_result_re = re.compile('.*(?:error.gif|title status_failed).*', re.S)
    passes = passes_re.search(file_content).group(1)
    failures = failures_re.search(file_content).group(1)
    error_titles = [re.compile('\s+').sub(' ', x).strip()
                    for x in error_title_re.findall(file_content)]
    revision = self.getSvnRevision()
  
    subject = "%s r%s: Functional Tests, %s Passes, %s Failures" \
                % (self.email_subject, revision, passes, failures)
    summary = """
Test Summary

Tests passed: %4s
Tests failed: %4s

Following tests failed:

%s""" % (passes, failures, "\n".join(error_titles))
    detail = ''
    for e in result_re.findall(file_content):
      if error_result_re.match(e):
        detail += e
    detail = image_re.sub('', detail)
    if detail:
      detail = '''<html>
<head>
 <style type="text/css">tr.status_failed { background-color:red };</style>
</head>
<body>%s</body>
</html>''' % detail
    status = (not failures)
    if self.send_mail:
      sendMail(subject=subject,
               body=summary,
               status=status,
               attachments=[detail],
               from_mail='*****@*****.**',
               to_mail=[self.email_to_address],
               smtp_host=self.smtp_host)
    if self.stdout:
      print '-' * 79
      print subject
      print '-' * 79
      print summary
      print '-' * 79
      print detail
    return int(failures)
Esempio n. 15
0
  def sendResult(self):
    file_content = self.openUrl('%s/portal_tests/TestTool_getResults' % self.portal_url)
    passes_re = re.compile('<th[^>]*>Tests passed</th>\n\s*<td[^>]*>([^<]*)')
    failures_re = re.compile('<th[^>]*>Tests failed</th>\n\s*<td[^>]*>([^<]*)')
    image_re = re.compile('<img[^>]*?>')
    error_title_re = re.compile('(?:error.gif.*?>|title status_failed"><td[^>]*>)([^>]*?)</td></tr>', re.S)
    result_re = re.compile('<div style="padding-top: 10px;">\s*<p>\s*'
                          '<img.*?</div>\s.*?</div>\s*', re.S)
    error_result_re = re.compile('.*(?:error.gif|title status_failed).*', re.S)
    passes = passes_re.search(file_content).group(1)
    failures = failures_re.search(file_content).group(1)
    error_titles = [re.compile('\s+').sub(' ', x).strip()
                    for x in error_title_re.findall(file_content)]
    revision = self.getSvnRevision()

    subject = "%s r%s: Functional Tests, %s Passes, %s Failures" \
                % (self.email_subject, revision, passes, failures)
    summary = """
Test Summary

Tests passed: %4s
Tests failed: %4s

Following tests failed:

%s""" % (passes, failures, "\n".join(error_titles))
    detail = ''
    for e in result_re.findall(file_content):
      if error_result_re.match(e):
        detail += e
    detail = image_re.sub('', detail)
    if detail:
      detail = '''<html>
<head>
 <style type="text/css">tr.status_failed { background-color:red };</style>
</head>
<body>%s</body>
</html>''' % detail
    status = (not failures)
    if self.send_mail:
      sendMail(subject=subject,
               body=summary,
               status=status,
               attachments=[detail],
               from_mail='*****@*****.**',
               to_mail=[self.email_to_address],
               smtp_host=self.smtp_host)
    if self.stdout:
      print '-' * 79
      print subject
      print '-' * 79
      print summary
      print '-' * 79
      print detail
    return int(failures)
def adjustData(data):
    (conf, tableNameList) = readLocalConfig()
    tempDataForDatabase = data[data['存储方式(源)'] == 'database']
    indexKeyForDatabase = list(set(list(tempDataForDatabase['标记值'])))
    for i in range(0, len(indexKeyForDatabase)):
        tempData = tempDataForDatabase[tempDataForDatabase['标记值'] ==
                                       indexKeyForDatabase[i]]
        tableName = list(tempData['目标表'])[0]
        if tableName not in tableNameList:
            continue
        config = list(tempData['配置'])[0]
        (mapValue, databaseType) = creatMapValue(config)
        cnnKey = creatCnnKey(mapValue)
        (TargetCursorDes, TargetCnnDes) = createSqlEngin.TargetCnnDict[cnnKey]
        timingMarkDesList = list(tempData['定时标记'])
        filedTarget = list(tempData['目标字段名称'])
        fileTimeDic = dict(zip(filedTarget, timingMarkDesList))
        temp1 = ''
        temp2 = ''
        tag1 = None
        tag2 = None
        tempSql = 'select * from ' + tableName
        for key in fileTimeDic.keys():
            if fileTimeDic[key] == 1:
                temp1 = ' order by ' + key + ' desc'
                tag1 = key
            elif fileTimeDic[key] == 2:
                temp2 = ',' + key + ' desc'
                tag2 = key
        tempSql = tempSql + temp1 + temp2 + ' limit 20'
        TargetCursorDes.execute(tempSql)
        data = TargetCursorDes.fetchmany(100)
        if data == []:
            continue
        data = pd.DataFrame(data)
        cols = TargetCursorDes.description
        colnum = []
        for col in cols:
            colnum.append(col[0])
        data.columns = colnum
        data.sort_values(by=tag1, ascending=False)
        value1 = list(data[tag1])[0]
        value2 = None
        if tag2 != None:
            value2 = list(data[tag2])[0]
        #获得配置文件中有关当前表的信息
        dic = dict(conf.items(tableName))
        value1ForConfig1 = dic[tag1]
        value1ForConfig2 = None
        if tag2 != None:
            value1ForConfig2 = dic[tag2]
        if value1ForConfig1 != value1:
            sendMail.sendMail("校准更新日期出错", tableName)
            writeConfig(tableName, tag1, value1, tag2, value2)
    return
Esempio n. 17
0
 def PushSendMailBtn(self):
     global currentDetailData
     if len(self.myMailAddr.text()) > 0 and len(
             self.password.text()) > 0 and len(
                 self.targetMailAddr.text()) > 0:
         if currentDetailData != None:
             sendMail.sendMail(currentDetailData, self.myMailAddr.text(),
                               self.password.text(),
                               self.targetMailAddr.text())
             self.dialog.destroy()
     pass
Esempio n. 18
0
def get_comp_order_book():
    print("查找comp挂单大于100的")
    futures = ftx.public_get_futures()["result"]
    msg = {}
    name = "comp_alarm"
    ALARM_SIZE = 100
    # msg["COMP-PERP"]["asks"][[187.1, 1.0471], [187.1, 1.0471]]
    comp_pd = [i["name"] for i in futures if "COMP" in i["name"]]
    for comp in comp_pd:
        orderbook = ftx.fetch_order_book(comp, 1)
        for i in orderbook["asks"]:
            price, size = i
            if size >= ALARM_SIZE:
                if comp in msg:
                    msg[comp]["asks"].append(i)
                else:
                    msg[comp] = {"asks": [], "bids": []}
                    msg[comp]["asks"].append(i)
        for i in orderbook["bids"]:
            price, size = i
            if size >= ALARM_SIZE:
                if comp in msg:
                    msg[comp]["bids"].append(i)
                else:
                    msg[comp] = {"asks": [], "bids": []}
                    msg[comp]["bids"].append(i)
    if msg:
        new_msg = {}
        for k, v in msg.items():
            if v["asks"] and v["bids"]:
                new_msg[k] = v
        result = Index("data/result")
        send_txt = ""
        msg = new_msg
        if msg:
            for k, v in msg.items():
                send_txt += k
                send_txt += "\n\n"
                send_txt += json.dumps(v)
                send_txt += "\n\n"

            if name in result:
                before_data = result[name]
                if msg != before_data:
                    sendMail(
                        f"{k} 有挂单超过100了",
                        send_txt,
                        ["*****@*****.**", "*****@*****.**"],
                    )
                    result[name] = msg
            else:
                sendMail("COMP有挂单超过50了", send_txt,
                         ["*****@*****.**", "*****@*****.**"])
                result[name] = msg
Esempio n. 19
0
def main():
    password = ""
    name = "Justin"
    toEmail = ""
    mail = omail.openMailbox(password)
    file = pe.pullMail(mail)
    output = pr.processNumbers(name, file)
    '''outputFile = open("numbers_" + name + ".txt", "w")
	outputFile.write(file + '\n')
	outputFile.write(output)
	outputFile.close()'''
    sm.sendMail(output, file, toEmail)
Esempio n. 20
0
def getImagesData(url):
    driver.get(url)
    time.sleep(3)
    pageNum = driver.find_element_by_class_name("denominator").text
    imgSrcList = []
    labelList = []
    #此循环得到所有图片链接地址
    for i in range(0, int(pageNum) - 1):
        driver.find_element_by_tag_name("body").send_keys(Keys.RIGHT)
        try:
            aPhoto = driver.find_element_by_class_name("photo-a")
            bPhoto = driver.find_element_by_class_name("photo-b")
            imgA = aPhoto.find_element_by_tag_name("img")
            imgB = bPhoto.find_element_by_tag_name("img")
            aSrc = imgA.get_attribute("src")
            bSrc = imgB.get_attribute("src")
            imgSrcList.append(aSrc)
            imgSrcList.append(bSrc)
        except:
            pass
    imgSrcList = list(set(imgSrcList))
    title = driver.find_element_by_tag_name("h1").text
    contentInfo = driver.find_element_by_xpath(
        "/html/body/div[2]/div[2]/div[2]/h2/div[2]/div/p").text
    tag = driver.find_element_by_xpath(
        "/html/body/div[2]/div[2]/div[2]/div[1]")
    labels = tag.find_elements_by_tag_name("a")
    for label in labels:
        labelList.append(label.text)
    content = '''
        <!DOCTYPE html>
        <html lang="en">
        <head>
            <meta charset="UTF-8">
            <title>Title</title>
        </head>
        <body>'''
    print(title, content, labels, imgSrcList)
    for i, label in enumerate(labels):
        if i == 0:
            content += "<p>"
        content += " " + label.text
        if i == len(labels) - 1:
            content += "</p></br>"
    content += "<p>" + contentInfo + "</p>"
    for imgSrc in imgSrcList:
        content += '''<img src="''' + imgSrc + '''" alt="">'''
    content += '''</body></html>'''
    sendMail.sendMail(title, content)


#getImagesData("http://lady.163.com/photoview/00A70026/114697.html")
Esempio n. 21
0
def main():
    errorTest = readData('TestCase/testCase.xlsx', 'User')
    if len(errorTest) > 0:
        print len(errorTest)
        html = '<html><body>接口自动化扫描,共有 ' + str(len(errorTest)) + ' 个异常接口,列表如下:' +\
               '</p><table><tr><th style="width:100px;text-align:left">    接口    ' \
               '</th><th style="width:50px;text-align:left">    状态    </th><th style="width:200px;text-align:left">' \
               '    接口地址    </th><th style="text-align:left">    接口返回值    </th></tr>'
        for test in errorTest:
            html = html + '<tr><td style="text-align:left">' + test[0] + '</td><td style="text-align:left">' + test[1] \
                   + '</td><td style="text-align:left">' + test[2] + '</td><td style="text-align:left">' + test[3] +\
                   '</td></tr>'
        sendMail(html)
Esempio n. 22
0
def run(m_data):
    failed = {}
    for mail in m_data:
        name = m_data[mail]
        print(f"Processing...{name.upper()} : {mail}")
        drawName(name, fnt_sz=70)
        try:
            sendMail(name, mail)
        except Exception as e:
            failed[name] = mail
            print("ERROR :", e)

    print("\n\nProcess Complted , Total :", len(m_data)-len(failed), "sent")
    print("\nFailed Tasks : ", failed)
Esempio n. 23
0
def checkPublicIP(src, pwd, dst):
	# Comprobamos si la dirección IP pública ha cambiado
	now = datetime.now()
	publicIParchivada, publicActualIP = checkActualIP()
	if publicIParchivada == "" or publicIParchivada != publicActualIP:
             # Guardamos la dirección IP pública actual en la variable "publicIP"
                # Escribimos la dirección IP pública actual en el fichero "publicIPs.txt". El atrib$
		archivo = open("publicIPs.txt", 'w+')
		archivo.write(publicActualIP)
		# Cerramos el fichero
		archivo.close()
		sub="Ha cambiado la IP Publica de casa"
		msg ="La nueva IP Public de casa es:  " + publicActualIP + " a las:  " + str(now)
		# Si la IP actual no coincide con la registrada, enviamos la nueva IP por correo el$
		sendMail(src, pwd, dst, sub, msg)
Esempio n. 24
0
def sendcode(request):
    username = request.POST.get("username", "")
    email = request.POST.get("email", "")
    code = 500
    vecode = captcha(5)
    request.session["vecode"] = vecode

    try:
        Users.objects.get(name=username, email=email)
        sendMail([email], "重置密码验证码", vecode)
        code = 200
        msg = "验证码已发送至邮箱"
    except Users.DoesNotExist:
        msg = "验证信息错误,请重新输入"
    logger.info(str(email) + " " + str(msg))
    return HttpResponse(json.dumps({"code": code, "msg": msg}))
Esempio n. 25
0
def search(br, type_search, language, location):
    """Search the contacts according to your criteria"""

    global PAGE_START, USER_START
    user_nb = 0  # counter
    pages_count = 0

    while True:
        br.select_form(nr=0)
        br.set_all_readonly(False)
        br.form.new_control('text', 'language', {'value': language})
        try:
            """The search from the home page requires a string"""
            br['type'] = type_search
        except:
            """After, when we are in the search page, it requires a sequence"""
            br['type'] = [type_search]
        br['start_value'] = str(PAGE_START)
        br['q'] = 'location:%s' % location
        try:
            request = br.submit()
        except:
            print colored('Page not found', 'red')
            print br.title()
            br.back()
            continue

        page = pq(request.read())
        if not pages_count:
            pages_count = get_pages_count(page)
            print colored('Search has %s pages of results' % pages_count,
                'blue')
        for nickname in page('.result a').map(lambda i, a: pq(a).text()):
            message = '%s => ' % colored(nickname, 'blue')
            user_nb += 1
            for link in br.links():
                if nickname in link.text:
                    request = br.follow_link(link)
                    content = pq(request.read())
                    fullname = get_fullname(content)

                    if user_nb < USER_START:
                        message += colored('skipping ...', 'blue')
                        continue

                    email = get_email(content)
                    if email:
                        #message += 'fake email sent'
                        message += sendMail(fullname, email)
            print message
            br.back()

        if PAGE_START == pages_count:
            # End of search
            break
        PAGE_START += 1
        USER_START = 1
        print colored('Go to page %d' % PAGE_START, 'blue')
Esempio n. 26
0
def findPassword():
    email = request.form['email']
    cursor = db.cursor()
    new_password = mail.createPassword()  #비밀번호 무작위 생성
    hashed_password = crypt.genHash(new_password)  #비밀번호 암호화
    res = ''
    try:
        sql = 'UPDATE user SET PASSWORD = %s WHERE ID LIKE(%s)'
        cursor.execute(sql, (hashed_password, email))
        res = 'success'
        res = jsonify(res)
        mail.sendMail(new_password, email)  #이메일로 비밀번호 전송
        db.commit()
        return res
    except Exception as e:
        db.rollback()
        print(e)
    cursor.close()
Esempio n. 27
0
def get_btc_move_diff(futures):
    "获取各个btc move的差价"
    perpetuals = [i for i in futures if i["type"] == "move"]
    perpetual_names = [{"future_name": i["name"]} for i in perpetuals]
    strikePrices = get_future_stats(perpetual_names)
    strikePrices = {i["name"]: i for i in strikePrices}
    btc_moves = []
    for i in perpetuals:
        name = i["name"]
        if strikePrices[name].get("strikePrice", False):
            c = round(i["index"], 4)  # 指数成分市场的平均市价
            mark = i["mark"]  # 期货标记价格
            strikePrice = round(strikePrices[name]["strikePrice"],
                                4)  # 到期日开始时标的价格
            diff = round(abs(abs(c - strikePrice) - mark), 4)
            c1 = round(abs(c - strikePrice), 4)  ## 预计交割价
            print(
                f"{name}: 行权价:{strikePrice}, BTC指数价:{c}, move价格:{mark},差价:{diff}"
            )

            _append = {
                "index": c,
                "mark": mark,
                "strikePrice": strikePrice,
                "diff": diff,
                "name": name,
                "c1": c1,
            }
            btc_moves.append(_append)
            if diff > 3000:
                result = Index("data/result")
                if name in result:
                    t = result[name]  # 上次发邮件时间
                    if int(time.time()) - t > 60 * 60:  # 超过一小时
                        sendMail("FTX MOVE 差价大于500了", json.dumps(_append),
                                 ["*****@*****.**"])
                        result[name] = int(time.time())
                else:
                    sendMail("FTX MOVE 差价大于500了", json.dumps(_append),
                             ["*****@*****.**"])
                    result[name] = int(time.time())
    return sorted(btc_moves, key=lambda k: k["diff"], reverse=True)
Esempio n. 28
0
def dealSearchKey(searchVul):  # returnDict[sear_key]
    try:
        keyWord = matching_keywords()
        all_key = getkeyWord()
        for vul in searchVul:
            keyIdList = []
            flag = re.search(keyWord, vul)
            if flag:
                for i in all_key.keys():
                    flag1 = re.search(all_key[i], vul)
                    if flag1:
                        keyIdList.append(i)
            for vid in keyIdList:
                xid = butian_insert(all_key[vid], all_key[vid], 'null')
                butian_keyword_insert(xid, vid, all_key[vid])
                toMailAddr = getFollowMail(vid)
                sendMail(
                    toMailAddr[0], all_key[vid],
                    'https://butian.360.cn/vul/search/c/%s' % all_key[vid])
    except Exception as e:
        print(e)
Esempio n. 29
0
 def WatchXjgl(self):
     sendString = ''
     if now.day != self.__setDay:
         self.reset()
     try:
         check_seesion = requests.Session()
         url = 'https://www.jisilu.cn/data/repo/sz_repo_list/?___t=1489544161142'
         xjglInfo = check_seesion.get(url)
         #print(xjglInfo.content.decode())
         jsonXjgl = json.loads(xjglInfo.content.decode())
     except:
         return
     i = 0
     #for row in jsonXjgl['rows']:
     row = jsonXjgl['rows'][0]
     #print(row)
     rowHigh = float(row['cell']['price'])
     if rowHigh > self.__highIn:  #新高超过前基准
         sub = '逆回购: ' + row['id'] + ' 破 ' + str(
             self.__highIn) + ', 现价: ' + row['cell']['price']
         self.__highIn = max(self.__highIn * 1.3, rowHigh)
         print(sub)
         sendMail.sendMail(sub, "")
Esempio n. 30
0
def successful():
    try:
        if request.method == "POST":
            email = request.form["emailVal"]
            height = request.form["heightVal"]
            weight = request.form["weightVal"]

            #If email doesn't exist in database
            if db.session.query(Data).filter(
                    Data.emailDB == email).count() == 0:
                bmi = (float(weight)) / (float(height) / 100)**2
                data = Data(email, height, weight, bmi)
                bmiRange = bmiRangeGet(bmi)
                average = db.session.query(func.avg(Data.bmiDB)).scalar()
                sendMail(email, height, weight, bmi, bmiRange, average)
                db.session.add(data)
                db.session.commit()
                return render_template("successful.html")

            #Update info if email exists in database
            elif db.session.query(Data).filter(
                    Data.emailDB == email).count() == 1:
                entity = db.session.query(Data).filter(
                    Data.emailDB == email).first()
                entity.heightDB = height
                entity.weightDB = weight
                entity.bmiDB = (float(
                    entity.weightDB)) / (float(entity.heightDB) / 100)**2
                bmiRange = bmiRangeGet(entity.bmiDB)
                average = db.session.query(func.avg(Data.bmiDB)).scalar()
                sendMail(email, height, weight, entity.bmiDB, bmiRange,
                         average)
                db.session.commit()
                return render_template("updated.html")
    except Exception as e:
        print(e)
        return render_template("error.html")
def main():
    files18 = [f for f in listdir(Path('./data/18/')) if f.endswith(".xlsx") if isfile(join(Path('./data/18'), f))]
    savedData = Path('savedData.txt') 
    # create savedData.txt if not exist
    if savedData.is_file():
      with open("savedData.txt", "rb") as fp:
          existing_files18 = pickle.load(fp)
    else:
      with open('savedData.txt', 'wb') as fp:
        pickle.dump([], fp)
    # check if there are new files to add
    if files18 == existing_files18:
        print('There are no new files to add')
    else:
        print("there are files to add...")
        setNewFiles = set(files18)
        setExistingFiles = set(existing_files18)
        unmatched = setNewFiles.symmetric_difference(setExistingFiles)
        print('File with name {} wil be added to the df'.format(unmatched))
        addFiles(True, list(unmatched)[0])
        saveDF()
        sendMail('*****@*****.**', 'formatting df', 'formatting df completed')
        with open('savedData.txt', 'wb') as fp:
            pickle.dump(files18, fp)
Esempio n. 32
0
def informRequestor(addrTo, msg, platf):
    addrFrom = "*****@*****.**"
    subj = '[cib] results from customIB (' + platf + ')'
    sendMail.sendMail(addrFrom, addrTo, subj, msg)
    return
Esempio n. 33
0
import time

from sendMail import sendMail

#name of process to look for
procnamePrefix = "findClone"

waitStart = False
waitEnd = True

while True:
    output = commands.getoutput("ps -A")
    found = False
    for process in output.split("\n"):
        if "<defunct>" in process:
            sendMail("Zombies!!! call rick!!!")
            while True:
                pass
        if procnamePrefix in process:
            #print "FOUND!"
            found = True
    
    if found == False:
        if waitEnd:
            #ok we stopped, alert via main and toggle
            sendMail("Watch dog exit")
            waitStart = True
            waitEnd = False
            print "Waiting for start"
    else:
        if waitStart:
Esempio n. 34
0
def sendDirectMail() :
	content = getContent()
	if sendMail(mailInfo.subject, content) :
		print "send mail successfully."
	else :
		print "send mail failed."
Esempio n. 35
0
sendTo = open(sendtoFile)
messages = open(messagesFile).read()
cntSend=0
cntUnsend=0
cntTotal=0
for line in sendTo:
    strTemp = line.strip()
    if strTemp=="":
        continue
    cntTotal += 1
    sendtoList.append(line[:-1])
    if len(sendtoList) >= LIMIT:
        if accountIndex<len(user):
            sendMail.smtpuser = user[accountIndex][0] 
            sendMail.smtppass = user[accountIndex][1]
            sendMail.sendMail([],[],sendtoList,subject,messages,[])
            accountIndex += 1
            cntSend += len(sendtoList)
            print cntSend
            print "send from:"+sendMail.smtpuser+" to:"
            print sendtoList
        else:
            print "no user available"
            for i in range(len(sendtoList)):
                unsend.write(sendtoList[i]+"\n")
            cntUnsend += len(sendtoList)
        sendtoList = []
if len(sendtoList) >= 1:
    if accountIndex<len(user):
        sendMail.smtpuser = user[accountIndex][0] 
        sendMail.smtppass = user[accountIndex][1]
def loadDataDatabase(data):
    day = datetime.datetime.now().day
    #每个月5,10,15,20,25对数据更新做校准
    if day % 5 == 0:
        currentTime = time.strftime('%Y-%m-%d %H:%M:%S',
                                    time.localtime(time.time()))
        currentH = int(currentTime.split(' ')[1].split(":")[0])
        currentM = int(currentTime.split(' ')[1].split(":")[1])
        if ((currentH == 0) & (currentM < 10)):
            pass
            #adjustData(data);
    tempDataForDatabase = data[data['存储方式(源)'] == 'database']
    indexKeyForDatabase = list(set(list(tempDataForDatabase['标记值'])))
    for i in range(0, len(indexKeyForDatabase)):
        tempData = tempDataForDatabase[tempDataForDatabase['标记值'] ==
                                       indexKeyForDatabase[i]]
        databaseConfig = list(tempData['配置(源)'])[0]
        tableName = list(tempData['目标表'])[0]
        sourceTableName = list(tempData['表名(源)'])[0]
        rules = tempData[['字段名称(源)', '目标字段名称', '默认值']]
        config = list(tempData['配置'])[0]
        sql = list(tempData['sql语句'])[0]

        timingMarkDesList = list(tempData['定时标记'])

        filedSource = list(tempData['字段名称(源)'])
        filedTarget = list(tempData['目标字段名称'])

        fileDic = dict(zip(filedTarget, filedSource))
        fileTimeDic = dict(zip(filedTarget, timingMarkDesList))

        (mapValueDatabase,
         databaseTypeDatabase) = creatMapValue(databaseConfig)
        (mapValue, databaseType) = creatMapValue(config)
        enginKey = creatCnnKey(mapValue)
        cnnKey = creatCnnKey(mapValueDatabase)
        (TargetCursor, TargetCnn) = createSqlEngin.TargetCnnDict[cnnKey]
        #得到源数据库游标
        (TargetCursorDes,
         TargetCnnDes) = createSqlEngin.TargetCnnDict[enginKey]  #得到目标数据库游标
        engin = createSqlEngin.enginDict[enginKey]

        #先读取配置文件的定时标记形成预加载,如果配置文件没有该表的定时文件,
        # 直接从目标库中读取最新定时标记信息,然后直接写入配置文件,
        # 每隔十次/天进行配置文件和目标库的标记字段进行校准
        tag1 = None
        tag2 = None
        (conf, tableNameList) = readLocalConfig()
        if tableName in tableNameList:
            tempTimeTag = conf.items(tableName)
            sql = 'select * from ' + sourceTableName
            if len(tempTimeTag) == 1:
                tempStr = ' where ' + fileDic[tempTimeTag[0][0]] + ' > ' + str(
                    tempTimeTag[0][1])
                tag1 = tempTimeTag[0][0]
                sql = sql + tempStr
            elif len(tempTimeTag) == 2:
                # 有问题
                tag1 = tempTimeTag[0][0]
                tag2 = tempTimeTag[1][0]
                tempStr = ' where ' + '( '+fileDic[tempTimeTag[0][0]] + ' = ' + str(tempTimeTag[0][1])+' and '+fileDic[tempTimeTag[1][0]] + ' > ' + str(tempTimeTag[1][1])\
                    + ')'+' or ' +' ('+ fileDic[tempTimeTag[0][0]] + ' > '+ str(tempTimeTag[0][1])+' ) '
                sql = sql + tempStr
            else:
                sendMail.sendMail(tableName, '数据表时间标记大于2')
                continue
        else:
            sql = 'select * from ' + sourceTableName
            #此sql用于读取目标数据标定最新日期等数据用于确定update的数据时间
            tempSql = 'select * from ' + tableName
            temp1 = ''
            temp2 = ''

            keyList = fileTimeDic.keys()
            for key in keyList:
                if fileTimeDic[key] == 1:
                    temp1 = ' order by ' + key + ' desc'
                    tag1 = key
                elif fileTimeDic[key] == 2:
                    temp2 = ',' + key + ' desc'
                    tag2 = key
            tempSql = tempSql + temp1 + temp2 + ' limit 20'
            TargetCursorDes.execute(tempSql)
            data = TargetCursorDes.fetchmany(100)
            if data == []:
                sql = sql
            else:
                data = pd.DataFrame(data)
                cols = TargetCursorDes.description

                colnum = []
                for col in cols:
                    colnum.append(col[0])
                data.columns = colnum
                tagValue2 = None
                tagValue1 = list(data[tag1])[0]

                if tag2 != None:
                    tagValue2 = list(data[tag2])[0]
                tempSql = sql
                sql = sql + " where " + fileDic[tag1] + ' > ' + str(tagValue1)
                if tagValue2 != None:
                    sql = tempSql+" where "+' ( '+fileDic[tag1] +' = ' + str(tagValue1) + ' and '+fileDic[tag2] +' > ' + str(tagValue2) +' ) '\
                        + ' or '+' ( '+fileDic[tag1] +' > ' + str(tagValue1) +' ) '
                    #sql = sql + ' and '+fileDic[tag2] +' > ' + str(tagValue2);
                writeConfig(tableName, tag1, tagValue1, tag2, tagValue2)
        try:
            readDataFromOriginDatabase(TargetCursor, sql, rules, engin,
                                       tableName, tag1, tag2)
        except Exception as e:
            print(e)
            currentTime = time.strftime('%Y-%m-%d %H:%M:%S',
                                        time.localtime(time.time()))
            sendMail.sendMail(tableName, '数据导入出问题:' + str(currentTime))
    return
def informRequestor(addrTo, msg, platf):
    addrFrom = "*****@*****.**"
    subj     = '[cib] results from customIB ('+platf+')'
    sendMail.sendMail(addrFrom, addrTo, subj, msg)
    return
Esempio n. 38
0
time_before = timedelta(weeks=4)

connection_string = "-d postgresql://sysop:[email protected]/sc_master"

t0 = datetime.now() - time_before
tf = datetime.now()

filename = "picks_%s_%s.xml"%(t0.strftime("%Y%m%dT%H%M"), tf.strftime("%Y%m%dT%H%M"))

_t0 = t0.strftime("%Y-%m-%d %H:%M:%S")
_tf = tf.strftime("%Y-%m-%d %H:%M:%S")

#dump Picks
cmd = "python dumpManualPicks.py %s --begin '%s' --end '%s' > %s" % (connection_string, t0, tf, filename)
print cmd
os.system(cmd)

# compress file
tar_filename = "%s.tar.gz" % filename
cmd = "tar czf %s %s" % (tar_filename, filename)
print cmd
os.system(cmd)

import sendMail as mail
mail.sendMail(tar_filename)

#remove old file
cmd = "rm -f %s %s" % (tar_filename, filename)
print cmd
os.system(cmd)
Esempio n. 39
0
t0 = datetime.now() - time_before
tf = datetime.now()

filename = "picks_%s_%s.xml" % (t0.strftime("%Y%m%dT%H%M"),
                                tf.strftime("%Y%m%dT%H%M"))

_t0 = t0.strftime("%Y-%m-%d %H:%M:%S")
_tf = tf.strftime("%Y-%m-%d %H:%M:%S")

#dump Picks
cmd = "python dumpManualPicks.py %s --begin '%s' --end '%s' > %s" % (
    connection_string, t0, tf, filename)
print cmd
os.system(cmd)

# compress file
tar_filename = "%s.tar.gz" % filename
cmd = "tar czf %s %s" % (tar_filename, filename)
print cmd
os.system(cmd)

import sendMail as mail

mail.sendMail(tar_filename)

#remove old file
cmd = "rm -f %s %s" % (tar_filename, filename)
print cmd
os.system(cmd)
Esempio n. 40
0
        print company
        date = company_results_hash.get(company)
        print date
        if date:
            resultDate = datetime.strptime(date, date_format).date()
            print resultDate
            diff = (resultDate - today).days
            if diff >= 0:
                final_company[company + "|" + date] = diff

for key, days in sorted(final_company.items(), key=lambda x: x[1]):
    value = key.split("|")
    company = value[0]
    date = value[1]
    msg = msg + "<tr><td>" + company.title() + "</td><td><b>" + str(
        days) + " days to go</b></td><td>" + date + "</td></tr>"

if msg:
    msg = "<table border=\"2\"><body><tr><th><b>Company Name</th><th>Days Left</th><th>Result Date</th></b></tr>" + msg + "</body></table>"
else:
    msg = "<body><b><i>No results with in a week</i></b></body>\n"

print "msg ", msg
to = [
    "*****@*****.**", "*****@*****.**",
    "*****@*****.**"
]
sendMail("*****@*****.**", to, subject, msg)

print "mail sent "
Esempio n. 41
0
## Loop for host in hosts
for host in hosts:
    ## Chech the url
    if host[-7:] != 'faq.htm':
        print 'Host Url ERROR'
    else:
        try:
            ## Http request without verify and use local proxy
            r = requests.get(host, verify=False, proxies=proxyDict)
            #print r.status_code
            #print r.headers
            #print r.content

            ## Service crash
            if r.status_code != 200:
                sendMail(msg(request_exception, host, r.status_code, r.headers, r.content))
            ## Return without <!--Newegg-->
            elif r.content.find("Newegg")==-1:
                sendMail(msg(request_return_exception_content, host, r.status_code, r.headers, r.content))
            else:
                print 'Everying is awesome'

            ## Test sendMail functional
            #else:
            #    sendMail(msg(request_return_exception_content, host, r.status_code, r.headers, r.content))
        except Exception as e:
            print 'Exception!!'
            print e
    
Esempio n. 42
0
 def test_sendmail_succeeds(self):
     result = sendMail(u'Test', SENDER)
     self.assertEquals(result, '%s \x1b[32m / mail sent !\x1b[0m' % SENDER)
Esempio n. 43
0
            print "loading - " + exeName + " ... " ,
            currentExeDir = os.path.join(targetsDir,os.path.join(exeName,functionsGraphsDirectoryName))

            for funcFileName in filter(lambda x:x.endswith(myExt),os.listdir(currentExeDir)):
                tarGraph = igraph.read(os.path.join(currentExeDir,funcFileName))
                tarGraph['name'] = funcFileName
                
                #funcFileName and exe are only for the timeout print
                yield {'tarGraph':tarGraph,'refGraph':refGraph,'sourcesList3k':sourcesList3k,'funcFileName':funcFileName,'exeName':exeName}
            
            print "finished loading " + exeName 
            
    params =  [doOneFunctionFileRW,superFunctionsGenerator()]
    #if (mapper !=  itertools.imap):
    #    params.append(50)       
         
    for allFields in mapper(*params):    
        for fields in allFields:           
            reportFile.writeLine(fields)


if __name__ == '__main__':
    startVal = time.time()
    CompareWithKSplit()
    end = time.time()

    print "total runtime = " + str(getDurationStr(int(end-startVal)))
    
    sendMail()