Guest User

Untitled

a guest
Feb 3rd, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. import RPi.GPIO as rp
  2. import smtplib
  3. import requests as r
  4. import random as ran
  5. import time
  6.  
  7. rp.setmode(rp.BOARD)
  8. rp.setup(7,rp.OUT)
  9. rp.setup(11,rp.OUT)
  10. rp.setup(13,rp.OUT)
  11.  
  12. admin='vishveshpatel26@gmail.com'
  13. email=['namanpreet@gmail.com','namanpreet@gmail.com','namanpreet@gmail.com','namanpreet@gmail.com','namanpreet@gmail.com',]
  14. user=['a1','a2','a3','a4','a5']
  15. pwd=['111','222','333','444','555']
  16.  
  17. def autom():
  18. rp.setmode(rp.BOARD)
  19. rp.setup(11,rp.OUT)
  20. rp.setup(13,rp.OUT)
  21. rp.output(11,0)
  22. while True:
  23. rp.output(11,1)
  24. time.sleep(0.00001)
  25. rp.output(11,0)
  26. while(rp.input(13)==0):
  27. pass
  28. t1=time.time()
  29. while(rp.input(13)==1):
  30. pass
  31. t2=time.time()
  32. T=t2-t1
  33. print(T)
  34. if D < 20:
  35. rp.output(7,1)
  36. time.sleep(1)
  37. else:
  38. rp.output(7,0)
  39. time.sleep(1)
  40.  
  41.  
  42. def manu():
  43.  
  44. while True:
  45. data=r.get('http://indianiotcloud.com/retrieve.php?id=LY2DM1Q9YXLMFFB562A4')
  46. d=data.json()
  47. d1=d['result'][0]['field1']
  48. print(d1)
  49. if(d1=='1'):
  50. rp.output(7,1)
  51. time.sleep(1)
  52. else:
  53. rp.output(7,0)
  54. time.sleep(1)
  55.  
  56. def s4():
  57. s = smtplib.SMTP('smtp.gmail.com', 587)
  58. s.starttls()
  59. s.login("prime10400@gmail.com", "naman@123")
  60. message = ("Password and OTP entered wrongly")
  61. s.sendmail("sender_email_id", admin, message)
  62. s.quit()
  63.  
  64. def s5():
  65. mode=raw_input('What mode do you want? \n Enter A for Automatic Mode\n Enter B for manual mode')
  66. if(mode=='A'):
  67. autom()
  68. else:
  69. manu()
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. i=0
  78.  
  79. while i < 3 :
  80. a = raw_input('Enter your Username')
  81. if a in user:
  82. b=raw_input('Enter your password')
  83. c=user.index(a)
  84. if pwd[c]==b:
  85. s5()
  86. else:
  87. i=i+1
  88. print('Wrong Password')
  89. if(i==3):
  90.  
  91. otp=ran.randint(0,10000)
  92. s = smtplib.SMTP('smtp.gmail.com', 587)
  93. s.starttls()
  94. s.login("prime10400@gmail.com", "naman@123")
  95. message = (otp)
  96. s.sendmail("sender_email_id", email[1], message)
  97. s.quit()
  98. print('inside')
  99. inotp=input('Enter OTP')
  100. r=int(inotp)
  101. if(r==otp):
  102. s5()
  103. else:
  104. s4()
  105. else:
  106. print('Wrong Username')
Add Comment
Please, Sign In to add comment