Advertisement
Guest User

Untitled

a guest
Apr 24th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. while time == 0600:
  2. send my mail etc
  3.  
  4. import smtplib, pywapi, datetime
  5. weather = True
  6. loopmsg = True
  7. loopmsg1 = True
  8. def send():
  9. loopmsg = True
  10. loopmsg1 = True
  11. global weather
  12. while weather == True:
  13. if loopmsg == True:
  14. print('Initial Loop Initiated')
  15. loopmsg = False
  16. time = datetime.datetime.now()
  17. time = str(time)
  18. time = time[11:]
  19. time = time[:-10]
  20. time = time.replace(":", "")
  21. time = int(time)
  22. fromaddr = 'xxx'
  23. toaddrs = 'xxx'
  24. while time == 0600:
  25. print('Time is correct')
  26. weather_com_result = pywapi.get_weather_from_weather_com('ASXX0075')
  27. msg = "It is " + weather_com_result['current_conditions']['text'].lower() + " and " + weather_com_result['current_conditions']['temperature'] + "°C in Your City."
  28. msg = msg.encode('utf-8')
  29.  
  30. # Credentials (if needed)
  31. username = 'xxx'
  32. password = 'xxx'
  33.  
  34. # The actual mail send
  35. server = smtplib.SMTP('smtp.gmail.com:587')
  36. server.starttls()
  37. server.login(username,password)
  38. server.sendmail(fromaddr, toaddrs, msg)
  39. server.quit()
  40. print('Sent')
  41. #weather = False
  42.  
  43. #while weather == False:
  44. # if loopmsg1 == True:
  45. # print('Second Loop Initiated')
  46. # loopmsg1 = False
  47. # while time > 0600:
  48. # send()
  49.  
  50. send()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement