Exemplo n.º 1
0
def getSales():
    global skin_sales
    global champ_sales
    global debug
    #Get sale page

    sale, title = getSalePage();

    sale = 'http://na.leagueoflegends.com/' + sale

    data = getHTMLofPage(sale)

    sale_parser = SalePageParser()
    sale_parser.feed(data)

    #Remove new line characters for the Champion names
    for i in range(0, len(champ_sales)):
        champ_sales[i] = re.sub("\n", "", champ_sales[i])

    try:
        f = open("mostrecentsale.txt")
        oldTitle = f.read()
        f.close()
    except IOError:
        oldTitle = "none"

    if not oldTitle == saleTitle or debug:
        f = open("mostrecentsale.txt", 'w')
        f.write(saleTitle)
        f.close()
        emailMessage = "\nSkins on sale:\n\t" + '\n\t'.join(skin_sales) + "\n\nChampions on sale:\n\t" + '\n\t'.join(champ_sales) + ""
        
		recipient = ""
		sendEmail(recipient, saleTitle, emailMessage)
Exemplo n.º 2
0
def send(mailContent):
    # send=emailSenderWithClass.EmailSender()
    # send.sendEmail('*****@*****.**', subjectText = '*****CURRENT RCZ CRAZY PRICES***** csak neked :)', massageText = 'asdfgh')

    emailSender.sendEmail(
        '*****@*****.**',
        subjectText='*****CURRENT RCZ CRAZY PRICES***** csak neked és nekem :)',
        massageText=mailContent)
Exemplo n.º 3
0
def detectDevice(ipAddress, macAddress):
    while True:
        mac = getmac.get_mac_address(ip=ipAddress)
        if mac == macAddress:
            msg = "Device (" + ipAddress + ") has joined the network"
            print(msg)
            sendEmail(sender_email, password, receiver_email, msg)
            return
        else:
            time.sleep(1)
Exemplo n.º 4
0
def handle_message(msg):
    task = json.loads(msg)
    #task = msg
    if (not isinstance(task, dict) or not 'zpid' in task
            or task['zpid'] is None):
        return

    zpid = task['zpid']

    users = getPermissionList()

    # Scrape the zillow for details
    property_detail = zillow_web_scraper_client.get_property_by_zpid(zpid)

    for user in users:
        emailSender.sendEmail(user, property_detail)
Exemplo n.º 5
0
auth.set_access_token(os.environ["TW_ACCESS_TOKEN"],
                      os.environ["TW_ACCESS_SECRET"])
api = tweepy.API(auth)
DailyUpdate = False
gTotal = 0
gReplied = 0
gErrors = 0

while (True):
    try:
        if (time.localtime().tm_hour == 2):
            DailyUpdate = False
        if (not DailyUpdate and time.localtime().tm_hour == 3):
            print(
                emailSender.sendEmail(
                    "TWBOT: Daily report",
                    "\nHere is your daily report:\r\nTotal mentions: {}\r\nReplied to: {}\r\nErrors: {}"
                    .format(gTotal, gReplied, gErrors)))
            with open("stats.txt", "a+") as f:
                f.write(
                    "Day: {} {} {}\t Total mentions: {}\t Replied to: {}\t Errors: {}\r\n"
                    .format(time.localtime().tm_year,
                            time.localtime().tm_mon,
                            time.localtime().tm_mday, gTotal, gReplied,
                            gErrors))
            gTotal = gReplied = gErrors = 0
            DailyUpdate = True

        with open("lastId.txt", "r") as f:
            lastId = int(f.read().strip())

        mentionsN, newLastId, repliedN, errors = checkStatus(lastId)
Exemplo n.º 6
0
def handleBurst(serv):
    recips =["*****@*****.**","*****@*****.**"]
    connfailures = 0
    emailMeAtMost = 60* 10 # 10 min in seconds
    lastEmailTime = 0
    while True:
        try:
            print("bout to say accept..")
            (conn,addr) = serv.accept()
            print("connection accepted")
            dat = conn.recv(BUFSIZE).decode('UTF-8', 'ignore')
            print("data received!!!")
            dat = dat.encode('cp850', errors='replace').decode('cp850').encode("utf-8", errors='replace').decode("utf-8")
            connfailures = 0
        except KeyboardInterrupt:
            print("You have entered a keyboard interrupt. exiting.")
            conn.close()
            sys.exit(0)
            quit()
        except:
            connfailures += 1 
            mydelay = 30 #seconds
            e0 =str(sys.exc_info()[0])
            v0 = str(sys.exc_info()[1])
            t0 = str(tb.extract_tb(sys.exc_info()[2]))
            error0 = "ERROR:\n" + e0 + "\n\nVALUE:\n" + v0 + "\n\nTRACEBACK:\n" + t0 
            sub ="Connection to Device Server Error"
            bod="Error: \n" + error0
            
            try:
                conn.close()
                print("Connection closed!")
                connectionStatus = "successfully closed connection"
            except:
                connectionStatus = "failed to close connection:\n"
                connectionStatus+= str(sys.exc_info()[0])
                connectionStatus+= "\n" + str(sys.exc_info()[1])

            bod += "\n\n" + connectionStatus
            bod += "\n conn failures since last success: " + str(connfailures)
            bod += "\n Attempt reconnect in: " + str(mydelay) + " seconds."
            if ((t.time() - lastEmailTime) > emailMeAtMost):
                es.sendEmail(recips,sub,bod)
                lastEmailTime = t.time()
            t.sleep(mydelay)
            continue
                
            
        try:
            print(dat)
        except:
            
            e =str(sys.exc_info()[0])
            v = str(sys.exc_info()[1])
            t = str(tb.extract_tb(sys.exc_info()[2]))
            error1 = "ERROR:\n" + e + "\n\nVALUE:\n" + v + "\n\nTRACEBACK:\n" + t 
            print("calling music logger..")
            try:
                mlog.handleDataBurst(dat)
            except:
                sub="Failed to print and failed to log"
                e2 =str(sys.exc_info()[0])
                v2 = str(sys.exc_info()[1])
                t2 = str(tb.extract_tb(sys.exc_info()[2]))
                error2 = "ERROR:\n" + e2 + "\n\nVALUE:\n" + v2 + "\n\nTRACEBACK:\n" + t2
                bod="print error:\n" + error1 + "\n" + "log error:\n" + error2
                es.sendEmail(recips,sub,bod)
            else:
                # if we s succeeded in logging, but there was a print error
                sub ="Error printing but logging song raised no exceptions"
                bod="print error: \n" + error1
                bod += "\n dat=\n" + dat
                es.sendEmail(recips,sub,bod)
        else:
            try:
                mlog.handleDataBurst(dat)
            except:
                sub="success printing, but logging threw an exception"
                e3 =str(sys.exc_info()[0])
                v3 = str(sys.exc_info()[1])
                t3 = str(tb.extract_tb(sys.exc_info()[2]))
                error3 = "ERROR:\n" + e3 + "\n\nVALUE:\n" + v3 + "\n\nTRACEBACK:\n" + t3 
                bod="dat=\n" + dat +"\n\n Error logging:\n" + error3
                es.sendEmail(recips,sub,bod)

        conn.close()
        print("Connection closed!")