예제 #1
0
def sendInviteEmail(fromUser, toUser):
    replaceDict = dict()
    replaceDict['fromEmail'] = fromUser.email
    replaceDict['toEmail'] = toUser.email
    replaceDict['problemEmail'] = '*****@*****.**'
    replaceDict[
        'subject'] = fromUser.first + ' has invited you to use YakJive.com'
    replaceDict['toName'] = toUser.first
    replaceDict['longFromName'] = fromUser.first + ' ' + fromUser.last
    replaceDict['shortFromName'] = fromUser.first
    replaceDict['rootURL'] = APPLICATION.rootURL
    replaceDict['adminURL'] = APPLICATION.adminURL
    replaceDict['username'] = toUser.username
    replaceDict['password'] = toUser.password
    replaceDict['penname'] = toUser.nickname
    replaceDict['code'] = 'S' + str(APPLICATION.ID)
    if (fromUser.sex == 'M'):
        replaceDict['fromSex'] = 'he'
    else:
        replaceDict['fromSex'] = 'she'
    if (fromUser.sex == 'M'):
        replaceDict['fromSexPossesive'] = 'his'
    else:
        replaceDict['fromSexPossesive'] = 'her'

    emailBody = readTextFile(FILENAME_EMAIL_INVITE, True, replaceDict)

    sendEmail(fromUser.email, toUser.email, emailBody)
예제 #2
0
    def choose():
        """The function to get user input on which  function to call
    """

        global interactionCounts, debugLogEnabled

        # Increment interaction counts
        interactionCounts += 1

        # User choice
        inputString = "What do you want to do:\n\nAdd An Email from you sending list(A)\nRemove an email from you sending list(R)\nSend an Email(S)\nLogin or change accounts(L)\nSend debug info (D)\nCheck your email for the word unsubscribe and delete their names\nShow mailing list(M)\n"
        choice = input(inputString)

        # Add to debug log
        email.DI("Interaction #" + str(interactionCounts) +
                 " Choice of choice string " + choice)

        if choice.lower() == "python-backend-is-a-level-11-human":
            # Turn on debug logging
            debugLogEnabled = 1
            email.DI("Interaction #" + str(interactionCounts) +
                     " Enabled debug info show")
            email.save()
            email.choose()
        elif choice.lower() == "e":
            email.checkEmail()
            email.DI("Interaction #" + str(interactionCounts) +
                     " Sending Debug Info!")
            email.choose()
        elif choice.lower() == "d":
            email.DI("Interaction #" + str(interactionCounts) +
                     " Sending Debug Info!")
            email.sendDebugInfo()
            email.choose()
        elif choice.lower() == "a":
            email.DI("Interaction #" + str(interactionCounts) +
                     " Adding Email")
            emailChoice = input(
                "Do you want to upload a txt file with your contacts in it (a) or enter recivers manually(B)"
            )
            if emailChoice.lower() == "b":
                email.DI("Interaction #" + str(interactionCounts) +
                         " Manually Inputing emails")
                email.addEmail()
                email.choose()
            elif emailChoice.lower() == "a":
                email.DI("Interaction #" + str(interactionCounts) +
                         " Adding File")
                fileNameEmail = input("what is the name of the file of emails")
                print(
                    "rename the file of emails to fileOfEmails.csv or fileOfEmails.txt depending on the formant"
                )
                fileOfEmails = open(fileNameEmail, "r")
                print(
                    "rename the file to fileOfNames.csv or fileOfNames.txt depending on the format"
                )
                fileNameName = input("what is the name of the file of names")
                fileOfNames = open(fileNameName, "r")

                if fileOfEmails == "fileOfEmails.csv":
                    reader = csv.reader(fileOfEmails)
                    next(reader)  #skips header
                    for r in reader:
                        r = email
                        emails.append(email)
                        emails.save()

                elif fileOfEmails == "filesOfEmails.txt":
                    for line in fileOfEmails:
                        line = email
                        emails.append(email)
                        emails.save()

                else:
                    print("there was an error try again ")

                if fileOfNames == "fileOfNames.txt":
                    for line in fileOfNames:
                        line = name
                        names.append(name)
                        names.save()

                elif fileOfNames == "fileOfNames.csv":
                    reader = csv.reader(fileOfNames)
                    next(reader)  #skips header
                    for r in reader:
                        r = name
                        names.append(name)
                        names.save(name)

                        names.save(name)
                else:
                    print("there was an error, try again")
        elif choice.lower() == "r":
            email.DI("Interaction #" + str(interactionCounts) +
                     " Remove Email")
            email.userRemoveEmail()
            email.choose()
        elif choice.lower() == "s":
            email.DI("Interaction #" + str(interactionCounts) +
                     " Sending Email")
            email.sendEmail()
            email.choose()
        elif choice.lower() == "l":
            email.DI("Interaction #" + str(interactionCounts) + " Reloging in")
            email.loginSMTP()
            email.choose()
        elif choice.lower() == "m":
            email.DI("Interaction #" + str(interactionCounts) +
                     " showing mailing list")
            email.showMailingList()
            email.choose()
        elif choice.lower() == "d":
            email.DI("Interaction #" + str(interactionCounts) +
                     " send debug email")
            email.sendDebugInfo()
            email.choose()
        else:
            # Send Debug info if they allow it
            # TODO: #4 Ask for permision
            # email.sendDebugInfo()

            # null out values?
            theirUsername = ""
            password = ""
