Advertisement
aolivens

Python OS Detection

Oct 4th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. #=====================================#
  2. #==============MODULES================#
  3. #=====================================#
  4.  
  5. import platform
  6.  
  7. #=====================================#
  8. #==============VARIABLES==============#
  9. #=====================================#
  10.  
  11. menu = ["(1) Run", "(2) Exit"]
  12. line = "="
  13.  
  14. #=====================================#
  15. #==============FUNCTIONS==============#
  16. #=====================================#
  17.  
  18. def menus(parameter):
  19.     print "     +========+"
  20.     print "     |  MENU  |"
  21.     print "     |========|"
  22.     for word in parameter:
  23.         print "     |%s|" % word
  24.         print "     |--------|"
  25.  
  26. def osdetect():
  27.     rawdata = platform.platform()
  28.     linesize = (len(rawdata) + 11)
  29.     sys = platform.system()
  30.     rel = platform.release()
  31.     ver = platform.version()
  32.    
  33.     print line * linesize
  34.     print " OS Name:  %s " % sys
  35.     print " Release:  %s " % rel
  36.     print " Version:  %s " % ver
  37.     print " Raw Data: %s " % rawdata
  38.     print line * linesize
  39.    
  40. #=====================================#
  41. #=============MAIN PROGRAM============#
  42. #=====================================#
  43.  
  44. def main():
  45.     menus(menu)
  46.     choice = input("Please make a selection(1-2): ")
  47.    
  48.     #OS Detection
  49.     if choice == 1:
  50.         osdetect()
  51.     #Exit
  52.     elif choice == 2:
  53.         print "Exiting Program. Goodbye"
  54.         return
  55.     #Fault
  56.     else:
  57.         print "Invalid Selection"
  58.         return main()
  59. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement