sysinfo.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #Sysinfo.py - Get info about computer and OS
  2. #Developed by PythonCoder8
  3. #Only works if you run this program on Linux since this program calls a bash script
  4. #Ubuntu, Debian, and Linux Mint only
  5. #Import all required libraries/modules
  6. import subprocess as sp
  7. import platform
  8. import os
  9. import sys
  10. import time
  11. #Create timer to get execution time
  12. start = time.time()
  13. #Display Python version
  14. print("Python version: %s" %(platform.python_version()))
  15. #See if user has figlet installed, and if not installed, install it
  16. figlet_install = input("Do you have figlet installed on your linux terminal (Y/N)? ")
  17. #Clear terminal
  18. os.system("clear")
  19. if figlet_install.upper() == "Y":
  20. pass
  21. elif figlet_install.upper() == "N":
  22. print("Installing figlet...")
  23. os.system("sudo apt-get install figlet")
  24. elif figlet_install.upper() != "Y" and "N":
  25. sys.exit("Invalid input. Your input must either be Y or N (uppercase is not mandatory).")
  26. #Run figlet and get the name of the user's computer
  27. os.system("figlet %s" %(platform.node()))
  28. #Execute bash script sysinfo.sh
  29. sp.call("./sysinfo.sh")
  30. #End timer for finding execution time of program
  31. end = time.time()
  32. #Display execution time - Important: Sometimes the execution time might be a bit big but that would be because the user takes long to enter input
  33. print("Program execution time: %s seconds" %(end - start))