Redbrick User management tool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.7 KiB

  1. #!/usr/local/bin/python
  2. import sys
  3. import readline
  4. import re
  5. import os
  6. from rbuser import *
  7. from rbuserdb import *
  8. voteregister= 'voted.txt'
  9. #-----------------------------------------------------------------------------#
  10. # MAIN #
  11. #-----------------------------------------------------------------------------#
  12. def main():
  13. """Program entry function."""
  14. voted = {}
  15. if os.path.exists(voteregister):
  16. fd = open(voteregister, 'r')
  17. for line in fd.readlines():
  18. voted[line.rstrip()] = 1
  19. fd.close()
  20. fd = open(voteregister, 'a')
  21. udb = RBUserDB()
  22. udb.connect()
  23. while 1:
  24. usr = RBUser()
  25. tmp = None
  26. while not tmp:
  27. tmp = raw_input("Please enter Username/Student ID/Student Card: ")
  28. res = re.search(r'\D*\d{2}(\d{8})\d{3}\D*', tmp)
  29. if res:
  30. usr.id = int(res.group(1))
  31. print 'CARD', usr.id
  32. else:
  33. res = re.search(r'^(\d{8})$', tmp)
  34. if res:
  35. usr.id = int(tmp)
  36. print 'ID', usr.id
  37. try:
  38. if usr.id:
  39. udb.get_user_byid(usr)
  40. udb.show(usr)
  41. else:
  42. usr.uid = tmp
  43. udb.get_user_byname(usr)
  44. udb.show(usr)
  45. except RBError:
  46. print 'NO SUCH USER YOU FUCKING DICKHEAD'
  47. else:
  48. if voted.has_key(usr.uid):
  49. print '\nGO FUCK YOUSELF YOU TWO-VOTING PRICK\n'
  50. continue
  51. if usr.usertype not in ('member', 'committe', 'staff'):
  52. print '\nTELL THE COCKMUCH TO GET A REAL MEMBER ACCOUNT\n'
  53. elif usr.yearsPaid <= 0:
  54. print '\nTELL THE SCABBY BASTARD TO PISS OFF\n'
  55. else:
  56. fd.write('%s\n' % usr.uid)
  57. fd.flush()
  58. voted[usr.uid] = 1
  59. print '\nBIG VOTE GO NOW!\n'
  60. fd.close()
  61. sys.exit(0)
  62. if __name__ == "__main__":
  63. main()