sysinfo.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. #This code has only been tested on Ubuntu 20.04 LTS and may not work on any other distros of Linux
  4. #Import all required libraries/modules
  5. import subprocess as sp
  6. import platform, os, sys, time
  7. #Create timer to get execution time
  8. start = time.time()
  9. #Ask user if they have the Linux command line tool figlet installed
  10. figlet_install = input("Do you have figlet installed on your linux terminal (Y/N)? ")
  11. #If they already have it installed, don't do anything and move on to the next part in the code
  12. if figlet_install.upper() == "Y":
  13. pass
  14. #If user does not have figlet installed, in the background the program runs the Linux command for installing figlet
  15. elif figlet_install.upper() == "N":
  16. print("Installing figlet...")
  17. os.system("sudo apt-get install figlet")
  18. #If user doesn't enter y or n, throw an error exiting the program
  19. elif figlet_install.upper() != "Y" and "N":
  20. sys.exit("Invalid input. Your input must either be Y or N (uppercase is not mandatory).")
  21. #Run figlet and get the name of the user's computer
  22. os.system("figlet %s" %(platform.node()))
  23. #Execute bash script sysinfo.sh
  24. sp.call("/mnt/e/bash/welcomewagon.sh")
  25. #End timer for finding execution time of program
  26. end = time.time()
  27. #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
  28. print("Program execution time: %s seconds" %(end - start))