mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
add info class
This commit is contained in:
@ -5,9 +5,7 @@ jc changelog
|
||||
- Add OSX support for the arp parser
|
||||
- Add OSX support for the df parser
|
||||
- Add OSX support for the mount parser
|
||||
- Add tests for ls on OSX
|
||||
- Add tests for dig on OSX
|
||||
- Add tests for ps on OSX
|
||||
- Add tests for ls, dig, ps, w, uptime on OSX
|
||||
- Add universal parsers to refactor repetitive code
|
||||
- Updated ifconfig parser to output 'state' as an array
|
||||
|
||||
|
127
jc/cli.py
127
jc/cli.py
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""jc - JSON CLI output utility
|
||||
|
||||
JC cli module
|
||||
"""
|
||||
import sys
|
||||
@ -37,52 +36,76 @@ import jc.parsers.uname
|
||||
import jc.parsers.uptime
|
||||
import jc.parsers.w
|
||||
|
||||
parser_map = {
|
||||
'--arp': jc.parsers.arp,
|
||||
'--df': jc.parsers.df,
|
||||
'--dig': jc.parsers.dig,
|
||||
'--env': jc.parsers.env,
|
||||
'--free': jc.parsers.free,
|
||||
'--fstab': jc.parsers.fstab,
|
||||
'--history': jc.parsers.history,
|
||||
'--hosts': jc.parsers.hosts,
|
||||
'--ifconfig': jc.parsers.ifconfig,
|
||||
'--iptables': jc.parsers.iptables,
|
||||
'--jobs': jc.parsers.jobs,
|
||||
'--ls': jc.parsers.ls,
|
||||
'--lsblk': jc.parsers.lsblk,
|
||||
'--lsmod': jc.parsers.lsmod,
|
||||
'--lsof': jc.parsers.lsof,
|
||||
'--mount': jc.parsers.mount,
|
||||
'--netstat': jc.parsers.netstat,
|
||||
'--ps': jc.parsers.ps,
|
||||
'--route': jc.parsers.route,
|
||||
'--ss': jc.parsers.ss,
|
||||
'--stat': jc.parsers.stat,
|
||||
'--systemctl': jc.parsers.systemctl,
|
||||
'--systemctl-lj': jc.parsers.systemctl_lj,
|
||||
'--systemctl-ls': jc.parsers.systemctl_ls,
|
||||
'--systemctl-luf': jc.parsers.systemctl_luf,
|
||||
'--uname': jc.parsers.uname,
|
||||
'--uptime': jc.parsers.uptime,
|
||||
'--w': jc.parsers.w
|
||||
}
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.6.1'
|
||||
description = 'jc cli'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
|
||||
def ctrlc(signum, frame):
|
||||
exit()
|
||||
|
||||
|
||||
def parsers_text():
|
||||
ptext = ''
|
||||
for key in parser_map:
|
||||
if hasattr(parser_map[key], 'info'):
|
||||
padding = 16 - len(key)
|
||||
padding_char = ' '
|
||||
padding_text = padding_char * padding
|
||||
ptext += ' ' + key + padding_text + parser_map[key].info.description + '\n'
|
||||
|
||||
return ptext
|
||||
|
||||
|
||||
def helptext(message):
|
||||
parsers_string = parsers_text()
|
||||
|
||||
helptext_string = f'''
|
||||
jc: {message}
|
||||
|
||||
Usage: jc PARSER [OPTIONS]
|
||||
|
||||
Parsers:
|
||||
--arp arp parser
|
||||
--df df parser
|
||||
--dig dig parser
|
||||
--env env parser
|
||||
--free free parser
|
||||
--fstab /etc/fstab file parser
|
||||
--history history parser
|
||||
--hosts /etc/hosts file parser
|
||||
--ifconfig iconfig parser
|
||||
--iptables iptables parser
|
||||
--jobs jobs parser
|
||||
--ls ls parser
|
||||
--lsblk lsblk parser
|
||||
--lsmod lsmod parser
|
||||
--lsof lsof parser
|
||||
--mount mount parser
|
||||
--netstat netstat parser
|
||||
--ps ps parser
|
||||
--route route parser
|
||||
--ss ss parser
|
||||
--stat stat parser
|
||||
--systemctl systemctl parser
|
||||
--systemctl-lj systemctl list-jobs parser
|
||||
--systemctl-ls systemctl list-sockets parser
|
||||
--systemctl-luf systemctl list-unit-files parser
|
||||
--uname uname -a parser
|
||||
--uptime uptime parser
|
||||
--w w parser
|
||||
|
||||
{parsers_string}
|
||||
Options:
|
||||
-d debug - show trace messages
|
||||
-p pretty print output
|
||||
-q quiet - suppress warnings
|
||||
-r raw JSON output
|
||||
-d debug - show trace messages
|
||||
-p pretty print output
|
||||
-q quiet - suppress warnings
|
||||
-r raw JSON output
|
||||
|
||||
Example:
|
||||
ls -al | jc --ls -p
|
||||
@ -116,51 +139,19 @@ def main():
|
||||
if '-r' in sys.argv:
|
||||
raw = True
|
||||
|
||||
# parsers
|
||||
parser_map = {
|
||||
'--arp': jc.parsers.arp.parse,
|
||||
'--df': jc.parsers.df.parse,
|
||||
'--dig': jc.parsers.dig.parse,
|
||||
'--env': jc.parsers.env.parse,
|
||||
'--free': jc.parsers.free.parse,
|
||||
'--fstab': jc.parsers.fstab.parse,
|
||||
'--history': jc.parsers.history.parse,
|
||||
'--hosts': jc.parsers.hosts.parse,
|
||||
'--ifconfig': jc.parsers.ifconfig.parse,
|
||||
'--iptables': jc.parsers.iptables.parse,
|
||||
'--jobs': jc.parsers.jobs.parse,
|
||||
'--ls': jc.parsers.ls.parse,
|
||||
'--lsblk': jc.parsers.lsblk.parse,
|
||||
'--lsmod': jc.parsers.lsmod.parse,
|
||||
'--lsof': jc.parsers.lsof.parse,
|
||||
'--mount': jc.parsers.mount.parse,
|
||||
'--netstat': jc.parsers.netstat.parse,
|
||||
'--ps': jc.parsers.ps.parse,
|
||||
'--route': jc.parsers.route.parse,
|
||||
'--ss': jc.parsers.ss.parse,
|
||||
'--stat': jc.parsers.stat.parse,
|
||||
'--systemctl': jc.parsers.systemctl.parse,
|
||||
'--systemctl-lj': jc.parsers.systemctl_lj.parse,
|
||||
'--systemctl-ls': jc.parsers.systemctl_ls.parse,
|
||||
'--systemctl-luf': jc.parsers.systemctl_luf.parse,
|
||||
'--uname': jc.parsers.uname.parse,
|
||||
'--uptime': jc.parsers.uptime.parse,
|
||||
'--w': jc.parsers.w.parse
|
||||
}
|
||||
|
||||
found = False
|
||||
|
||||
if debug:
|
||||
for arg in sys.argv:
|
||||
if arg in parser_map:
|
||||
result = parser_map[arg](data, raw=raw, quiet=quiet)
|
||||
result = parser_map[arg].parse(data, raw=raw, quiet=quiet)
|
||||
found = True
|
||||
break
|
||||
else:
|
||||
for arg in sys.argv:
|
||||
if arg in parser_map:
|
||||
try:
|
||||
result = parser_map[arg](data, raw=raw, quiet=quiet)
|
||||
result = parser_map[arg].parse(data, raw=raw, quiet=quiet)
|
||||
found = True
|
||||
break
|
||||
except:
|
||||
|
@ -2,7 +2,11 @@
|
||||
|
||||
Usage:
|
||||
|
||||
specify --arp as the first argument if the piped input is coming from arp
|
||||
specify --arp as the first argument if the piped input is coming from:
|
||||
|
||||
arp
|
||||
or
|
||||
arp -a
|
||||
|
||||
Compatibility:
|
||||
|
||||
@ -86,6 +90,16 @@ import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'arp parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'aix', 'freebsd', 'darwin']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -132,15 +146,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'aix', 'freebsd', 'darwin']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
|
||||
# code adapted from Conor Heine at:
|
||||
# https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
|
||||
|
@ -72,6 +72,16 @@ import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'df parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -166,11 +176,8 @@ def parse(data, raw=False, quiet=False):
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
|
||||
|
@ -323,6 +323,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'dig parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'aix', 'freebsd', 'darwin']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -509,11 +519,8 @@ def parse(data, raw=False, quiet=False):
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@ -51,6 +51,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'env parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -96,12 +106,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -19,6 +19,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'foo parser'
|
||||
author = 'John Doe'
|
||||
author_email = 'johndoe@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -58,12 +68,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@ -52,6 +52,16 @@ import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'free parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -104,12 +114,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
@ -69,6 +69,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = '/etc/fstab file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -119,12 +129,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@ -43,6 +43,16 @@ Examples:
|
||||
import jc
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'history parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -88,12 +98,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -60,6 +60,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = '/etc/hosts file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -100,12 +110,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@ -145,6 +145,17 @@ import jc.utils
|
||||
from ifconfigparser import IfconfigParser
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.5'
|
||||
description = 'ifconfig parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
details = 'Using ifconfig-parser package from https://github.com/KnightWhoSayNi/ifconfig-parser'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'aix', 'freebsd', 'darwin']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -238,12 +249,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'aix', 'freebsd', 'darwin']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -133,6 +133,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'iptables parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -222,12 +232,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
chain = {}
|
||||
|
@ -76,6 +76,16 @@ import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'jobs parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -124,12 +134,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -143,6 +143,16 @@ import re
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'ls parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -195,12 +205,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -211,11 +211,20 @@ Examples:
|
||||
...
|
||||
]
|
||||
"""
|
||||
import string
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
description = 'lsblk parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -311,12 +320,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
|
@ -106,6 +106,16 @@ import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'lsmod parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -157,12 +167,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
@ -96,6 +96,16 @@ import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'lsof parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -150,12 +160,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -55,6 +55,16 @@ Example:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'mount parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -141,12 +151,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
|
||||
|
@ -312,6 +312,16 @@ import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'netstat parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -513,12 +523,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
@ -176,6 +176,16 @@ import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'ps parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -264,12 +274,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
@ -100,6 +100,16 @@ import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'route parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -155,12 +165,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()[1:]
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
@ -250,6 +250,16 @@ import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'ss parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -323,12 +333,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
contains_colon = ['nl', 'p_raw', 'raw', 'udp', 'tcp', 'v_str', 'icmp6']
|
||||
raw_output = []
|
||||
|
@ -102,6 +102,15 @@ Examples:
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'stat parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
@ -174,12 +183,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@ -39,6 +39,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'systemctl parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -79,12 +89,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, systemctlbsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
|
@ -58,6 +58,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'systemctl list-jobs parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -105,12 +115,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, systemctlbsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
|
@ -33,6 +33,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'systemctl list-sockets parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -71,12 +81,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, systemctlbsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
|
@ -30,6 +30,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'systemctl list-unit-files parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -67,12 +77,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, systemctlbsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
|
@ -29,6 +29,16 @@ Example:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'uname -a parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -70,12 +80,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
parsed_line = data.split(maxsplit=3)
|
||||
|
@ -33,6 +33,16 @@ Example:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'uptime parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -89,12 +99,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -82,6 +82,16 @@ import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'w parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@ -131,12 +141,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
dictionary raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()[1:]
|
||||
header_text = cleandata[0].lower()
|
||||
|
Reference in New Issue
Block a user