Advertisement
Guest User

python system info

a guest
Apr 23rd, 2017
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.51 KB | None | 0 0
  1. import urllib2
  2. import json
  3. import wmi
  4. import time
  5. import os
  6. import platform
  7. import win32api
  8.  
  9. def upload_info():
  10.         try: #In case there is a problem with site.
  11.             loc = urllib2.urlopen("http://freegeoip.net/json/")
  12.             json_string = loc.read()
  13.             loc.close()
  14.             location = json.loads(json_string)
  15.         except:
  16.             pass
  17.         else:
  18.             mashine_info = []
  19.  
  20.             computer = wmi.WMI()
  21.             computer_info = computer.Win32_ComputerSystem()[0]
  22.             os_info = computer.Win32_OperatingSystem()[0]
  23.             processor = computer.Win32_Processor()[0]
  24.             gpu = computer.Win32_VideoController()[0]
  25.             os_version = "%s, %s"%(os_info.Version, os_info.BuildNumber)
  26.             system_ram = float(os_info.TotalVisibleMemorySize) / 1048576  # KB to GB
  27.            
  28.             mashine_info.append(time.ctime())
  29.             mashine_info.append("\n\n")
  30.             mashine_info.append("Location")
  31.             mashine_info.append("\n\tCountry: %s"%(location["country_name"]))
  32.             mashine_info.append("\n\tState: %s"%(location["region_name"]))
  33.             mashine_info.append("\n\tCity: %s"%(location["city"]))
  34.             mashine_info.append("\n")
  35.             mashine_info.append("Computer")
  36.  
  37.             mashine_info.append("\n\tName: %s"%(os.environ["COMPUTERNAME"]))
  38.             mashine_info.append("\n\tOS_Name: %s %s"%(platform.system(), platform.release()))
  39.             mashine_info.append("\n\tOS_Version: %s"%(os_version))
  40.            
  41.             mashine_info.append("\n\tProcessor: %s"%(processor.Name))
  42.             mashine_info.append("\n\tArchitecture: %s"%(os.environ["PROCESSOR_ARCHITECTURE"]))
  43.             mashine_info.append("\n\tCores: %s"%(os.environ["NUMBER_OF_PROCESSORS"]))
  44.             mashine_info.append("\n\tRAM: %s"%(system_ram))
  45.             mashine_info.append("\n\tVideo: %s"%(gpu.Name))
  46.             mashine_info.append("\n\tResolution: %sx%s"%(win32api.GetSystemMetrics(0), win32api.GetSystemMetrics(1)))
  47.             mashine_info.append("\n\tMain_Drive: %s"%(os.environ["HOMEDRIVE"]))
  48.             mashine_info.append("\n")
  49.  
  50.             mashine_info.append("User")
  51.             mashine_info.append("\n\tCurrent: %s"%(os.environ["USERNAME"]))
  52.  
  53.             with open("info.txt", "w") as info:
  54.                 try: #In case there was a problem with site.
  55.                     for line in mashine_info:
  56.                         info.write(line)
  57.                 except:
  58.                     pass
  59.  
  60. upload_info()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement