sysinfo.py 1.3 KB

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