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
2.0 KiB

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