mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-25 00:37:31 +02:00
Add parsing of processors/hotfixs
This commit is contained in:
@ -177,16 +177,19 @@ def parse(data, raw=False, quiet=False):
|
|||||||
raw_output = {}
|
raw_output = {}
|
||||||
for k, v in raw_data.items():
|
for k, v in raw_data.items():
|
||||||
# lowercase and replace spaces with underscores
|
# lowercase and replace spaces with underscores
|
||||||
k = k.strip().lower().replace(' ', '_')
|
k = k.strip().lower().replace(" ", "_")
|
||||||
|
|
||||||
# remove invalid key characters
|
# remove invalid key characters
|
||||||
for c in ';:!@#$%^&*()-':
|
for c in ";:!@#$%^&*()-":
|
||||||
k = k.replace(c, '')
|
k = k.replace(c, "")
|
||||||
|
|
||||||
# since we split on start_value_pos, the delimiter
|
# since we split on start_value_pos, the delimiter
|
||||||
# is still in the key field. Remove it.
|
# is still in the key field. Remove it.
|
||||||
k = k.rstrip(delim)
|
k = k.rstrip(delim)
|
||||||
|
|
||||||
|
if k in ["hotfixs", "processors"]:
|
||||||
|
raw_output[k] = parse_hotfixs_or_processors(v)
|
||||||
|
else:
|
||||||
raw_output[k] = v.strip()
|
raw_output[k] = v.strip()
|
||||||
|
|
||||||
if raw:
|
if raw:
|
||||||
@ -195,6 +198,35 @@ def parse(data, raw=False, quiet=False):
|
|||||||
return process(raw_output)
|
return process(raw_output)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_hotfixs_or_processors(data):
|
||||||
|
"""
|
||||||
|
Turns a list of return-delimited hotfixes or processors
|
||||||
|
with [x] as a prefix into an array of hotfixes
|
||||||
|
|
||||||
|
Note that if a high number of items exist, the list may cutoff
|
||||||
|
and this list may not contain all items installed on the system
|
||||||
|
|
||||||
|
IRL, this likely applies to hotfixes more than processors
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
data: (string) Input string
|
||||||
|
"""
|
||||||
|
arr_output = []
|
||||||
|
for i, l in enumerate(data.splitlines()):
|
||||||
|
# skip line that says how many are installed
|
||||||
|
if i == 0:
|
||||||
|
continue
|
||||||
|
# we have to make sure this is a complete line
|
||||||
|
# as data could cutoff. Make sure the delimiter
|
||||||
|
# exists. Otherwise, skip it.
|
||||||
|
if ":" in l:
|
||||||
|
k, v = l.split(":")
|
||||||
|
# discard the number sequence
|
||||||
|
arr_output.append(v.strip())
|
||||||
|
|
||||||
|
return arr_output
|
||||||
|
|
||||||
|
|
||||||
def get_value_pos(line, delim):
|
def get_value_pos(line, delim):
|
||||||
"""
|
"""
|
||||||
Finds the first non-whitespace character after the delimiter
|
Finds the first non-whitespace character after the delimiter
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
"system_manufacturer": "VMware, Inc.",
|
"system_manufacturer": "VMware, Inc.",
|
||||||
"system_model": "VMware7,1",
|
"system_model": "VMware7,1",
|
||||||
"system_type": "x64-based PC",
|
"system_type": "x64-based PC",
|
||||||
"processors": "1 Processor(s) Installed.\n [01]: Intel64 Family 6 Model 158 Stepping 13 GenuineIntel ~2400 Mhz",
|
"processors": ["Intel64 Family 6 Model 158 Stepping 13 GenuineIntel ~2400 Mhz"],
|
||||||
"bios_version": "VMware, Inc. VMW71.00V.11111111.B64.2008100111, 8/10/2020",
|
"bios_version": "VMware, Inc. VMW71.00V.11111111.B64.2008100111, 8/10/2020",
|
||||||
"windows_directory": "C:\\Windows",
|
"windows_directory": "C:\\Windows",
|
||||||
"system_directory": "C:\\Windows\\system32",
|
"system_directory": "C:\\Windows\\system32",
|
||||||
@ -29,7 +29,7 @@
|
|||||||
"page_file_locations": "C:\\pagefile.sys",
|
"page_file_locations": "C:\\pagefile.sys",
|
||||||
"domain": "TEST.local",
|
"domain": "TEST.local",
|
||||||
"logon_server": "\\\\WIN-AA1A1A11AAA",
|
"logon_server": "\\\\WIN-AA1A1A11AAA",
|
||||||
"hotfixs": "6 Hotfix(s) Installed.\n [01]: KB4578968\n [02]: KB4562830\n [03]: KB4570334\n [04]: KB4580325\n [05]: KB4586864\n [06]: KB4594440",
|
"hotfixs": ["KB4578968", "KB4562830", "KB4570334", "KB4580325", "KB4586864", "KB4594440"],
|
||||||
"network_cards": "1 NIC(s) Installed.\n [01]: Intel(R) 82574L Gigabit Network Connection\n Connection Name: Ethernet0\n DHCP Enabled: Yes\n DHCP Server: 192.168.133.250\n IP address(es)\n [01]: 192.168.133.3\n [02]: fe80::192:eb64:1fcf:86eb",
|
"network_cards": "1 NIC(s) Installed.\n [01]: Intel(R) 82574L Gigabit Network Connection\n Connection Name: Ethernet0\n DHCP Enabled: Yes\n DHCP Server: 192.168.133.250\n IP address(es)\n [01]: 192.168.133.3\n [02]: fe80::192:eb64:1fcf:86eb",
|
||||||
"hyperv_requirements": "A hypervisor has been detected. Features required for Hyper-V will not be displayed."
|
"hyperv_requirements": "A hypervisor has been detected. Features required for Hyper-V will not be displayed."
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user