Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while time == 0600:
- send my mail etc
- import smtplib, pywapi, datetime
- weather = True
- loopmsg = True
- loopmsg1 = True
- def send():
- loopmsg = True
- loopmsg1 = True
- global weather
- while weather == True:
- if loopmsg == True:
- print('Initial Loop Initiated')
- loopmsg = False
- time = datetime.datetime.now()
- time = str(time)
- time = time[11:]
- time = time[:-10]
- time = time.replace(":", "")
- time = int(time)
- fromaddr = 'xxx'
- toaddrs = 'xxx'
- while time == 0600:
- print('Time is correct')
- weather_com_result = pywapi.get_weather_from_weather_com('ASXX0075')
- msg = "It is " + weather_com_result['current_conditions']['text'].lower() + " and " + weather_com_result['current_conditions']['temperature'] + "°C in Your City."
- msg = msg.encode('utf-8')
- # Credentials (if needed)
- username = 'xxx'
- password = 'xxx'
- # The actual mail send
- server = smtplib.SMTP('smtp.gmail.com:587')
- server.starttls()
- server.login(username,password)
- server.sendmail(fromaddr, toaddrs, msg)
- server.quit()
- print('Sent')
- #weather = False
- #while weather == False:
- # if loopmsg1 == True:
- # print('Second Loop Initiated')
- # loopmsg1 = False
- # while time > 0600:
- # send()
- send()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement