user.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import os
  2. from time import sleep
  3. from sys import argv
  4. def get_user():
  5. if len(argv) > 1:
  6. uname = argv[1]
  7. else:
  8. uname = input("输入用户标记名:")
  9. if check_uname(uname):
  10. dd = check_dd(uname)
  11. else:
  12. os.makedirs("./user/{}".format(uname))
  13. dd = False
  14. return dd, uname
  15. def check_uname(uname):
  16. __check_status = False
  17. if os.path.exists("./user/{}".format(uname)):
  18. __check_status = True
  19. return __check_status
  20. def check_dd(uname):
  21. __dd_status = False
  22. if os.path.exists("./user/{}/dingding".format(uname)):
  23. __dd_status = True
  24. return __dd_status
  25. def get_a_log(uname):
  26. __a_log = 0
  27. if os.path.exists("./user/{}/a_log".format(uname)):
  28. with open("./user/{}/a_log".format(uname), "r", encoding="utf8") as fp:
  29. __a_log = int(fp.read())
  30. else:
  31. with open("./user/{}/a_log".format(uname), "w", encoding="utf8") as fp:
  32. fp.write(str(__a_log))
  33. return __a_log
  34. def get_v_log(uname):
  35. __v_log = 0
  36. if os.path.exists("./user/{}/v_log".format(uname)):
  37. with open("./user/{}/v_log".format(uname), "r", encoding="utf8") as fp:
  38. __v_log = int(fp.read())
  39. else:
  40. with open("./user/{}/v_log".format(uname), "w", encoding="utf8") as fp:
  41. fp.write(str(__v_log))
  42. return __v_log
  43. def shutdown(stime):
  44. if stime:
  45. stime = int(stime)
  46. os.system('shutdown -s -t {}'.format(stime))
  47. for i in range(stime):
  48. print("\r{}秒后关机".format(stime-i), end="")
  49. sleep(1)
  50. else:
  51. print("无自动关机任务,已程序释放内存,00分钟后窗口将自动关闭")
  52. sleep(600)