Advertisement
Guest User

Untitled

a guest
Dec 7th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.02 KB | None | 0 0
  1. #modules
  2. import sqlite3
  3. import autopy
  4. import kivy
  5. kivy.require("1.9.0")
  6. from kivy.properties import NumericProperty
  7. from kivy.app import App
  8. from kivy.uix.widget import Widget
  9. from kivy.properties import ObjectProperty
  10. from kivy.core.window import Window
  11. from kivy.properties import StringProperty
  12.  
  13. import smtplib
  14. from email.mime.multipart import MIMEMultipart
  15. from email.mime.text import MIMEText
  16. Window.clearcolor = (0.8, 0.8, 0.8, 1)#SET COLOR
  17.  
  18. import winsound
  19. import smtplib
  20. import webbrowser
  21. import random
  22. import matplotlib.pyplot as plt
  23.  
  24. #Test program
  25.  
  26.  
  27.  
  28. class CustomWidget(Widget):
  29.  
  30. password_text_input=ObjectProperty()
  31. username_text_input=ObjectProperty()
  32. onoma_text_input= ObjectProperty()
  33. epitheto_text_input=ObjectProperty()
  34. onoma_patros_text_input=ObjectProperty()
  35. hmer_gen_text_input=ObjectProperty()
  36. katagogh_text_input=ObjectProperty()
  37. tmhma_text_input=ObjectProperty()
  38. email_goniou_text_input=ObjectProperty()
  39. epiv_text_input=ObjectProperty()
  40.  
  41. def move_admin(self):
  42. self.ids.addbutton.pos=100,850
  43. self.ids.removebutton.pos=350,850
  44. self.ids.apousiesbutton.pos=600,850
  45. def remove_start(self):
  46. self.ids.username.pos=10000,10000
  47. self.ids.userlab.pos=10000,10000
  48. self.ids.password.pos=10000,10000
  49. self.ids.passwordlab.pos=10000,10000
  50. self.ids.loginbutton.pos=10000,10000
  51. def login_but(self):
  52. username=self.username_text_input.text
  53. password=self.password_text_input.text
  54. if ((username == 0)):
  55. autopy.alert.alert("You have to write the username !")
  56. elif ((password == 0)):
  57. autopy.alert.alert("You have to write the password !")
  58. else:
  59. conn=sqlite3.connect("database.db")
  60. c=conn.cursor()
  61. c.execute("CREATE TABLE IF NOT EXISTS acc(First_Name TEXT, Last_Name TEXT, username TEXT, password TEXT)")
  62. conn.commit()
  63. conn=sqlite3.connect("database.db")
  64. c=conn.cursor()
  65. c.execute("SELECT * FROM acc WHERE username = (?) AND password = (?)",(username,password))
  66. if c.fetchall is not None :
  67.  
  68. for row in c.fetchall() :
  69. name=row[0]
  70. lastname=row[1]
  71. self.move_admin()
  72.  
  73.  
  74. autopy.alert.alert("Welcome MR/MRS "+name+" "+lastname,"SUCCESS")
  75. self.remove_start()
  76. elif c.fetchall () is None :
  77. autopy.alert.alert("Wrong password or Wrong username")
  78. else:
  79. autopy.alert.alert("Error","Error")
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. def add_student (self):
  92. conn=sqlite3.connect("database.db")
  93. c=conn.cursor()
  94. 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)")
  95. conn.commit()
  96. pmsg=random.randint(10000,99999)
  97.  
  98. onoma=raw_input("dose onoma mathith :")
  99. epitheto=raw_input("dose epitheto mathith :")
  100. onoma_patros=raw_input("dose onoma patros :")
  101. hmer_gen=raw_input("dose hmerominia genhshs :")
  102. katagogh=raw_input("dose katagogh tou mathith :")
  103. tmhma=raw_input("dose mou to tmhma")
  104. apousies=0
  105.  
  106. mesos_oros=""
  107. while True :
  108. email_goniou=raw_input("dose to email goniou : ")
  109. s=smtplib.SMTP("smtp.gmail.com",587)
  110. s.ehlo()
  111. s.starttls()
  112. s.login("kostas2372@gmail.com","myllwcutinlyswpw")
  113. s.set_debuglevel(1)
  114. msg = MIMEText("Kalhspera sas hmaste apo to sxoleio tou giou ,\n O kodikos Epiveveoshs einai : "+str(pmsg))
  115. sender = 'kostas2372@gmail.com'
  116. recipients = [email_goniou]
  117. msg['Subject'] = "Kodikos Epiveveoshs"
  118. msg['From'] = sender
  119. msg['To'] = ", ".join(recipients)
  120. s.sendmail(sender, recipients, msg.as_string())
  121. epiv=raw_input("Dose ton kodiko epiveveoshs se parakalo : ")
  122. if (epiv==str(pmsg)):
  123. break
  124. elif(epiv!=str(pmsg)):
  125. print "Xanaprospathise me ton neo kodiko"
  126. else:
  127. print "error"
  128. while True:
  129. aritmos_mhtroou=str(random.randint(10000,99999))
  130. conn=sqlite3.connect("database.db")
  131. c=conn.cursor()
  132. c.execute("SELECT * FROM mathites WHERE aritmos_mhtroou = (?)",(aritmos_mhtroou,))
  133. if c.fetchone() is None :
  134. conn.commit()
  135. break
  136. elif c.fetchone() is not None:
  137. pass
  138.  
  139. try:
  140. conn=sqlite3.connect("database.db")
  141. c=conn.cursor()
  142. c.execute("INSERT INTO mathites(onoma, epitheto, onoma_patros, hmer_gen, katagogh, tmhma, apousies, mesos_oros, email_goniou, aritmos_mhtroou) VALUES (? , ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  143. (onoma,epitheto,onoma_patros,hmer_gen,katagogh,tmhma,apousies,mesos_oros,email_goniou,aritmos_mhtroou))
  144. conn.commit()
  145.  
  146. except:
  147. autopy.alert.alert("Error","Error")
  148.  
  149. def remove_student (self):
  150. conn=sqlite3.connect("database.db")
  151. c=conn.cursor()
  152. while True:
  153. std=raw_input("Which student you want to remove from database ?\n Put the Mhtroou Number :")
  154. #try:
  155. c.execute("SELECT * FROM mathites WHERE aritmos_mhtroou = (?)",(std,))
  156. for row in c.fetchall():
  157. onoma=row[0]
  158. ep=row[1]
  159. onoma_patros=row[2]
  160. hmer_gen=row[3]
  161. katagogh=row[4]
  162. tmhma=row[5]
  163. apousies=str(row[6])
  164. mesos_oros=row[7]
  165. email_goniou=row[8]
  166. aritmos_mhtroou=str (row[9])
  167. 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)"))
  168. if (epiveveosh=="Y" or epiveveosh=="yes" or epiveveosh=="y"):
  169. apousies=str(row[6])
  170. aritmos_mhtroou=(row[9])
  171. mail=smtplib.SMTP('smtp.gmail.com',587)
  172. mail.ehlo()
  173. mail.starttls()
  174. mail.login("kostas2372@gmail.com","myllwcutinlyswpw")
  175. mail.sendmail("kostas2372@gmail.com",email_goniou,"Your kid is not in our database anymore ")
  176. 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)")
  177. c.execute("INSERT INTO diegramenoi_mathites(onoma, epitheto, onoma_patros, hmer_gen, katagogh, tmhma, apousies, mesos_oros, email_goniou, aritmos_mhtroou) VALUES (? , ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  178. (onoma,ep,onoma_patros,hmer_gen,katagogh,tmhma,apousies,mesos_oros,email_goniou,aritmos_mhtroou))
  179. c.execute("DELETE FROM mathites WHERE aritmos_mhtroou = (?) ",(std,))
  180. autopy.alert.alert("This account deleted","SUCCESS")
  181. conn.commit()
  182. break
  183. #except:
  184. autopy.alert.alert("We could not find this student please try again ")
  185. def apousies(self):
  186. mathiths=raw_input("Grapse ton arithmo mhtroou tou mathth sto opoion thes na valeis apousia : ")
  187. conn=sqlite3.connect("database.db")
  188. c=conn.cursor()
  189. c.execute("SELECT * FROM mathites WHERE aritmos_mhtroou = (?)",(mathiths,))
  190.  
  191. for row in c.fetchall():
  192. onoma=row[0]
  193. ep=row[1]
  194. onoma_patros=row[2]
  195. hmer_gen=row[3]
  196. katagogh=row[4]
  197. tmhma=row[5]
  198. apousies=str(row[6])
  199. mesos_oros=row[7]
  200. email_goniou=row[8]
  201. aritmos_mhtroou=str (row[9])
  202. 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
  203.  
  204. apousies_p_vl=input("Vale poses apousies theleis na tou prostheseis")
  205. ap_int=row[6]
  206. telikes_apousies=ap_int+apousies_p_vl
  207. if (telikes_apousies<0):
  208. print "You can't have -x apousies try again"
  209. elif (telikes_apousies>0):
  210. c.execute("UPDATE mathites SET apousies = (?) WHERE aritmos_mhtroou = (?)",(telikes_apousies,mathiths))
  211. conn.commit()
  212. if (telikes_apousies > 114):
  213. autopy.alert.alert("O mathiths me arithmo mhtroou : "+aritmos_mhtroou+"Kai me onomateponimo : "+onoma+" "+ep+"Exei mhnei apo apousies !","MATHITHS/A EMEINE")
  214. s=smtplib.SMTP("smtp.gmail.com",587)
  215. s.ehlo()
  216. s.starttls()
  217. s.login("kostas2372@gmail.com","myllwcutinlyswpw")
  218. s.set_debuglevel(1)
  219. 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")
  220. sender = 'kostas2372@gmail.com'
  221. recipients = [email_goniou]
  222. msg['Subject'] = "To paidi sas emeine apo apousies !"
  223. msg['From'] = sender
  224. msg['To'] = ", ".join(recipients)
  225. s.sendmail(sender, recipients, msg.as_string())
  226. elif(telikes_apousies):
  227. s=smtplib.SMTP("smtp.gmail.com",587)
  228. s.ehlo()
  229. s.starttls()
  230. s.login("kostas2372@gmail.com","myllwcutinlyswpw")
  231. s.set_debuglevel(1)
  232. msg = MIMEText("Oi apousies tou paidiou sas einai : "+str(telikes_apousies))
  233. sender = 'kostas2372@gmail.com'
  234. recipients = [email_goniou]
  235. msg['Subject'] = "Apousies tou paidiou sas"
  236. msg['From'] = sender
  237. msg['To'] = ", ".join(recipients)
  238. s.sendmail(sender, recipients, msg.as_string())
  239.  
  240.  
  241. class CustomWidgetApp(App):
  242. def build(self):
  243. self.title = 'School System'
  244. self.icon = 'icon.jpg'
  245. return CustomWidget()
  246. customWidget = CustomWidgetApp()
  247. customWidget.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement