Exemple #1
0
def notifyKey(keyID, username, account, filename):
    message = (
        "\n\nThis is a IAM Access ID expiration notification for the following IAM Key Pair:"
        + "\n\nAccess ID: " + keyID + "\nIAM User: "******"\nAccount: " + account +
        "\n\nThis key pair will be deleted in 3 Months." +
        "\n\nYour new encrypted key pair can be found here: https://s3-us-west-2.amazonaws.com/"
        + keyBucket + "/" + filename +
        "\n\nPlease make the necessary changes to your new key to prevent any downtime in production.\n\n"
    )

    recipents = getEmails(account, username)
    if production:
        sendEmail(recipents, '*****@*****.**',
                  'TEAM MESSAGE: KEY ROTATION NOTIFICATION', message, "plain")

    if p2c and not production:
        print("SEND TO: " + str(recipents) + "\nMESSAGE: " + message)
    logging.info("ACCESS ID NOTIFICATION. Key: " + keyID + " for user: "******" in account: " + account +
                 " will be deleted in 3 months")
    if p2c:
        print("ACCESS ID NOTIFICATION. Key: " + keyID + " for user: "******" in account: " + account +
              " will be deleted in 3 months")
def Main():
    """Compiles the Final Scheduler to be sent out via. Text Message"""
    
    #Retrieves the Current Days Schedule
    daySchedule = getSchedule()
    
    #Prints Schedule
    print "Todays Schedule Is: " + "\n" + daySchedule + "\n" 
    #Sends Email
    sendEmail(daySchedule)
Exemple #3
0
def notifyDelete(keyID, username, account):
    message = (
        "\n\nThis is a IAM Access ID deletion notification for the following IAM Key Pair:"
        + "\n\nAccess ID: " + keyID + "\nIAM User: "******"\nAccount: " + account + "\n\nThis key pair WAS DELETED on: " +
        str(datetime.datetime.utcnow()) + "\n\n\n\n")

    recipents = getEmails(account, username)
    if production:
        sendEmail(recipents, '*****@*****.**',
                  'TEAM MESSAGE: KEY DELETION NOTIFICATION', message, "plain")
Exemple #4
0
def run(name):
    while (1):
        item = r.blpop('class_info')
        print '%d接收到一个任务' % name
        xh, password, email = item[1].split('|')
        try:
            Util(xh, password, email).run()
        except Exception as e:
            print e
            sendEmail('*****@*****.**', htmlText=str(e))
        print '%d完成到一个任务' % name
Exemple #5
0
def notifyMissing(username, account):
    message = (
        "\n\nThe following user is missing a Public Key for Encryption or not in Whitelist:"
        + "\nIAM User: "******"\nAccount: " + account +
        "\n\nEnsure key is imported using GPG on CRON Server, User is listed in IAM Account list, and/or their Public Key email is correctly present in IAM Account List.\n\n"
    )

    recipents = [notifyEmail]
    if production:
        sendEmail(recipents, '*****@*****.**',
                  'TEAM MESSAGE: MISSING INFORMATION FOR IAM USER', message,
                  "plain")
    if p2c and not production:
        print("SEND TO: " + str(recipents) + "\nMESSAGE: " + message)
    for title, author in tqdm(books):
        price, link = getBookPriceAbeBooks(title, author)
        time.sleep(10)
        prices.append([title, author, price, link])

    browser.close()
    prices.sort(key=lambda x: x[2])
    return prices[:3]


def getInputBooks(inputFile):
    file = open(inputFile)
    books = []
    for line in file.readlines():
        title, author = line.strip().split("\t")
        books.append([title, author])
    return books


def displayTopThree(top_three):
    for book in top_three:
        print(book[0] + ": %.2f" % book[2])


books = getToRead()

top_three = getTopThree(books)

displayTopThree(top_three)
sendEmail(top_three)
                    for cutoff in range(0, 31):
                        cut = cutoff/float(100)   # Cutoff in decimal form
                        y = y_pred > cut   # If y values are greater than the cutoff
                        recall = metrics.recall_score(test_label, y)
                        # true_negative_rate = sum(np.logical_not(np.logical_or(test_label, y)))/float(len(y_pred))
                        filter_rate = sum(np.logical_not(y))/float(len(y_pred))
                        if recall*6.7+filter_rate > results[0]:
                            results[0] = recall*6.7+filter_rate
                            results[1] = metrics.roc_auc_score(test_label, y)
                            results[2] = recall
                            results[3] = filter_rate
                            results[4] = cut
                            results[5] = 127000*filter_rate -5200 -850000*(1-recall)
                    wr.writerow(results)
                    print 'done for the hour', j
                    print '--------------------------'
                print 'done for the DAY', i
                print '-------------------------------------'
                print '-------------------------------------'
            print '_______________________________________________________________________'
            print '_______________________________________________________________________'
        except:
            pass
            errorCounter += 1
            print 'There was an error'
            subjeto = 'Error on code... countOfError' + str(errorCounter)
            sendEmail('*****@*****.**',subjeto,"XGBoost-trainHoursDaily.py encountered an error. :P")
            #time.sleep(20)  #sleep


sendEmail('*****@*****.**','Code Done2',"XGBoost-trainHoursDaily.py ended running in the local RIPS computer. :P")
                filter_rate = sum(np.logical_not(preds))/float(len(preds))
                savings = 127000*filter_rate -5200 -850000*(1-recall)
                print '[day, hour, recall, filtering rate, savings ] '
                #['Net_Savings', 'num_round', 'day_trained', 'day_predicted','hour_trainedAndTested']
                timeSpentOnRound = time.time()-start
                print '[i, j, recall, filter_rate, savings, timeSpentOnRound ]'
                print [i, j, recall, filter_rate, savings, timeSpentOnRound ]
                results = [eta1, eta2, eta3,savings, num_round,p0, p1,ph0, timeSpentOnRound]
                print 'It took', time.time()-timeThen, 's TIME to get the metrics: recall filtering and so on.'
                timeThen = time.time()
                wr.writerow(results)
                print 'done for the hour', j
                print '--------------------------'
            print 'done for the DAY', i
            print '-------------------------------------'
            print '-------------------------------------'
        print '_______________________________________________________________________'
        print '_______________________________________________________________________'
        # except Exception as e:
        #     print e
        #     print 'ooops'
        #     #pass
        #     errorCounter += 1
        #     print 'There was an error, count ', errorCounter
        #     subjeto = 'Error on code... countOfError' + str(errorCounter)
        #     #sendEmail('*****@*****.**',subjeto,"XGBoost-trainHoursDaily.py encountered an error. :P")
            #time.sleep(20)  #sleep


sendEmail('*****@*****.**','Code Done2',"XGBoost-EnsemblewithFunctions.py ended running in the local RIPS computer. :P")
                                cut = cutoff/float(100)   # Cutoff in decimal form
                                y = y_pred > cut   # If y values are greater than the cutoff
                                recall = metrics.recall_score(test_label, y)
                                # true_negative_rate = sum(np.logical_not(np.logical_or(test_label, y)))/float(len(y_pred))
                                filter_rate = sum(np.logical_not(y))/float(len(y_pred))
                                if recall*6.7+filter_rate > results[0]:
                                    results[0] = recall*6.7+filter_rate
                                    results[1] = metrics.roc_auc_score(test_label, y)
                                    results[2] = recall
                                    results[3] = filter_rate
                                    results[4] = cut
                                    results[5] = 127000*filter_rate -5200 -850000*(1-recall)
                            wr.writerow(results)
                            print 'done for the DAY',p0
                            print '-------------------------------------'
                            print '-------------------------------------'
                        except Exception as e:
                            pass
                            errorCounter += 1
                            print 'There was an error in day '+str(i)
                            texto = "XGBoost-Grid-Searches_RAM.py encountered an error. :P..." +str(sys.exc_info()[0])
                            texto = texto+'                                                                  '+str(e)
                            subjeto = 'Error '+ str(errorCounter) +'... on code in da GRID... on day '+str(i)+' on eta = '+str(eta)+'   on num_round = '+ str(num_round)
                            sendEmail('*****@*****.**',subjeto,texto)
                    print '_______________________________________________________________________'
                    print '_______________________________________________________________________'
                    wr.writerow(['Increasing_num_Round'])
                    print 'end of num_round =  ', num_round
                wr.writerow(['Increasing_eta','num_Round_fixed'])
                print 'end of eta =  ', eta
sendEmail('*****@*****.**','Code Done',"XGBoost-Grid-Searches_RAM.py ended running in the local RIPS computer. :P")
Exemple #10
0
#!/usr/bin/env python3
#-*- coding:utf-8 -*-
请在Python3下运行此程序='Please run this program with Python3'
'''此脚本需要在网速较好的情况下运行,否则会出现网页一直加载不完的情况'''

import time
from SendEmail import sendEmail
from Screenshot import Screenshot

try:
    text_body = 'weather' # ATTENTION: you must add the email's body, otherwise it CANNOT be sent out!
    subject = 'ZhengZhou weather for 7 days and 15 days later'
    ss = Screenshot()
    attachment = ss.saveScreenshot()
    sendEmail(subject=subject,text_body=text_body , attachment=attachment)
    # sendEmail(subject=subject,text_body=text_body)
except Exception as e:
    timestyle = time.strftime('%m%d_%H%M%S')
    logname = 'err_{}.log'.format(timestyle)
    print('err--->', str(e))
    with open(logname, 'w') as f:
        f.write(str(e))