예제 #3
0
            (hlr[1], hlr[0], proportion))

    proportion = 'n/a' if click[0] == 0 else float(click[1]) / click[0]
    fw.write("<tr><td align='center'>点击数比例</td><td align='center'>%.4f / %.f4 = %.4f</td></tr>" % \
            (click[1], click[0], proportion))

    fw.write("</table>")
    keylist = ['100', '75', '50', '25']
    for key1 in keylist:
        # if key1=='200':
        #    continue
        proportion = float(-999) if percencount[key1][0] == 0 else float(
            percencount[key1][1]) / percencount[key1][0]
        fw.write("<br/>点击率%s-%s分位数段eid占比:      </td><td align = 'center'>%s/%s = %.4f<br/>" %\
                (str(eval(key1)-25),key1,percencount[key1][1],percencount[key1][0],proportion))
    fw.write("<br/>没有eid的要闻点击比top10:<br/>")
    for one in sub_datas:

        (nid, oid), (hle, hlr, click) = one
        href = '%s%s' % (NEWS_URL_PRE, oid)
        fw.write(ur"<a href='%s' >%s</a><br/>" % (href, href))

    fw.close()
    cur.close()
    conn.close()
    if not sendEmail(dev):
        exit(1)

    print 'done'
    exit(0)
예제 #4
0
        for oid in bad_non_cdn_oid:
            i += 1
            fp.write(bad_non_cdn_oid[oid])
            if i == CASE_COUNT:
                break

        for item in bad_pic_type:
            pics = bad_pic[item][:CASE_COUNT]
            random.shuffle(pics)
            for pic in pics:
                fp.write(pic)

        sim_pic = sim_pic[:CASE_COUNT]
        for item in sim_pic:
            fp.write(item)

        bad_bg = bad_bg[:CASE_COUNT]
        for item in bad_bg:

            fp.write(item)

        bad_size = bad_size[:CASE_COUNT]
        for item in bad_size:
            fp.write(item)

        fp.close()

    sendEmail(TABLE_NAME, COLUMN_NAME, dev)

    exit(0)
