winfetch.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env python
  2. import datetime
  3. import subprocess
  4. import sys
  5. import random
  6. cpu = subprocess.getoutput("wmic cpu get numberofcores, name")
  7. cpu = cpu.splitlines()[2]
  8. gpu = subprocess.getoutput("wmic path win32_videoController get name")
  9. gpu = gpu.splitlines()[2]
  10. memory = subprocess.getoutput("wmic MemoryChip get Capacity")
  11. rams = 0
  12. for line in memory.splitlines():
  13. if "Capacity" in line:
  14. pass
  15. elif line == "":
  16. pass
  17. else:
  18. rams = rams + int(line.split()[0])
  19. rams = sys.getsizeof(rams)
  20. uptime = subprocess.getoutput("net statistics workstation")
  21. for line in uptime.splitlines():
  22. if "Statistics" in line:
  23. uptimedate = line.split()[2].split("/")
  24. a = datetime.datetime(int(uptimedate[2]),int(uptimedate[0]),int(uptimedate[1]))
  25. b = datetime.datetime.now()
  26. uptimedate = str(b-a).split(",")[0]
  27. version = subprocess.getoutput("wmic os get version")
  28. version = version.splitlines()[2]
  29. name = subprocess.getoutput("wmic os get Caption")
  30. name = name.splitlines()[2]
  31. random = random.randint(1,3)
  32. if len(sys.argv) == 1:
  33. if random == 1:
  34. print(f"""
  35. _____ _____
  36. | || | CPU: {cpu}
  37. | || | GPU: {gpu}
  38. |_____||_____| RAM: {rams}
  39. _____ _____ Uptime: {uptimedate}
  40. | || | Version: {version}
  41. | || | OS: {name}
  42. |_____||_____|""")
  43. elif random == 2:
  44. print(f"""
  45. ___ ___
  46. / \ / \ CPU: {cpu}
  47. \ |\ | GPU: {gpu}
  48. \___| \___| RAM: {rams}
  49. ___ ___ Uptime: {uptimedate}
  50. / \ / \ Version: {version}
  51. \ |\ | OS: {name}
  52. \___| \___|""")
  53. elif random == 3:
  54. print(f"""
  55. ____ ____
  56. / \/ \ CPU: {cpu}
  57. | /| / GPU: {gpu}
  58. |___/ |___/ RAM: {rams}
  59. ____ ____ Uptime: {uptimedate}
  60. / \/ \ Version: {version}
  61. | /| / OS: {name}
  62. |___/ |___/ """)
  63. elif sys.argv[1] == "-u":
  64. print(f'''
  65. ┌────┐ ┌────┐ CPU: {cpu}
  66. │ │ │ │ GPU: {gpu}
  67. └────┘ └────┘ RAM: {rams}
  68. ┌────┐ ┌────┐ Uptime: {uptimedate}
  69. │ │ │ │ Version: {version}
  70. └────┘ └────┘ OS: {name}''')
  71. else:
  72. print("Unsupported command")