mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
add exception with hint to use "uname -a"
This commit is contained in:
@ -4,7 +4,7 @@ jc changelog
|
||||
- Add ping and ping6 command parser tested on linux, macos, and freebsd
|
||||
- Add traceroute and traceroute6 command parser tested on linux, macos, and freebsd
|
||||
- Update ini parser to support files only containing key/value pairs
|
||||
|
||||
- Update uname parser exception with a hint to use "uname -a"
|
||||
|
||||
20200711 v1.12.1
|
||||
- Fix tests when using older version of pygments library
|
||||
|
@ -30,7 +30,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
version = '1.4'
|
||||
description = 'uname -a command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -43,6 +43,10 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
class ParseError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -94,6 +98,10 @@ def parse(data, raw=False, quiet=False):
|
||||
# check for OSX output
|
||||
if data.startswith('Darwin'):
|
||||
parsed_line = data.split()
|
||||
|
||||
if len(parsed_line) < 5:
|
||||
raise ParseError('Could not parse uname output. Make sure to use "uname -a".')
|
||||
|
||||
raw_output['machine'] = parsed_line.pop(-1)
|
||||
raw_output['kernel_name'] = parsed_line.pop(0)
|
||||
raw_output['node_name'] = parsed_line.pop(0)
|
||||
@ -103,6 +111,10 @@ def parse(data, raw=False, quiet=False):
|
||||
# otherwise use linux parser
|
||||
else:
|
||||
parsed_line = data.split(maxsplit=3)
|
||||
|
||||
if len(parsed_line) < 3:
|
||||
raise ParseError('Could not parse uname output. Make sure to use "uname -a".')
|
||||
|
||||
raw_output['kernel_name'] = parsed_line.pop(0)
|
||||
raw_output['node_name'] = parsed_line.pop(0)
|
||||
raw_output['kernel_release'] = parsed_line.pop(0)
|
||||
|
Reference in New Issue
Block a user