mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-06 22:32:54 +02:00
simplify fixup logic for uname
This commit is contained in:
@ -2,7 +2,7 @@ jc changelog
|
|||||||
|
|
||||||
20211019 v1.17.1 *** in progress ***
|
20211019 v1.17.1 *** in progress ***
|
||||||
- Fix file parser for gzip files
|
- Fix file parser for gzip files
|
||||||
- Fix uname parser for cases where the 'processor' and/or 'machine' fields are missing on linux
|
- Fix uname parser for cases where the 'processor' and/or 'hardware_platform' fields are missing on linux
|
||||||
- Fix uname parser on FreeBSD
|
- Fix uname parser on FreeBSD
|
||||||
- Add lsusb parser tested on linux
|
- Add lsusb parser tested on linux
|
||||||
|
|
||||||
|
@ -113,25 +113,13 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
# otherwise use linux parser
|
# otherwise use linux parser
|
||||||
else:
|
else:
|
||||||
# fixup for cases where the 'processor' and/or 'machine' fields are blank
|
# fixup for cases where the 'processor' and/or 'hardware_platform' fields are blank
|
||||||
fixup_count = 0
|
|
||||||
fixup = data.split()
|
fixup = data.split()
|
||||||
cleanup = True
|
fixup_set = set([fixup[-2], fixup[-3], fixup[-4]])
|
||||||
if fixup[-2] == fixup[-3] and fixup[-2] != fixup[-4]:
|
if len(fixup_set) > 2:
|
||||||
fixup_count = 1
|
fixup.insert(-1, 'unknown')
|
||||||
|
fixup.insert(-1, 'unknown')
|
||||||
elif fixup[-2] != fixup[-3]:
|
|
||||||
fixup_count = 2
|
|
||||||
|
|
||||||
else:
|
|
||||||
cleanup = False
|
|
||||||
|
|
||||||
if cleanup:
|
|
||||||
for item in range(fixup_count):
|
|
||||||
fixup.insert(-2, 'unknown')
|
|
||||||
|
|
||||||
data = ' '.join(fixup)
|
data = ' '.join(fixup)
|
||||||
# end fixup
|
|
||||||
|
|
||||||
parsed_line = data.split(maxsplit=3)
|
parsed_line = data.split(maxsplit=3)
|
||||||
|
|
||||||
@ -145,8 +133,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
parsed_line = parsed_line[-1].rsplit(maxsplit=4)
|
parsed_line = parsed_line[-1].rsplit(maxsplit=4)
|
||||||
|
|
||||||
raw_output['operating_system'] = parsed_line.pop(-1)
|
raw_output['operating_system'] = parsed_line.pop(-1)
|
||||||
raw_output['hardware_platform'] = parsed_line.pop(-1)
|
|
||||||
raw_output['processor'] = parsed_line.pop(-1)
|
raw_output['processor'] = parsed_line.pop(-1)
|
||||||
|
raw_output['hardware_platform'] = parsed_line.pop(-1)
|
||||||
raw_output['machine'] = parsed_line.pop(-1)
|
raw_output['machine'] = parsed_line.pop(-1)
|
||||||
|
|
||||||
raw_output['kernel_version'] = parsed_line.pop(0)
|
raw_output['kernel_version'] = parsed_line.pop(0)
|
||||||
|
Reference in New Issue
Block a user