예제 #1
0
파일: logic.py 프로젝트: Yelp/PushmasterApp
def set_request_checkedin(request):
    assert request.state == 'accepted'
    push = request.push
    assert push

    request.state = 'checkedin'

    request.put()
    push.bust_requests_cache()

    util.send_mail(
        to=[push.owner.email(), config.mail_to],
        subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
        body='Changes are checked in.\n' + config.url(push.uri))

    im_fields = dict(

        )
    util.send_im(
        to=request.owner.email(),
        message='Changes for <a href="%(request_uri)s">%(request_subject)s</a> are checked into <a href="%(push_uri)s">%(push_name)s</a>.',
        request_uri=config.url(request.uri),
        request_subject=request.subject,
        push_name=push.name or 'the push',
        push_uri=config.url(push.uri),
        )

    return request
def send_email(env_status, file=[], admin_list=[]):

    header = "<head><style> table, th, td { border: 1px solid black; border-collapse: collapse; padding: 5px; } " \
              "th { font-weight: bold; text-align: left; background-color: #c8cbd1; } " \
              "th, td { padding: 10px; }</style></head>"

    table = '<table><thead><tr><th>Environment</th><th>Status</th></tr></thead><tbody>'
    for env, status in env_status.items():
        table = table + '<tr><td>' + env + '</td><td>'
        table = table + ('<b style="color:Red">' + status +
                         '</b>') if status in ('Down',
                                               'Old Data') else table + status
        table = table + '</td></tr>'
    table = table + '</table>'

    msg = "Good Morning,<br><br>"
    msg = msg + "Below is the status of all Stingray environments: <br><br>" + table
    msg = msg + "<br><br>Thank you,<br>Stingray IT"
    email = header + msg

    util.send_mail(
        config.get('email', 'smtp_host'), config.get('email', 'smtp_user'),
        config.get('email', 'smtp_pwd'), from_address, to_list, admin_list,
        "Stingray Daily Environment Check for " + t.strftime("%m/%d"), email,
        file, 'html')
    return True
예제 #3
0
파일: logic.py 프로젝트: Yelp/PushmasterApp
def reject_request(request, rejector, reason=None):
    push = request.push

    request.push = None
    request.state = 'rejected'
    if reason:
        request.reject_reason = reason

    request.put()
    query.bust_request_caches()
    if push is not None:
        push.bust_requests_cache()

    util.send_im(
        to=request.owner.email(),
        message='<a href="mailto:%(rejector_email)s">%(rejector_name)s</a> rejected your request <a href="%(request_uri)s">%(request_subject)s</a>: %(reason)s',
        rejector_email=rejector.email(),
        rejector_name=user_info(rejector).full_name,
        request_subject=request.subject,
        request_uri=config.url(request.uri),
        reason=reason,
        )

    util.send_mail(
        to=[request.owner.email(), config.mail_to, config.mail_request],
        subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
        body="""This request was rejected.\n\n%s\n\n%s""" % (reason, config.url(request.uri)),
        )

    return request
예제 #4
0
    def run(self, verbose=False):
        """
        Main entry point.
        """
        warnings, criticals = self.check_limits(verbose=verbose)
        # output
        if len(warnings) > 0:
            print("\nWARNING:\n")
            for w in warnings:
                print(w)
        if len(criticals) > 0:
            print("\nCRITICAL:\n")
            for c in criticals:
                print(c)

        # alerts
        if len(warnings) > 0:
            body = '\n'.join(warnings)
            send_mail(EMAIL_SUBJECT_WARNING, body, [EMAIL_TO_WARNING])

        if len(criticals) > 0:
            body = '\n'.join(criticals)
            send_mail(EMAIL_SUBJECT_CRITICAL, body, [EMAIL_TO_CRITICAL])

        # summary
        if len(warnings) > 0 or len(criticals) > 0:
            print(
                "\n{c} limit(s) above CRITICAL threshold; {w} limit(s) above "
                "WARNING threshold".format(c=len(criticals), w=len(warnings)))
        else:
            print("All limits are within thresholds.")
예제 #5
0
def send_status_email(running_tasks, failed_tasks):

    header = "<head><style> table, th, td { border: 1px solid black; border-collapse: collapse; padding: 5px; } " \
              "th { font-weight: bold; text-align: left; background-color: #c8cbd1; } " \
              "th, td { padding: 10px; }</style></head>"

    running_table = '<table><thead><tr><th>Task</th><th>Status</th></tr></thead><tbody>'
    for task, status in running_tasks.items():
        running_table = running_table + '<tr><td>' + task + '</td><td>' + status + '</td></tr>'
    running_table = running_table + '</table>'

    failed_table = '<table><thead><tr><th>Task</th><th>Status</th></tr></thead><tbody>'
    for task, status in failed_tasks.items():
        failed_table = failed_table + '<tr><td>' + task + '</td><td>' + '<b style="color:Red">' + status + '</b></td></tr>'
    failed_table = failed_table + '</table>'

    msg = "Good Morning,<br><br>"
    msg = msg + "Below is the list of tasks still running in Stingray production:<br><br>" + running_table
    if len(failed_tasks) != 0:
        msg = msg + "<br><br>Below is the list of tasks that failed in Stingray production:<br><br>" + failed_table
    msg = msg + "<br><br>Thank you,<br>Stingray IT"
    email = header + msg

    util.send_mail(
        config.get('email', 'smtp_host'), config.get('email', 'smtp_user'),
        config.get('email', 'smtp_pwd'), from_address, to_list, cc_list,
        "Stingray Daily Production Check for " + t.strftime("%m/%d"), email,
        [], 'html')
예제 #6
0
파일: logic.py 프로젝트: Yelp/PushmasterApp
def send_request_mail(request):
    body = [request.message or request.subject]
    body.append(config.url(request.uri))

    util.send_mail(
        to=[request.owner.email(), config.mail_to, config.mail_request],
        subject='%s: %s' % (request.owner.nickname(), request.subject),
        body='\n'.join(body))
예제 #7
0
def remail(gifter, contactsfile, cyclefile):
    'Remail a specific gifter their gift recipient'
    contacts = util.parse_contacts(contactsfile)
    cycle = util.parse_cycle(cyclefile)
    cycle_dict = util.cycle_as_dict(cycle)
    gifter_info = contacts[gifter]
    recipient_info = contacts[cycle_dict[gifter]]
    util.send_mail(gifter_info, recipient_info)
    print('Mailed to', gifter)
예제 #8
0
def mail(contactsfile, cyclefile):
    'Mail all participants in cyclefile using their email in contactsfile'
    contacts = util.parse_contacts(contactsfile)
    cycle = util.parse_cycle(cyclefile)
    for gifter, gift_recipient in util.cycle_as_dict(cycle).items():
        gifter_info = contacts[gifter]
        recipient_info = contacts[gift_recipient]
        util.send_mail(gifter_info, recipient_info)
	print('Mailed to', gifter)
예제 #9
0
def send_failure_email(file=[]):
    util.send_mail(smtp_host, smtp_user, smtp_pwd,
        from_address, dev_list, [],
        "Production check failed",
        "Good morning,\n\n" \
            + "Note: Production check failed. Please check the attached log file and take action if needed " \
            + "The process will check in 60 mins and send a status if successful \n\n" \
            + "Thank you, Stingray IT",
        file
    )
def send_failure_email(file=[]):
    util.send_mail(config.get('email', 'smtp_host'), config.get('email', 'smtp_user'), config.get('email', 'smtp_pwd'),
        from_address, dev_list, [],
        "Stingray Daily Environment Check failed",
        "Good morning,\n\n" \
            + "Note: Stingray Daily environment check failed. Please check the attached log file and take action if needed " \
            + "The process will try in 60 mins and send a status if successful \n\n" \
            + "Thank you, Stingray IT",
        file
    )
예제 #11
0
def send_report_email(file):
    subject_suffix = (date.today() - timedelta(1)).strftime("%m/%d/%Y")
    util.send_mail(smtp_host, smtp_user, smtp_pwd,
        from_address, to_list, cc_list,
        "Stingray Daily Claims report - " + subject_suffix,
        "Good morning,\n\n" \
            + "Please find attached daily open/closed/reopen claims report from Stingray for " \
            + subject_suffix + ".\n\nThank you, Stingray IT",
        [file]
    )
예제 #12
0
def send_email_dwh_not_current(file=None):
    util.send_mail(smtp_host, smtp_user, smtp_pwd,
        from_address, dev_list, [],
        "DWH is not current to send Daily Claims Report",
        "Good morning,\n\n" \
            + "Note: DWH is not current with latest data to send daily claims report. " \
            + "The process will check in 60 mins and send the report if the DB is refreshed\n\n" \
            + "Thank you, Stingray IT",
        [file]
    )
예제 #13
0
	def send_alert(self, alert):
		""" This will take the alert and mail it """

		send_alert_result = util.send_mail(self.settings.smtp_server, self.settings.smtp_user, self.settings.smtp_password, self.settings.smtp_port, [self.settings.alert_to], self.settings.alert_from, alert["subject"], alert["body_text"], alert["body_html"], [])
		if send_alert_result:
			log('Alert email sent! (Subj: %s)' % alert['subject'])
		return send_alert_result
예제 #14
0
    def create(self, validated_data):
        user = User(**validated_data)

        user.is_groomer = True
        user.is_active = True
        user.set_password(validated_data['password'])
        user.generate_activation_key()
        user.save()

        # create user token for rest authentication
        Token.objects.create(user=user)

        # send email
        send_mail("Welcome to Appetments!", "Thank you for signing up to Appetments! Follow the <a href='http://"
                                            "localhost:8000/verify-email?token={}'>link</a> to verify your account".
                  format(user.activation_key), user.email)
        return user
예제 #15
0
    def send_alert(self, alert):
        """ This will take the alert and mail it """

        send_alert_result = util.send_mail(
            self.settings.smtp_server, self.settings.smtp_user,
            self.settings.smtp_password, self.settings.smtp_port,
            [self.settings.alert_to], self.settings.alert_from,
            alert["subject"], alert["body_text"], alert["body_html"], [])
        if send_alert_result:
            log('Alert email sent! (Subj: %s)' % alert['subject'])
        return send_alert_result
예제 #16
0
파일: logic.py 프로젝트: Yelp/PushmasterApp
def withdraw_request(request):
    assert request.state in ('accepted', 'checkedin', 'onstage', 'tested')
    push = request.push
    assert push
    assert request.push.state in ('accepting', 'onstage')

    push_owner_email = request.push.owner.email()
    request.push = None
    request.state = 'requested'

    request.put()
    query.bust_request_caches()
    push.bust_requests_cache()

    util.send_mail(
        to=[push_owner_email, config.mail_to, config.mail_request],
        subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
        body='I withdrew my request.\n' + config.url(request.uri))

    return request
예제 #17
0
파일: logic.py 프로젝트: Yelp/PushmasterApp
def set_request_tested(request, bust_caches=True):
    assert request.state == 'onstage'
    push = request.push
    assert push

    request.state = 'tested'
    request.put()

    if bust_caches:
        push.bust_requests_cache()

    push_owner_email = push.owner.email()

    util.send_mail(
        to=[push_owner_email, config.mail_to],
        subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
        body='Looks good to me.\n' + config.url(push.uri))

    if all(request.state == 'tested' for request in query.push_requests(push)):
        util.send_im(push_owner_email, 'All changes for <a href="%s">the push</a> are verified on stage.' % config.url(push.uri))

    return request
예제 #18
0
파일: logic.py 프로젝트: Yelp/PushmasterApp
def send_to_stage(push, stage):
    assert push.state in ('accepting', 'onstage')
    assert stage in model.Push.all_stages

    checkedin_requests = query.push_requests(push, state='checkedin')
    if checkedin_requests:
        if push.state != 'onstage' or push.stage != stage:
            push.state = 'onstage'
            push.stage = stage

            push.put()
            query.bust_push_caches()

        for request in checkedin_requests:
            request.state = 'onstage'
            owner_email = request.owner.email()

            util.send_mail(
                to=[owner_email, config.mail_to],
                subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
                body=('Please verify your changes on %s.\n%s' % (push.stage, config.url(push.uri)))
                )

            util.send_im(
                to=owner_email,
                message='<a href="mailto:%(pushmaster_email)s">%(pushmaster_name)s</a> requests that you verify your changes on %(stage)s for <a href="%(push_uri)s">%(request_subject)s</a>.',
                pushmaster_email=push.owner.email(),
                pushmaster_name=user_info(push.owner).full_name,
                request_subject=request.subject,
                push_uri=config.url(push.uri),
                stage=push.stage,
                )
            request.put()

        push.bust_requests_cache()

    return push
예제 #19
0
 def post(self):
     email_user = cgi.escape(self.request.get('email_from'))
     email_subject = cgi.escape(self.request.get('email_subject'))
     email_message = cgi.escape(self.request.get('email_message'))
     message = util.send_mail(email_user, email_subject, email_message)
     self.generate('contact.html', {'message': message})
예제 #20
0
 # -*- coding: utf-8 -*-
예제 #21
0
# -*- coding: utf-8 -*-
예제 #22
0
 def post(self):
     email_user = cgi.escape(self.request.get('email_from'))
     email_subject = cgi.escape(self.request.get('email_subject'))
     email_message = cgi.escape(self.request.get('email_message'))
     message = util.send_mail(email_user, email_subject, email_message)
     self.generate('contact.html', {'message': message})
예제 #23
0
# -*- coding: utf-8 -*-
예제 #24
0
def send_daily_push_report_mail(report):
    util.send_mail(
        to=['*****@*****.**'],
        subject='Daily Push Report Mail for %s' % util.tznow().date().strftime('%Y-%m-%d'),
        body='\n'.join(report))
예제 #25
0
	def send_log(self):
		if self.debug_mode is False:
			send_mail(email=self.gmail_username, password=self.gmail_pw, message=self.TEXT_LOG)
		else:
			print(self.TEXT_LOG)
		self.clear_log()
            excel_obj.write_cell_value(
                int(test_step_row[test_case_id_col_no].value) + 1,
                test_case_result_col_no, "")

            excel_obj.set_sheet_by_name(
                test_step_row[test_case_sheet_name].value)
            test_step_rows = excel_obj.get_rows_object()[1:]
            for test_step_row in test_step_rows:
                if test_step_row[test_step_id_col_no].value is None:
                    continue
                excel_obj.write_cell_value(
                    int(test_step_row[test_step_id_col_no].value) + 1,
                    test_step_result_col_no, "")
                excel_obj.write_cell_value(
                    int(test_step_row[test_step_id_col_no].value) + 1,
                    test_step_error_info_col_no, "")
                excel_obj.write_cell_value(
                    int(test_step_row[test_step_id_col_no].value) + 1,
                    test_step_capture_pic_path_col_no, "")


if __name__ == "__main__":
    # 24.遍历执行所有测试用例
    test_data_excel_file_path = ProjDirPath + "\\test_data\\testdata.xlsx"
    for test_case_sheet in get_test_case_sheet(test_data_excel_file_path):
        execute(test_data_excel_file_path, test_case_sheet[0],
                test_case_sheet[1])
    # clear_test_data_file_info(test_data_excel_file_path)
    from util.send_mail import *
    send_mail()
예제 #27
0
    trainer = pl.Trainer(
        gpus=opt[GPU],
        distributed_backend='dp',
        # auto_select_gpus=True,
        max_epochs=opt[NUM_EPOCH],
        logger=mylogger,
        callbacks=[checkpoint_callback],
        precision=opt[RUNTIME_PRECISION],
        check_val_every_n_epoch=opt[VALID_EVERY])

    # training loop
    global OPT
    OPT = copy.deepcopy(opt)
    trainer.fit(model, trainloader, val_dataloaders=valid_loader)


if __name__ == "__main__":
    try:
        main()
        import pprint

        content = pprint.pformat(OPT, indent=4)
        send_mail(f'[ DONE ] Training finished: {OPT[NAME]}',
                  f'[ ARGS ] \n{content}')

    except Exception as e:
        console.print_exception()
        # server_chan_send('[Exception] Training stop.', str(e))
        send_mail('[ ERR ] Training stop by exception.',
                  str(traceback.format_exc()))
예제 #28
0
def main():
    table = "video_advertiser"
    domain_table = "domain_master"
    url_table = "url_master"
    total_links = 0
    total_urls = 0
    display = None
    driver = None
    cursor = None
    #main code starts
    starttime = 'Start Time : %s' % (mx.DateTime.now())
    print starttime

    s1time = mx.DateTime.now().strftime("%Y-%m-%d %H:%M:%S")
    try:

        from pyvirtualdisplay import Display
        display = Display(visible=0, size=(1000, 900))
        display.start()
    except:
        print 'No Xvfb!'
    driver = webdriver.Chrome()
    inttime = int(mx.DateTime.now())
    stime = 'Start Time : %s' % (mx.DateTime.now())
    sql = """SELECT a.urlid,a.domainid,a.url,b.domain FROM %s as a join %s as b 
    using (domainid)""" % (url_table, domain_table)
    if not cursor:
        cursor = util.cursor_define()
    cursor.execute(sql)
    urls = cursor.fetchall()
    total_urls += len(urls)
    num_urls_processed = "Total number of urls to be processed %s" % len(urls)
    print num_urls_processed
    for (
            domainid,
            urlid,
            url_link,
            domain,
    ) in urls:
        total_links = video_crawl(driver, domainid, urlid, url_link, domain,
                                  inttime, table, total_links)

    print "Fetching Completed"
    endtime = 'End Time : %s' % (mx.DateTime.now())
    e1time = mx.DateTime.now().strftime("%Y-%m-%d %H:%M:%S")
    d1 = datetime.datetime.strptime(s1time, '%Y-%m-%d %H:%M:%S')
    d2 = datetime.datetime.strptime(e1time, '%Y-%m-%d %H:%M:%S')
    ttime = "Total time to crawl:%s" % str(d2 - d1)
    print endtime
    total_num_urls_processed = "Total number of links processed %s" % total_links
    #set filename for csv
    filename = './csv_folder/video_advertiser_%s.csv' % (str(
        mx.DateTime.now().strftime("%Y_%m_%d_%H_%M_%S")))
    sql = """select a.domain as src_domain,c.advertiser as advertiser_domain,count(c.advertiser) 
    as advertiser_per_domain from domain_master a,url_master b,%s c where a.domainid=b.domainid 
    and b.domainid=c.domainid and c.datetime_run=%s and c.advertiser is not null group by a.domain,
    c.advertiser""" % (table, inttime)

    util.create_csvfile(sql, filename, cursor)
    util.send_mail("Video Advertisers", total_num_urls_processed, starttime,
                   endtime, ttime, filename)

    try:
        if cursor:
            cursor.close()
    except:
        pass

    # Browser close.
    if driver:
        driver.quit()
    if display:
        display.stop()

    try:
        cmd = """ps -ef | grep -v grep | grep 'screen 0 %sx%sx24' | awk '{print $2}' | 
        xargs kill -9""" % (1000, 900)
        os.system(cmd)
    except:
        traceback.print_exc()
예제 #29
0
                                        sb["data"])["data"]["uri"]

                                    email_str = util.html_format(
                                        time.strftime(
                                            "%Y-%m-%d %H:%M:%S",
                                            time.localtime(int(time.time()))),
                                        "签到和表单提交成功", share_url,
                                        json.loads(reason)["Address"])

                                    util.log(
                                        time.strftime(
                                            "%Y-%m-%d %H:%M:%S",
                                            time.localtime(int(time.time()))) +
                                        " 签到和表单提交成功 url: " + share_url + "\n")

                                    util.send_mail(email_str)
                                elif sb["code"] == 0 and night_s["code"] != 0:
                                    print("表单提交成功!但是签到没成功")
                                    share_url = yiban.getShareUrl(
                                        sb["data"])["data"]["uri"]

                                    email_str = util.html_format(
                                        time.strftime(
                                            "%Y-%m-%d %H:%M:%S",
                                            time.localtime(int(time.time()))),
                                        "表单提交成功!但是签到没成功!", share_url, "签到没成功")

                                    util.log(
                                        time.strftime(
                                            "%Y-%m-%d %H:%M:%S",
                                            time.localtime(int(time.time()))) +
예제 #30
0
                  'In order to stay up-to-date with the latest club news, ' \
                  'we recommend you either subscribe to our email newsletter, RSS feed, or follow us on Twitter.</p>' \
                  '<table>' \
                        '<tr>' \
                            '<td>Email Newsletter:</td>' \
                            '<td><a href="http://feedburner.google.com/fb/a/mailverify?uri=UBCBadmintonClub&amp;loc=en_US">subscribe</a></td>' \
                        '</tr>' \
                        '<tr>' \
                            '<td>RSS:</td>' \
                            '<td><a href="http://ubcbadm.vlexofree.com/feed/">subscribe</a></td>' \
                        '</tr>' \
                        '<tr>' \
                            '<td>Twitter:</td>' \
                            '<td><a href="http://twitter.com/ubcbadm">http://twitter.com/ubcbadm</a></td>' \
                        '</tr>' \
                  '</table>'

            util.send_mail(fromAddr,
                  member.email, 
                  '[UBC Badm] Welcome ' + member.firstName + '!',
                  msgBody)

application = webapp.WSGIApplication(   [('/member', MemberView)],
                                        debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
예제 #31
0
 def email_user(self, subject, message, from_email=None, **kwargs):
     """
     Sends an email to this User.
     """
     send_mail(subject=subject, message=message, to=self.email)
예제 #32
0
 # -*- coding: utf-8 -*-
예제 #33
0
 # -*- coding: utf-8 -*-