Ejemplo n.º 1
0
def main():
    """
    """
    todays_temperature: int = 0
    tommorows_temperature: int = 0
    subject_error: str = ''
    error_text: str = ''

    owm = pyowm.OWM(default.TOKEN)
    detailed_report = owm_work.get_tomorrows_avg_temp(owm, default.COORD_X,
                                                      default.COORD_Y)
    tommorows_temperature = mean([
        row[len(row) - 1]['temp'] for row in detailed_report
    ])  # calculates avg temp for tommorow
    detailed_report = pformat(detailed_report)

    todays_temperature = owm_work.get_todays_avg_temp(owm, default.COORD_X,
                                                      default.COORD_Y)

    # if abs(tommorows_temperature - todays_temprature) > (todays_temprature/100)*15:                                                     # difference in more than 15%//4 degrees
    subject = f'Subject: TEMP DIFF {todays_temperature} vs {tommorows_temperature}' + subject_error
    message = subject_error + f'Tommorow\'s weather:\n{detailed_report}\n' + error_text
    send_mail.send_mail(login=default.SMTP_SEND_FROM,
                        password=default.SMTP_PASSWORD,
                        send_to=[default.SMTP_SEND_TO],
                        subject=subject,
                        message=message)
Ejemplo n.º 2
0
def mail_result(event):
    '''
    Sending TXT(result) file
    '''
    from modules.send_mail import send_mail
    from modules.conf_fetcher import fetcher

    a = fetcher() #take a dict with conf setting
    
    a ['files'] = [tmp]

    send_mail(**a)

    tex.delete(1.0, END)
    tex.insert(END, 'Результат сохранен во временный файл ')
    tex.insert(END, 'tmp/tmp_file.txt')
    tex.insert(END, ' и отправлен по почте')
Ejemplo n.º 3
0
def mail_source(event):
    '''
    Sending EXCEL(source) file
    '''
    from modules.send_mail import send_mail
    from modules.conf_fetcher import fetcher
  
    a = fetcher() #take a dict with conf setting
    if open_file:
        a ['files'] = [open_file]
 
    send_mail(**a)

    tex.delete(1.0,END)
    tex.insert(END,'Файл ')
    tex.insert(END, open_file)
    tex.insert(END, ' отправлен')
Ejemplo n.º 4
0
def mail_result(event):
    '''
    Sending TXT(result) file
    '''
    from modules.send_mail import send_mail
    from modules.conf_fetcher import fetcher

    a = fetcher()  #take a dict with conf setting

    a['files'] = [tmp]

    send_mail(**a)

    tex.delete(1.0, END)
    tex.insert(END, 'Результат сохранен во временный файл ')
    tex.insert(END, 'tmp/tmp_file.txt')
    tex.insert(END, ' и отправлен по почте')
Ejemplo n.º 5
0
def mail_source(event):
    '''
    Sending EXCEL(source) file
    '''
    from modules.send_mail import send_mail
    from modules.conf_fetcher import fetcher

    a = fetcher()  #take a dict with conf setting
    if open_file:
        a['files'] = [open_file]

    send_mail(**a)

    tex.delete(1.0, END)
    tex.insert(END, 'Файл ')
    tex.insert(END, open_file)
    tex.insert(END, ' отправлен')
Ejemplo n.º 6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
The purpose of the programm is to organize some repeatedly job's.
This python program allows us to send a mail with included files.
Now, this program calculate the current date and include to mail
file which contain yesterday's date.
It's can send mail to diff recipients and CC recipients(config in 
conf/base.cfg file).
But this program not universal now, it's for my use.
Program alow to use some open smtp sever.
Work on python 2.7
"""
from modules.send_mail import send_mail
from modules.conf_fetcher import fetcher

if __name__ == "__main__":
    a = fetcher() #take a dict with conf setting
    send_mail(**a)