Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 29 additions & 17 deletions htpclient/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def __login(self):
if not os.path.isdir("multicast"):
os.mkdir("multicast")

def decode_output(self, output):
return output.decode(encoding='utf-8').replace("\r\n", "\n").split("\n")

def __update_information(self):
if not self.config.get_value('uuid'):
self.config.set_value('uuid', str(uuid.uuid4()))
Expand All @@ -72,7 +75,7 @@ def __update_information(self):
devices = []
if Initialize.get_os() == 0: # linux
output = subprocess.check_output("cat /proc/cpuinfo", shell=True)
output = output.decode(encoding='utf-8').replace("\r\n", "\n").split("\n")
output = self.decode_output(output)
tmp = []
for line in output:
line = line.strip()
Expand All @@ -96,32 +99,41 @@ def __update_information(self):
except subprocess.CalledProcessError:
# we silently ignore this case on machines where lspci is not present or architecture has no pci bus
output = b""
output = output.decode(encoding='utf-8').replace("\r\n", "\n").split("\n")
output = self.decode_output(output)
for line in output:
if not line:
continue
line = ' '.join(line.split(' ')[1:]).split(':')
devices.append(line[1].strip())

elif Initialize.get_os() == 1: # windows
output = subprocess.check_output("wmic cpu get name", shell=True)
output = output.decode(encoding='utf-8').replace("\r\n", "\n").split("\n")
for line in output:
line = line.rstrip("\r\n ")
if line == "Name" or not line:
continue
devices.append(line)
output = subprocess.check_output("wmic path win32_VideoController get name", shell=True)
output = output.decode(encoding='utf-8').replace("\r\n", "\n").split("\n")
for line in output:
line = line.rstrip("\r\n ")
if line == "Name" or not line:
continue
devices.append(line)
platform_release = platform.uname().release
if platform_release == "" or int(platform_release) >= 10:
processor_information = subprocess.check_output(
'powershell -Command "Get-CimInstance Win32_Processor | Select-Object -ExpandProperty Name"',
shell=True)
processor_information = self.decode_output(processor_information)
video_controller = subprocess.check_output(
'powershell -Command "Get-CimInstance Win32_VideoController | Select-Object -ExpandProperty Name"',
shell=True)
video_controller = self.decode_output(video_controller)
else:
processor_information = subprocess.check_output(
'wmic cpu get name',
shell=True)
processor_information = self.decode_output(processor_information)
video_controller = subprocess.check_output('wmic path win32_VideoController get name', shell=True)
video_controller = self.decode_output(video_controller)

for source in (processor_information, video_controller):
for line in source:
line = line.rstrip("\r\n ")
if line and line != "Name":
devices.append(line)

else: # OS X
output = subprocess.check_output("system_profiler SPDisplaysDataType -detaillevel mini", shell=True)
output = output.decode(encoding='utf-8').replace("\r\n", "\n").split("\n")
output = self.decode_output(output)
for line in output:
line = line.rstrip("\r\n ")
if "Chipset Model" not in line:
Expand Down