@@ -63,6 +63,9 @@ def __login(self):
6363 if not os .path .isdir ("multicast" ):
6464 os .mkdir ("multicast" )
6565
66+ def decode_output (self , output ):
67+ return output .decode (encoding = 'utf-8' ).replace ("\r \n " , "\n " ).split ("\n " )
68+
6669 def __update_information (self ):
6770 if not self .config .get_value ('uuid' ):
6871 self .config .set_value ('uuid' , str (uuid .uuid4 ()))
@@ -72,7 +75,7 @@ def __update_information(self):
7275 devices = []
7376 if Initialize .get_os () == 0 : # linux
7477 output = subprocess .check_output ("cat /proc/cpuinfo" , shell = True )
75- output = output . decode ( encoding = 'utf-8' ). replace ( " \r \n " , " \n " ). split ( " \n " )
78+ output = self . decode_output ( output )
7679 tmp = []
7780 for line in output :
7881 line = line .strip ()
@@ -96,32 +99,41 @@ def __update_information(self):
9699 except subprocess .CalledProcessError :
97100 # we silently ignore this case on machines where lspci is not present or architecture has no pci bus
98101 output = b""
99- output = output . decode ( encoding = 'utf-8' ). replace ( " \r \n " , " \n " ). split ( " \n " )
102+ output = self . decode_output ( output )
100103 for line in output :
101104 if not line :
102105 continue
103106 line = ' ' .join (line .split (' ' )[1 :]).split (':' )
104107 devices .append (line [1 ].strip ())
105108
106109 elif Initialize .get_os () == 1 : # windows
107- output = subprocess .check_output ("wmic cpu get name" , shell = True )
108- output = output .decode (encoding = 'utf-8' ).replace ("\r \n " , "\n " ).split ("\n " )
109- for line in output :
110- line = line .rstrip ("\r \n " )
111- if line == "Name" or not line :
112- continue
113- devices .append (line )
114- output = subprocess .check_output ("wmic path win32_VideoController get name" , shell = True )
115- output = output .decode (encoding = 'utf-8' ).replace ("\r \n " , "\n " ).split ("\n " )
116- for line in output :
117- line = line .rstrip ("\r \n " )
118- if line == "Name" or not line :
119- continue
120- devices .append (line )
110+ platform_release = platform .uname ().release
111+ if platform_release == "" or int (platform_release ) >= 10 :
112+ processor_information = subprocess .check_output (
113+ 'powershell -Command "Get-CimInstance Win32_Processor | Select-Object -ExpandProperty Name"' ,
114+ shell = True )
115+ processor_information = self .decode_output (processor_information )
116+ video_controller = subprocess .check_output (
117+ 'powershell -Command "Get-CimInstance Win32_VideoController | Select-Object -ExpandProperty Name"' ,
118+ shell = True )
119+ video_controller = self .decode_output (video_controller )
120+ else :
121+ processor_information = subprocess .check_output (
122+ 'wmic cpu get name' ,
123+ shell = True )
124+ processor_information = self .decode_output (processor_information )
125+ video_controller = subprocess .check_output ('wmic path win32_VideoController get name' , shell = True )
126+ video_controller = self .decode_output (video_controller )
127+
128+ for source in (processor_information , video_controller ):
129+ for line in source :
130+ line = line .rstrip ("\r \n " )
131+ if line and line != "Name" :
132+ devices .append (line )
121133
122134 else : # OS X
123135 output = subprocess .check_output ("system_profiler SPDisplaysDataType -detaillevel mini" , shell = True )
124- output = output . decode ( encoding = 'utf-8' ). replace ( " \r \n " , " \n " ). split ( " \n " )
136+ output = self . decode_output ( output )
125137 for line in output :
126138 line = line .rstrip ("\r \n " )
127139 if "Chipset Model" not in line :
0 commit comments