admin scripts
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.

34 lines
900 B

  1. #!/usr/bin/python3
  2. """Check if db is owned by a user"""
  3. import sys
  4. import subprocess
  5. def get_courses(db_name):
  6. """Get users course"""
  7. result = ''
  8. proc = subprocess.Popen('../bash/rbsearch -uid ' + str(db_name) + ' | grep yearsPaid',
  9. shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  10. proc.daemon = True
  11. for line in proc.stdout.readlines():
  12. result += line
  13. proc.wait()
  14. if '1' in result:
  15. return False
  16. return True
  17. # start processing input
  18. if sys.argv[1]:
  19. try:
  20. FILENAME = sys.argv[1]
  21. FILE = open(FILENAME)
  22. LINES = [line.strip() for line in FILE]
  23. FILE.close()
  24. for l in LINES:
  25. if get_courses(l):
  26. print(l)
  27. except IndexError as err:
  28. print('Usage: not_a_user_db.py <filename>')
  29. else:
  30. print('Usage: not_a_user_db.py <filename>')