Advertisement
Guest User

Untitled

a guest
Dec 5th, 2018
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.68 KB | None | 0 0
  1. #modules
  2. import sqlite3
  3. import autopy
  4.  
  5.  
  6. import smtplib
  7. from email.mime.multipart import MIMEMultipart
  8. from email.mime.text import MIMEText
  9.  
  10. import winsound
  11. import smtplib
  12. import webbrowser
  13. import random
  14. import matplotlib.pyplot as plt
  15.  
  16. #Test program
  17. conn=sqlite3.connect("database.db")
  18. c=conn.cursor()
  19. c.execute("CREATE TABLE IF NOT EXISTS mathites(onoma TEXT,epitheto TEXT ,onoma_patros TEXT ,hmer_gen TEXT,katagogh TEXT,tmhma TEXT,apousies NUMERIC,mesos_oros TEXT,email_goniou TEXT,aritmos_mhtroou TEXT)")
  20. conn.commit()
  21. def add_student (self):
  22.  
  23.  
  24. onoma=raw_input("dose onoma mathith :")
  25. epitheto=raw_input("dose epitheto mathith :")
  26. onoma_patros=raw_input("dose onoma patros :")
  27. hmer_gen=raw_input("dose hmerominia genhshs :")
  28. katagogh=raw_input("dose katagogh tou mathith :")
  29. tmhma=raw_input("dose mou to tmhma")
  30. apousies=0
  31.  
  32. mesos_oros=""
  33. while True:
  34. email_goniou=raw_input("dose to email goniou : ")
  35. try:
  36. pmsg=random.randint(10000,99999)
  37. s=smtplib.SMTP("smtp.gmail.com",587)
  38. s.ehlo()
  39. s.starttls()
  40. s.login("kostas2372@gmail.com","myllwcutinlyswpw")
  41. s.set_debuglevel(1)
  42. msg = MIMEText("Kalhspera sas hmaste apo to sxoleio tou giou ,\n O kodikos Epiveveoshs einai : "+str(pmsg))
  43. sender = 'kostas2372@gmail.com'
  44. recipients = [email_goniou]
  45. msg['Subject'] = "Kodikos Epiveveoshs"
  46. msg['From'] = sender
  47. msg['To'] = ", ".join(recipients)
  48. s.sendmail(sender, recipients, msg.as_string())
  49. epiv=raw_input("Dose ton kodiko epiveveoshs se parakalo : ")
  50. if (epiv==str(pmsg)):
  51. break
  52. elif(epiv!=str(pmsg)):
  53. print "Xanaprospathise me ton neo kodiko"
  54. else:
  55. print "error"
  56. except :
  57. autopy.alert.alert("Prospathise xan xoris grammata afthn thn fora")
  58. while True:
  59. aritmos_mhtroou=str(random.randint(10000,99999))
  60. conn=sqlite3.connect("database.db")
  61. c=conn.cursor()
  62. c.execute("SELECT * FROM mathites WHERE aritmos_mhtroou = (?)",(aritmos_mhtroou,))
  63. if c.fetchone() is None :
  64. conn.commit()
  65. break
  66. elif c.fetchone() is not None:
  67. pass
  68.  
  69. try:
  70. conn=sqlite3.connect("database.db")
  71. c=conn.cursor()
  72. c.execute("INSERT INTO mathites(onoma, epitheto, onoma_patros, hmer_gen, katagogh, tmhma, apousies, mesos_oros, email_goniou, aritmos_mhtroou) VALUES (? , ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  73. (onoma,epitheto,onoma_patros,hmer_gen,katagogh,tmhma,apousies,mesos_oros,email_goniou,aritmos_mhtroou))
  74. conn.commit()
  75.  
  76. except:
  77. autopy.alert.alert("Error","Error")
  78.  
  79. def remove_student (self):
  80. conn=sqlite3.connect("database.db")
  81. c=conn.cursor()
  82. while True:
  83. std=raw_input("Which student you want to remove from database ?\n Put the Mhtroou Number :")
  84. #try:
  85. c.execute("SELECT * FROM mathites WHERE aritmos_mhtroou = (?)",(std,))
  86. for row in c.fetchall():
  87. onoma=row[0]
  88. ep=row[1]
  89. onoma_patros=row[2]
  90. hmer_gen=row[3]
  91. katagogh=row[4]
  92. tmhma=row[5]
  93. apousies=str(row[6])
  94. mesos_oros=row[7]
  95. email_goniou=row[8]
  96. aritmos_mhtroou=str (row[9])
  97. epiveveosh=raw_input(str("Are you sure that you want to delete the student with these info : \n Name : "+onoma+"\n epitheto : "+ep+"\n onoma patros : "+onoma_patros+"\n hmer. gen : "+hmer_gen+"\n Katagogh : "+katagogh+"\n Tmhma : "+tmhma+"\n Apousies : "+apousies+"\n Mesos Oros : "+mesos_oros+"\n Email Goniou : "+email_goniou+"\n Aritmos Mhtroou : "+aritmos_mhtroou+"\n (Y/N)"))
  98. if (epiveveosh=="Y" or epiveveosh=="yes" or epiveveosh=="y"):
  99. apousies=str(row[6])
  100. aritmos_mhtroou=(row[9])
  101. mail=smtplib.SMTP('smtp.gmail.com',587)
  102. mail.ehlo()
  103. mail.starttls()
  104. mail.login("kostas2372@gmail.com","myllwcutinlyswpw")
  105. mail.sendmail("kostas2372@gmail.com",email_goniou,"Your kid is not in our database anymore ")
  106. c.execute("CREATE TABLE IF NOT EXISTS diegramenoi_mathites(onoma TEXT,epitheto TEXT ,onoma_patros TEXT ,hmer_gen TEXT,katagogh TEXT,tmhma TEXT,apousies NUMERIC,mesos_oros TEXT,email_goniou TEXT,aritmos_mhtroou TEXT)")
  107. c.execute("INSERT INTO diegramenoi_mathites(onoma, epitheto, onoma_patros, hmer_gen, katagogh, tmhma, apousies, mesos_oros, email_goniou, aritmos_mhtroou) VALUES (? , ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  108. (onoma,ep,onoma_patros,hmer_gen,katagogh,tmhma,apousies,mesos_oros,email_goniou,aritmos_mhtroou))
  109. c.execute("DELETE FROM mathites WHERE aritmos_mhtroou = (?) ",(std,))
  110. autopy.alert.alert("This account deleted","SUCCESS")
  111. conn.commit()
  112. break
  113. #except:
  114. autopy.alert.alert("We could not find this student please try again ")
  115. def apousies(self):
  116. mathiths=raw_input("Grapse ton arithmo mhtroou tou mathth sto opoion thes na valeis apousia : ")
  117. conn=sqlite3.connect("database.db")
  118. c=conn.cursor()
  119. c.execute("SELECT * FROM mathites WHERE aritmos_mhtroou = (?)",(mathiths,))
  120.  
  121. for row in c.fetchall():
  122. onoma=row[0]
  123. ep=row[1]
  124. onoma_patros=row[2]
  125. hmer_gen=row[3]
  126. katagogh=row[4]
  127. tmhma=row[5]
  128. apousies=str(row[6])
  129. mesos_oros=row[7]
  130. email_goniou=row[8]
  131. aritmos_mhtroou=str (row[9])
  132. print "Ta stoixeia tou mathith pou thes na valeis apousia : \n Name : "+onoma+"\n epitheto : "+ep+"\n onoma patros : "+onoma_patros+"\n hmer. gen : "+hmer_gen+"\n Katagogh : "+katagogh+"\n Tmhma : "+tmhma+"\n Apousies : "+apousies+"\n Mesos Oros : "+mesos_oros+"\n Email Goniou : "+email_goniou+"\n Aritmos Mhtroou : "+aritmos_mhtroou
  133.  
  134. apousies_p_vl=input("Vale poses apousies theleis na tou prostheseis")
  135. ap_int=row[6]
  136. telikes_apousies=ap_int+apousies_p_vl
  137. if (telikes_apousies<0):
  138. print "You can't have -x apousies try again"
  139. elif (telikes_apousies>0):
  140. c.execute("UPDATE mathites SET apousies = (?) WHERE aritmos_mhtroou = (?)",(telikes_apousies,mathiths))
  141. conn.commit()
  142. if (telikes_apousies > 114):
  143. autopy.alert.alert("O mathiths me arithmo mhtroou : "+aritmos_mhtroou+"Kai me onomateponimo : "+onoma+" "+ep+"Exei mhnei apo apousies !","MATHITHS/A EMEINE")
  144. s=smtplib.SMTP("smtp.gmail.com",587)
  145. s.ehlo()
  146. s.starttls()
  147. s.login("kostas2372@gmail.com","myllwcutinlyswpw")
  148. s.set_debuglevel(1)
  149. msg = MIMEText("To paidi sas me aritmo mhtroou : "+str(aritmos_mhtroou)+" kai onomateponimo : "+onoma+" "+ep+" emeine sthn idia taxh me arithmo apousion : "+str(telikes_apousies)+" Kaleste mas amesa sto 2510-xxx-xxx")
  150. sender = 'kostas2372@gmail.com'
  151. recipients = [email_goniou]
  152. msg['Subject'] = "To paidi sas emeine apo apousies !"
  153. msg['From'] = sender
  154. msg['To'] = ", ".join(recipients)
  155. s.sendmail(sender, recipients, msg.as_string())
  156. elif(telikes_apousies):
  157. s=smtplib.SMTP("smtp.gmail.com",587)
  158. s.ehlo()
  159. s.starttls()
  160. s.login("kostas2372@gmail.com","myllwcutinlyswpw")
  161. s.set_debuglevel(1)
  162. msg = MIMEText("Oi apousies tou paidiou sas einai : "+str(telikes_apousies))
  163. sender = 'kostas2372@gmail.com'
  164. recipients = [email_goniou]
  165. msg['Subject'] = "Apousies tou paidiou sas"
  166. msg['From'] = sender
  167. msg['To'] = ", ".join(recipients)
  168. s.sendmail(sender, recipients, msg.as_string())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement