11import ctypes # included library with Python install.
2+ import ErrorLogger as elog
23
34def Mbox (title , text , style = 0 ):
45 return ctypes .windll .user32 .MessageBoxW (0 , text , title , style )
@@ -247,10 +248,12 @@ def del1():
247248 a = 0
248249 if dsid .get () == '' or dsid .get () == 'Enter ID' :
249250 Mbox ('Invalid entry' , 'Please enter ID. ' )
251+ elog .createLog ('deleting student acc' ,'invalid ID entered' )
250252 a += 1
251253 if (dsid .get () != '' and dsid .get () != 'Enter ID' ) and ((dsid .get (),) not in d20 ):
252254 Mbox ('Invalid entry' ,
253255 'Please enter valid ID. ' )
256+ elog .createLog ('deleting student acc' ,'invalid ID entered' )
254257 a += 1
255258 else :
256259 if (a == 0 ) and ((dsid .get (),) in d20 ):
@@ -272,10 +275,12 @@ def del1():
272275 dbcon .commit ()
273276 Mbox (
274277 'Message' , 'Account deleted successfully.' )
278+ elog .createLog ('deleting student acc' ,'Account Deleted successfully.' )
275279 adminhome ()
276280 except :
277281 Mbox (
278282 'Unexpected error' , 'There was an error deleting that account\n Please try again later.' )
283+ elog .createLog ('deleting student acc' ,'Account Deletion unsuccessful.' )
279284 adminhome ()
280285
281286 bt (f2 , text = 'delete' , bd = 0 , bg = '#000000' , fg = '#CF3327' , font = ('SF Pro Display' , 12 ), activebackground = '#000000' , command = del1 ).place (
@@ -302,16 +307,19 @@ def del2():
302307 if daid .get () == '' or daid .get () == 'Enter ID' :
303308 Mbox ('Invalid entry' , 'Please enter ID. ' )
304309 a += 1
310+ elog .createLog ('deleting admin acc' ,'invalid ID entered' )
305311 if (daid .get () != '' and daid .get () != 'Enter ID' ) and ((daid .get (),) not in d21 ):
306312 Mbox ('Invalid entry' ,
307313 'Please enter valid ID. ' )
308314 a += 1
315+ elog .createLog ('deleting admin acc' ,'invalid ID entered' )
309316 else :
310317 if (a == 0 ) and ((daid .get (),) in d21 ):
311318 if (daid .get () == aid .get ()):
312319 Mbox (
313320 'Message' , 'Please login from another ID to delete this one.'
314321 )
322+ elog .createLog ('deleting admin acc' ,'attempt to delete the account which is logged in.' )
315323 adminhome ()
316324 else :
317325 try :
@@ -320,10 +328,12 @@ def del2():
320328 dbcon .commit ()
321329 Mbox (
322330 'Message' , 'Account deleted successfully.' )
331+ elog .createLog ('deleting admin acc' ,'Account Deletion Successful.' )
323332 adminhome ()
324333 except :
325334 Mbox (
326335 'Unexpected error' , 'There was an error deleting that account\n Please try again later.' )
336+ elog .createLog ('deleting admin acc' ,'Account Deletion Unsuccessful.' )
327337 adminhome ()
328338
329339 bt (f2 , text = 'delete' , bd = 0 , bg = '#000000' , fg = '#CF3327' , font = ('SF Pro Display' , 12 ), activebackground = '#000000' , command = del2 ).place (
@@ -478,44 +488,54 @@ def nstudent_save():
478488 if sg != 0 :
479489 Mbox (
480490 'Invalid entry' , 'Please enter data in all fields before saving.' )
491+ elog .createLog ('student profile edit' ,'empty fields before saving.' )
481492 if sg == 0 :
482493 if s12 .get ().startswith ('Saiit' ) == False or s != 0 :
483494 Mbox (
484495 "Invalid entry" , "Please enter valid ID.\n It should start with 'Saiit',\n and should have a relevant unique number suffixed" )
496+ elog .createLog ('student profile edit' ,'New ID disobeys ID-constraints.' )
485497 e += 1
486498 if a != 0 :
487499 Mbox (
488500 'Invalid entry' , 'Names cannot contain numbers, please try again.' )
501+ elog .createLog ('student profile edit' ,'numeric value entered in name.' )
489502 e += 1
490503 if len (s2 .get ()) != 10 or len (s9 .get ()) != 10 or len (s11 .get ()) != 10 or b != 0 :
491504 Mbox (
492505 'Invalid entry' , 'Phone number is invalid, please try again.' )
506+ elog .createLog ('student profile edit' ,'Invalid Phone number.' )
493507 e += 1
494508 if s3 .get () not in l : # year checked.
495509 Mbox (
496510 'Invalid entry' , ' Please check year. ' )
511+ elog .createLog ('student profile edit' ,'Invalid Year.' )
497512 e += 1
498513 if s4 .get ().startswith ('S' ) == False or ad != 0 : # admission number checked
499514 Mbox (
500515 'Invalid entry' , "Admission number is not valid,\n It can only begin with a 'S'\n Please try again." )
516+ elog .createLog ('student profile edit' ,'empty fields before saving.' )
501517 e += 1
502518 if d != 0 :
503519 Mbox (
504520 'Invalid entry' , 'Course is not valid, please try again.' )
521+ elog .createLog ('student profile edit' ,'Invalid Course details.' )
505522 e += 1
506523 if s6 .get () not in l2 : # blood group checked.
507524 Mbox (
508525 'Invalid entry' , 'Please check blood group and try again.' )
526+ elog .createLog ('student profile edit' ,'Incorrect blood group details entered.' )
509527 e += 1
510528 # gender checked.
511529 if s7 .get () not in ['male' , 'female' , 'Male' , 'Female' , 'M' , 'F' , 'm' , 'f' ]:
512530 Mbox (
513531 'Invalid entry' , 'Please check gender and try again.' )
532+ elog .createLog ('student profile edit' ,'gender information invalid.' )
514533 e += 1
515534 else :
516535 if tuple (sget ) in d11 :
517536 Mbox ('Repeated entry' ,
518537 'This record already exists. ' )
538+ elog .createLog ('student profile edit' ,'Account with similar records found.' )
519539 if tuple (sget ) not in d11 and e == 0 :
520540 try :
521541 dbcur .execute ("insert into sprofile values('{}','{}','{}','{}','{}','{}','{}','{}','{}','{}','{}','{}')"
@@ -547,13 +567,15 @@ def nstudent_save():
547567 dbcon .commit ()
548568 Mbox (
549569 'Message' , 'Account added successfully.' )
570+ elog .createLog ('student profile saving' ,'Account added successfully.' )
550571 Mbox ('Message' , 'Since this will be a new account, therefore all other data branches such as password,assignments,attendance,etc are also not set-up.\n '
551572 'For now, all information regarding academics including credentials has been set to NULL.\n '
552573 'You can change this in the future. ' )
553574 adminhome ()
554575 except :
555576 Mbox (
556577 'Unexpected error' , 'Please check all fields or try again later.' )
578+ elog .createLog ('student profile saving' ,'Account addition Unsuccessful.' )
557579
558580 b41 = bt (f12 , image = p51 , bd = 0 , font = ('SF Pro Display' , 15 ), bg = '#000000' ,
559581 fg = '#249ADF' , activebackground = '#000000' , command = nstudent_save )
@@ -631,6 +653,7 @@ def nadmin_save():
631653 c += 1
632654 if c != 0 :
633655 Mbox ('Entry error' , 'Please fill all fields.' )
656+ elog .createLog ('admin profile creation' ,'empty fields before saving.' )
634657 if c == 0 :
635658 if (tid .get ().startswith ('Taiit' ) == False ):
636659 a += 1
@@ -645,25 +668,30 @@ def nadmin_save():
645668 if a != 0 :
646669 Mbox (
647670 'Entry error' , 'Please check all fields and try again.' )
671+ elog .createLog ('admin profile creation' ,'Invalid information in fields.' )
648672 if a == 0 :
649673 if napass .get () != cnapass .get ():
650674 Mbox (
651675 'Key error' , 'Entered paswords do not match.\n Please try again.' )
676+ elog .createLog ('admin profile creation' ,'Passwords not matching.' )
652677 if napass .get () == cnapass .get ():
653678 if tuple (a1get ) in d12 :
654679 Mbox ('Repeated entry' ,
655680 'This record already exists.' )
681+ elog .createLog ('admin profile creation' ,'Account with similar records has been found.' )
656682 if tuple (a1get ) not in d12 :
657683 try :
658684 dbcur .execute ('insert into adminlogin values("{}","{}","{}")' .format (
659685 tid .get (), cnapass .get (), phno .get ()))
660686 dbcon .commit ()
661687 Mbox (
662688 'Message' , 'Account added successfully.' )
689+ elog .createLog ('admin profile creation' ,'Account added successfully.' )
663690 adminhome ()
664691 except :
665692 Mbox (
666693 'Unexpected error' , 'Please check all fields or try again later.' )
694+ elog .createLog ('admin profile creation' ,'Account addition Unsuccessful.' )
667695
668696 b43 = bt (f13 , image = p51 , bd = 0 , font = ('SF Pro Display' , 15 ), bg = '#000000' ,
669697 fg = '#249ADF' , activebackground = '#000000' , command = nadmin_save )
@@ -707,6 +735,7 @@ def go():
707735 d2 = dbcur .fetchall ()
708736 if fid .get () == '' :
709737 Mbox ('Empty entry' , ' Please enter ID. ' )
738+ elog .createLog ('password reset' ,'empty fields before proceeding.' )
710739 if (fid .get (),) not in d2 and fid .get () != '' :
711740 Mbox (
712741 'Invalid entry' , ' Incorrect ID. \n Please try again' )
@@ -3801,8 +3830,10 @@ def reverse2(a):
38013830 except :
38023831 Mbox (
38033832 'Database Error' , 'There was some problem with the associated database, Please try again later' )
3833+ elog .createLog ('Database error CRITICAL' ,'Database response with login details NEGATIVE.' )
38043834 else :
38053835 main ()
38063836except :
38073837 Mbox ('Unexpected error' , "There was an unexpected error, we're trying to solve it. Please close the app and start it again." )
3838+ elog .createLog ('Main UI startup issue CRITICAL' ,'Main UI start NEGATIVE and program unexpectedly stopped.' )
38083839
0 commit comments