コード例 #1
0
ファイル: main.py プロジェクト: wixenius/upload
def main():
    mail = emailer(EMAIL_ADDRESS, EMAIL_PASSWORD, SECRET_STRING)
    if mail.getNbrOfUnseen() > 0:
        mail.parseMsg()


    mail.logOut()
コード例 #2
0
ファイル: safecgi.py プロジェクト: ryanlowe0/misc-python
def run(func, *args, **kwargs):
    conf = res.conf
    
    if conf.get("cgi", {}).get("errors_on_screen", False):
        cgitb.enable()
        return func(*args, **kwargs)
    
    try:
        return func(*args, **kwargs)        
    except Exception, e:
        
        # Send traceback in an email to conf.cgi.error_waters
        import emailer
        system_name = conf.get("system", {}).get("name", "Undefined")
        if 'REMOTE_USER' in os.environ:
            system_name = '%s: %s' % (system_name, os.environ['REMOTE_USER'])
        email = conf.get("cgi", {}).get("error_watchers",
                                        ["*****@*****.**"])
        filename = os.path.basename(sys.argv[0])
        emailer.emailer(emailTo=email,
                        emailFrom='*****@*****.**',
                        emailSubject='PLANT_ERROR: %s: %s: %s' % \
                           (system_name, filename, str(e)[:40]),
                        emailHtml=cgitb.html(sys.exc_info()),
                        emailText=cgitb.text(sys.exc_info()))

        # display message to user.
        logo = "<img src='images/mypub_logo.jpg'/>"
        button = '<a href="javascript:back()">GO BACK</a>'
        msg = markup('''
        An Unexpected Error Occurred: !%s!
        Details have been sent to %s

        ''' % (e, email))
        error_page = """
        <table style='border: 0' width='100%%' border='0'>
          <tr>
             <td style='border: 0;' width='30px' valign='top'>%s</td>
             <td style='border: 0;'>%s</td>
          </tr>
        </table>""" % (logo, msg) + button
        return HTML(msg=error_page)
コード例 #3
0
def launch_reports():
    clean_folder()
    sklad_report = get_report(sklad, sklad_params, 'sklad')
    time.sleep(3)
    sales_report = get_report(sales, sales_params, 'sales')
    time.sleep(3)
    orders_report = get_report(orders, orders_params, 'orders')
    time.sleep(3)
    postavki_report = get_report(postavki, postavki_params, 'postavki')
    try:
        print(f'call to emailer')
        emailer(from_email, from_email_pass, to_emails, sklad_report,
                sales_report, orders_report, postavki_report)
    except:
        print('smth went wrong')
        error_emailer(
            from_email,
            from_email_pass,
            to_emails,
        )

    clean_folder()  # cleaning workfolder
コード例 #4
0
ファイル: main.py プロジェクト: gnarph/Partner-Search
def doMatching(danceClub):
    ## Make the matches and print them in the console
    danceClub.makeMatches()
    danceClub.printMatches()   
    
    userInput = raw_input("Would you like to send emails at this time? (yes/no): ")
    if userInput.lower() == "yes":
        userInput = raw_input("Are you sure? (yeah, nope): ")
        
        if userInput.lower() == "yeah":
            # Setup the emailer and send out the emails
            mailer = emailer.emailer()
            danceClub.sendEmails(mailer)
            mailer.quitEmail()
            print("Done!")
コード例 #5
0
def doMatching(danceClub):
    ## Make the matches and print them in the console
    danceClub.makeMatches()
    danceClub.printMatches()

    userInput = raw_input(
        "Would you like to send emails at this time? (yes/no): ")
    if userInput.lower() == "yes":
        userInput = raw_input("Are you sure? (yeah, nope): ")

        if userInput.lower() == "yeah":
            # Setup the emailer and send out the emails
            mailer = emailer.emailer()
            danceClub.sendEmails(mailer)
            mailer.quitEmail()
            print("Done!")
コード例 #6
0
        if 0 < c:
            if c < 40:
                tilausnumero = tilausnumero + str(HIDconverter(c))
            elif c == 40:
                print("break")
                break

#Excelin avaus sälää, polku ja kopio sheetistä
    polku = '/home/lehmik/Documents/testi.xlsx'
    filu = xlrd.open_workbook(os.path.join(polku))
    p = filu.sheet_names()
    wb = copy(filu)
    wb_sheet = wb.get_sheet(0)
    #Haetaan excelistä löytyykö viivakoodia vastaavaa tilausnumeroa, jos löytyy potkaistaan yläällä oleva selainfunktio, erillisenä oleva sähköpostin lähetys ja
    #exceliin kirjoitus käyntiin. Lopputuloksena exceliin päivittyy tilauksen saapumispäivä, selain avaa tilausta vastaavan tiketin ja lähetetään maili asiasta asiakkaalle.
    for y in p:
        sh = filu.sheet_by_name(y)
        for rownum in range(sh.nrows):
            if rownum != 0:
                if int(tilausnumero) == int(sh.row_values(rownum)[2]):
                    date = str(datetime.date.today().day) + "." + str(
                        datetime.date.today().month) + "." + str(
                            datetime.date.today().year)
                    wb_sheet.write(rownum, 5, date)
                    wb.save(os.path.join(polku))
                    selain(str(sh.row_values(rownum)[3]))
                    emailer("Tietokoneen saapumisilmoitus",
                            "Tilauksesi on saapunut,asennellaan kun keritään",
                            secret.email, secret.emailpwd,
                            "*****@*****.**")
コード例 #7
0
        try:
            data = future.result()

            if i % 500 == 0:
                time_diff = datetime.now() - start_time
                logger.info(
                    f"Parsing url #: {i} {datetime.now().strftime('%m-%d-%Y %H:%M:%S')} (Total time taken: {time_diff.seconds} seconds)"
                )

            parse_data(data)

        except Exception as exc:
            logger.warning(
                f'{future_to_url[future]} {future.result()} url generated an exception: {exc}'
            )

if (connect().open):
    try:
        cur.execute(
            f"UPDATE etl_control_status set LOAD_STATUS = 'C', LOAD_DATE = '{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}'"
        )
        mydb.commit()
        cur.close()
        mydb.close()
        logger.info("MySQL connection is closed")
    except Exception as exc:
        logger.warning(exc)

logger.info("Download successful, sending emailer...")
emailer(logger)