예제 #5
0
def ecardhook(etype, message, obj):

    msg = ''
    #Exception when a card file cannot be found
    if (str(etype) == "exceptions.IOError"):
        msg = "The item you requested could not be found.(1: IOError)"

    #Exception when a greeting card category cannot be found
    if (str(etype) == "exceptions.TypeError"):
        msg = "The item you requested could not be found.(2: TypeError)"

    #Exception on the edit page when a card category is not found
    if (message == None):
        msg = "The item you requested could not be found.(3)"

    #Exception when someone enters bad data in a url
    if (str(etype) == "exceptions.ValueError"):
        msg = "An unexpected error has occurred."

    # traceback.print_exception(etype, message, obj)

    body = '''
<table width="600" border="0">
<tr><td width="10%">&nbsp;
<th align="LEFT">
<h1>Error</h1>
&nbsp;
<p>We apologize, but you have encountered an unexpected error<br>
&nbsp;
<p>The error has been logged with YakJive.com and we will investigate<br>
as soon as possible.  Please <a href="''' + APPLICATION.startPage + '''">click here</a> to return to<br>
your start page.<br>
&nbsp;
<p>If you continue to encounter the error, please<br>
<a href="http://www.yakjive.com/yjcontact.html">contact us immediately</a> to indicate<br>
that your site is experiencing technical difficulties.<br>
&nbsp;
<p>We are sorry for any incovenience.  Thank you for using YakJive.com.
</table>
'''

    emailBody = msg + '<br>&nbsp;<br>\n'

    data = traceback.format_tb(obj)

    for item in data:
        emailBody += str(item).replace('\n', '<br>') + '<br>\n'
    emailBody += str(etype) + '<br>\n'
    emailBody += str(message) + '<br>\n'

    emailDict = dict()
    emailDict['error'] = emailBody
    emailDict['domain'] = APPLICATION.domainName
    # TODO: Soft-code the email addresses somewhere
    emailDict['fromEmail'] = '*****@*****.**'
    emailDict['toEmail'] = '*****@*****.**'
    emailDict[
        'subject'] = 'YakJive Exception -- ' + APPLICATION.domainName + ': ' + str(
            etype)
    emailBody = readTextFile(FILENAME_EMAIL_ERROR, False, emailDict)

    if (GLOBAL_DEBUG):
        body += emailBody

    try:
        sendEmail(emailDict['fromEmail'], emailDict['toEmail'], email)
    except:
        # don't keep throwing exceptions
        # TODO: Log this condition
        pass

    replaceDict = {'userWelcome': ''}
    printConsolePage(body, replaceDict)
        
        num_11=data_dict_send['28']['id_send_sim_count_pgc']
        num_30=data_dict_send['30']['id_send_sim_count_pgc']
	sim_count_pgc_rd=sum(map(lambda x:x[1]['id_send_sim_count_pgc'],data_dict_send.items()))
	f.write('<tr><td>去重后sim_video字段个数</td><td><font color="#3300FF">{}</font></td><td><font color="#3300FF">{}</font></td><td><font color="#3300FF">{}</font></td></tr>'.format(sim_count_pgc_rd,num_30,num_11))
        for one in video_type:
  #              data_dict_send['26']['has_sim_video_dict'][one]
            video_type_dict_pgc=sum(map(lambda x:x[1]['has_sim_video_dict'][one],data_dict_send.items()))
            num_11=data_dict_send['28']['has_sim_video_dict'][one]
            num_30=data_dict_send['30']['has_sim_video_dict'][one]
            f.write("<tr bgcolor=#ADADAD><td align='center'>{}</td><td>{}</td><td>{}</td><td>{}</td></tr>".format(one, video_type_dict_pgc,num_30,num_11))
        f.write('</table>')
        

	f.write('<br/>')#空一行
	
        f.write("<font color='#FF0000'>sim_video:</font>")
	sim_video=[]
	for host in hosts:
                if len(data_dict_send[host]['sim_video_list_pgc'])>0:
		    sim_video=list(set(data_dict_send[host]['sim_video_list_pgc']+sim_video))
	f.write('<br/>{}'.format(json.dumps(sim_video[:PRINT_COUNT])))

	f.close()

	sendEmail(dev)	
	#sendEmail(True)	
	
	print 'end'
        exit(0)
예제 #7
0
fail = 0
failCPU = 0

# Se actualiza la bd con valores de [0, 1000] ms cada segundo.
while True:
    ping_time = ping(hostname)

    if ping_time == -1:
        ping_time = 1.0
        fail = fail + 1
    else:
        fail = 0
        cpu = getCPU(hostname)

        if cpu > 0.5:
            failCPU = failCPU + 1
        else:
            failCPU = 0

    rrdtool.update(fname, 'N:%d' % ping_time)

    # Send email after 3 seconds of not ping.
    if fail == 3:
        sendEmail(hostname, 1)

    # send email after 3 second of CPU eigher
    if failCPU == 3:
        sendEmail(hostname, 2)

    time.sleep(1)