Advertisement
Guest User

Untitled

a guest
Aug 28th, 2017
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. File "error.py", line 3, in <module>
  2. import httplib, urllib
  3. File "/usr/lib/python2.7/httplib.py", line 80, in <module>
  4. import mimetools
  5. File "/usr/lib/python2.7/mimetools.py", line 6, in <module>
  6. import tempfile
  7. File "/usr/lib/python2.7/tempfile.py", line 35, in <module>
  8. from random import Random as _Random
  9. File "/home/pi/random.py", line 3, in <module>
  10. random_number = random.randint(1,6)
  11. AttributeError: 'module' object has no attribute 'randint'
  12.  
  13. import RPi.GPIO as GPIO
  14. import time
  15. import httplib, urllib
  16. import subprocess
  17. import smtplib
  18.  
  19. from email.mime.image import MIMEImage
  20. from email.mime.multipart import MIMEMultipart
  21. from email.mime.text import MIMEText
  22.  
  23. fromaddrs = 'autoreply0070@gmail.com'
  24. toaddrs = 'rishabhsingh9286@gmail.com'
  25.  
  26. msg=MIMEMultipart()
  27. msg['Subject']='email with atachment'
  28. msg['From']=fromaddrs
  29. msg['to']=toaddrs
  30. b="hello done"
  31. text=MIMEText(b)
  32. username = 'autoreply0070@gmail.com'
  33. password = '9599909890'
  34.  
  35. GPIO.setmode(GPIO.BOARD)
  36. GPIO.setup(7,GPIO.OUT)
  37. GPIO.setup(11,GPIO.IN)
  38.  
  39.  
  40. while(True):
  41. a=GPIO.input(11)
  42. if a==1:
  43. print "motion",a
  44. GPIO.output(7,0)
  45. subprocess.call("./webcam.sh")
  46. fp=open('/home/pi/image.jpg','rb')
  47. img=MIMEImage(fp.read())
  48. fp.close()
  49.  
  50. msg.attach(img)
  51. msg.attach(text)
  52.  
  53. server = smtplib.SMTP('smtp.gmail.com:587')
  54. server.starttls()
  55. server.login(username,password)
  56. server.sendmail(fromaddrs,toaddrs,msg.as_string())
  57. server.quit()
  58. time.sleep(5)
  59. if a==0:
  60. print "no motion",a
  61. GPIO.output(7,1)
  62. time.sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement