mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
@ -1,5 +1,10 @@
|
|||||||
jc changelog
|
jc changelog
|
||||||
|
|
||||||
|
20200509 v1.10.10
|
||||||
|
- Fix ls parser issue where the first file was skipped for ls -R on some platforms
|
||||||
|
- Update last parser to handle 'gone - no logout' condition
|
||||||
|
- Update netstat parser to handle bluetooth section (ignore gracefully for now)
|
||||||
|
|
||||||
20200508 v1.10.9
|
20200508 v1.10.9
|
||||||
- Add license info to vendorized ifconfig-parser class
|
- Add license info to vendorized ifconfig-parser class
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.10.9'
|
version = '1.10.10'
|
||||||
description = 'jc cli output JSON conversion tool'
|
description = 'jc cli output JSON conversion tool'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
|
@ -72,7 +72,7 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.0'
|
version = '1.1'
|
||||||
description = 'last and lastb command parser'
|
description = 'last and lastb command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -122,6 +122,9 @@ def process(proc_data):
|
|||||||
if 'logout' in entry and entry['logout'] == 'still_logged_in':
|
if 'logout' in entry and entry['logout'] == 'still_logged_in':
|
||||||
entry['logout'] = 'still logged in'
|
entry['logout'] = 'still logged in'
|
||||||
|
|
||||||
|
if 'logout' in entry and entry['logout'] == 'gone_-_no_logout':
|
||||||
|
entry['logout'] = 'gone - no logout'
|
||||||
|
|
||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
@ -157,6 +160,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
entry = entry.replace('system boot', 'system_boot')
|
entry = entry.replace('system boot', 'system_boot')
|
||||||
entry = entry.replace(' still logged in', '- still_logged_in')
|
entry = entry.replace(' still logged in', '- still_logged_in')
|
||||||
|
entry = entry.replace(' gone - no logout', '- gone_-_no_logout')
|
||||||
|
|
||||||
linedata = entry.split()
|
linedata = entry.split()
|
||||||
if re.match(r'[MTWFS][ouerha][nedritnu] [JFMASOND][aepuco][nbrynlgptvc]', ' '.join(linedata[2:4])):
|
if re.match(r'[MTWFS][ouerha][nedritnu] [JFMASOND][aepuco][nbrynlgptvc]', ' '.join(linedata[2:4])):
|
||||||
|
@ -149,7 +149,7 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.3'
|
version = '1.4'
|
||||||
description = 'ls command parser'
|
description = 'ls command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -235,8 +235,9 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if not re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', linedata[0]) \
|
if not re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', linedata[0]) \
|
||||||
and linedata[0].endswith(':'):
|
and linedata[0].endswith(':'):
|
||||||
parent = linedata.pop(0)[:-1]
|
parent = linedata.pop(0)[:-1]
|
||||||
# Pop following total line
|
# Pop following total line if it exists
|
||||||
linedata.pop(0)
|
if re.match(r'total [0-9]+', linedata[0]):
|
||||||
|
linedata.pop(0)
|
||||||
|
|
||||||
if linedata:
|
if linedata:
|
||||||
# Check if -l was used to parse extra data
|
# Check if -l was used to parse extra data
|
||||||
|
@ -313,7 +313,7 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.3'
|
version = '1.4'
|
||||||
description = 'netstat command parser'
|
description = 'netstat command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -536,6 +536,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
raw_output = []
|
raw_output = []
|
||||||
network = False
|
network = False
|
||||||
socket = False
|
socket = False
|
||||||
|
bluetooth = False
|
||||||
headers = ''
|
headers = ''
|
||||||
network_list = []
|
network_list = []
|
||||||
socket_list = []
|
socket_list = []
|
||||||
@ -546,12 +547,20 @@ def parse(data, raw=False, quiet=False):
|
|||||||
network_list = []
|
network_list = []
|
||||||
network = True
|
network = True
|
||||||
socket = False
|
socket = False
|
||||||
|
bluetooth = False
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if line.startswith('Active UNIX'):
|
if line.startswith('Active UNIX'):
|
||||||
socket_list = []
|
socket_list = []
|
||||||
network = False
|
network = False
|
||||||
socket = True
|
socket = True
|
||||||
|
bluetooth = False
|
||||||
|
continue
|
||||||
|
|
||||||
|
if line.startswith('Active Bluetooth'):
|
||||||
|
network = False
|
||||||
|
socket = False
|
||||||
|
bluetooth = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if line.startswith('Proto'):
|
if line.startswith('Proto'):
|
||||||
@ -567,6 +576,10 @@ def parse(data, raw=False, quiet=False):
|
|||||||
socket_list.append(parse_socket(header_text, headers, line))
|
socket_list.append(parse_socket(header_text, headers, line))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if bluetooth:
|
||||||
|
# maybe implement later if requested
|
||||||
|
continue
|
||||||
|
|
||||||
for item in [network_list, socket_list]:
|
for item in [network_list, socket_list]:
|
||||||
for entry in item:
|
for entry in item:
|
||||||
raw_output.append(entry)
|
raw_output.append(entry)
|
||||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ with open('README.md', 'r') as f:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='jc',
|
name='jc',
|
||||||
version='1.10.9',
|
version='1.10.10',
|
||||||
author='Kelly Brazil',
|
author='Kelly Brazil',
|
||||||
author_email='kellyjonbrazil@gmail.com',
|
author_email='kellyjonbrazil@gmail.com',
|
||||||
description='This tool serializes the output of popular command line tools and filetypes to structured JSON output.',
|
description='This tool serializes the output of popular command line tools and filetypes to structured JSON output.',
|
||||||
|
2
tests/fixtures/centos-7.7/ls-R-newlines.json
vendored
2
tests/fixtures/centos-7.7/ls-R-newlines.json
vendored
@ -1 +1 @@
|
|||||||
[{"filename": "systemd-private-016de60725a3426792b93fc9f120b8f0-chronyd.service-oZqq4u", "parent": "."}, {"filename": "systemd-private-a30a5a178daa4042b42dfaf5ff9e5f68-chronyd.service-a1tpxv", "parent": "."}, {"filename": "systemd-private-af69d7360f3e40cfa947358c0fb5a6f8-chronyd.service-T3MQ4j", "parent": "."}, {"filename": "tmp.CvALl2jE6u", "parent": "."}, {"filename": "tmp.e7AlxSxY5a", "parent": "."}, {"filename": "tmp.uXm9yegjwj", "parent": "."}, {"filename": "a regular filename", "parent": "./lstest"}, {"filename": "this file has", "parent": "./lstest"}, {"filename": "a combination", "parent": "./lstest"}, {"filename": "of everything", "parent": "./lstest"}, {"filename": "this file has", "parent": "./lstest"}, {"filename": "a newline inside", "parent": "./lstest"}, {"filename": "this file has", "parent": "./lstest"}, {"filename": "four contiguous newlines inside", "parent": "./lstest"}, {"filename": "this file", "parent": "./lstest"}, {"filename": "has", "parent": "./lstest"}, {"filename": "six", "parent": "./lstest"}, {"filename": "newlines", "parent": "./lstest"}, {"filename": "within", "parent": "./lstest"}, {"filename": "this file starts with four newlines", "parent": "./lstest"}, {"filename": "this file starts with one newline", "parent": "./lstest"}]
|
[{"filename": "lstest", "parent": "."}, {"filename": "systemd-private-016de60725a3426792b93fc9f120b8f0-chronyd.service-oZqq4u", "parent": "."}, {"filename": "systemd-private-a30a5a178daa4042b42dfaf5ff9e5f68-chronyd.service-a1tpxv", "parent": "."}, {"filename": "systemd-private-af69d7360f3e40cfa947358c0fb5a6f8-chronyd.service-T3MQ4j", "parent": "."}, {"filename": "tmp.CvALl2jE6u", "parent": "."}, {"filename": "tmp.e7AlxSxY5a", "parent": "."}, {"filename": "tmp.uXm9yegjwj", "parent": "."}, {"filename": "a regular filename", "parent": "./lstest"}, {"filename": "this file has", "parent": "./lstest"}, {"filename": "a combination", "parent": "./lstest"}, {"filename": "of everything", "parent": "./lstest"}, {"filename": "this file has", "parent": "./lstest"}, {"filename": "a newline inside", "parent": "./lstest"}, {"filename": "this file has", "parent": "./lstest"}, {"filename": "four contiguous newlines inside", "parent": "./lstest"}, {"filename": "this file", "parent": "./lstest"}, {"filename": "has", "parent": "./lstest"}, {"filename": "six", "parent": "./lstest"}, {"filename": "newlines", "parent": "./lstest"}, {"filename": "within", "parent": "./lstest"}, {"filename": "this file starts with four newlines", "parent": "./lstest"}, {"filename": "this file starts with one newline", "parent": "./lstest"}]
|
||||||
|
2
tests/fixtures/centos-7.7/ls-R.json
vendored
2
tests/fixtures/centos-7.7/ls-R.json
vendored
File diff suppressed because one or more lines are too long
2
tests/fixtures/centos-7.7/ls-glob.json
vendored
2
tests/fixtures/centos-7.7/ls-glob.json
vendored
File diff suppressed because one or more lines are too long
1
tests/fixtures/fedora32/last.json
vendored
Normal file
1
tests/fixtures/fedora32/last.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"user": "kbrazil", "tty": "pts/0", "hostname": "192.168.71.1", "login": "Fri May 1 15:25", "logout": "gone - no logout"}, {"user": "kbrazil", "tty": "tty1", "hostname": null, "login": "Fri May 1 15:24", "logout": "gone - no logout"}, {"user": "reboot", "tty": "system boot", "hostname": "5.6.6-300.fc32.x", "login": "Fri May 1 15:24", "logout": "running"}, {"user": "kbrazil", "tty": "pts/0", "hostname": "192.168.71.1", "login": "Thu Apr 30 15:27", "logout": "15:22", "duration": "23:55"}, {"user": "kbrazil", "tty": "tty1", "hostname": null, "login": "Thu Apr 30 15:25", "logout": "down", "duration": "23:57"}, {"user": "reboot", "tty": "system boot", "hostname": "5.6.6-300.fc32.x", "login": "Thu Apr 30 15:22", "logout": "15:22", "duration": "1+00:00"}]
|
8
tests/fixtures/fedora32/last.out
vendored
Normal file
8
tests/fixtures/fedora32/last.out
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
kbrazil pts/0 192.168.71.1 Fri May 1 15:25 gone - no logout
|
||||||
|
kbrazil tty1 Fri May 1 15:24 gone - no logout
|
||||||
|
reboot system boot 5.6.6-300.fc32.x Fri May 1 15:24 still running
|
||||||
|
kbrazil pts/0 192.168.71.1 Thu Apr 30 15:27 - 15:22 (23:55)
|
||||||
|
kbrazil tty1 Thu Apr 30 15:25 - down (23:57)
|
||||||
|
reboot system boot 5.6.6-300.fc32.x Thu Apr 30 15:22 - 15:22 (1+00:00)
|
||||||
|
|
||||||
|
wtmp begins Thu Apr 30 15:22:02 2020
|
1
tests/fixtures/fedora32/netstat.json
vendored
Normal file
1
tests/fixtures/fedora32/netstat.json
vendored
Normal file
File diff suppressed because one or more lines are too long
139
tests/fixtures/fedora32/netstat.out
vendored
Normal file
139
tests/fixtures/fedora32/netstat.out
vendored
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
Active Internet connections (w/o servers)
|
||||||
|
Proto Recv-Q Send-Q Local Address Foreign Address State
|
||||||
|
tcp 0 0 localhost.localdoma:ssh 192.168.71.1:52882 ESTABLISHED
|
||||||
|
udp 0 0 localhost.locald:bootpc 192.168.71.254:bootps ESTABLISHED
|
||||||
|
Active UNIX domain sockets (w/o servers)
|
||||||
|
Proto RefCnt Flags Type State I-Node Path
|
||||||
|
unix 2 [ ] DGRAM 36371 /run/user/1000/systemd/notify
|
||||||
|
unix 3 [ ] DGRAM 15453 /run/systemd/notify
|
||||||
|
unix 9 [ ] DGRAM 15471 /run/systemd/journal/dev-log
|
||||||
|
unix 2 [ ] DGRAM 165956 @userdb-9bf8f59ca8f2bcce47a377edbaf8985d
|
||||||
|
unix 12 [ ] DGRAM 15479 /run/systemd/journal/socket
|
||||||
|
unix 2 [ ] DGRAM 29064 /var/run/chrony/chronyd.sock
|
||||||
|
unix 2 [ ] DGRAM 165866 @userdb-3f208fa7c8c6d98822a696ee7ca5e3ad
|
||||||
|
unix 2 [ ] DGRAM 165863 @userdb-da253950013f5ea3bc51a4049480d04e
|
||||||
|
unix 2 [ ] DGRAM 165865
|
||||||
|
unix 3 [ ] STREAM CONNECTED 36476
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31389
|
||||||
|
unix 3 [ ] STREAM CONNECTED 30999 /var/lib/sss/pipes/private/sbus-dp_implicit_files.692
|
||||||
|
unix 3 [ ] STREAM CONNECTED 33770 /run/dbus/system_bus_socket
|
||||||
|
unix 3 [ ] STREAM CONNECTED 30731
|
||||||
|
unix 2 [ ] DGRAM 24653
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31370 /var/lib/sss/pipes/private/sbus-dp_implicit_files.692
|
||||||
|
unix 2 [ ] DGRAM 165862
|
||||||
|
unix 2 [ ] DGRAM 33725
|
||||||
|
unix 3 [ ] STREAM CONNECTED 33885
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31173
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31019
|
||||||
|
unix 3 [ ] STREAM CONNECTED 33886
|
||||||
|
unix 3 [ ] STREAM CONNECTED 30735 /var/lib/sss/pipes/private/sbus-monitor
|
||||||
|
unix 3 [ ] STREAM CONNECTED 166231
|
||||||
|
unix 2 [ ] DGRAM 30987
|
||||||
|
unix 2 [ ] DGRAM 24745
|
||||||
|
unix 2 [ ] DGRAM 165955
|
||||||
|
unix 2 [ ] DGRAM 30575
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31062 /run/dbus/system_bus_socket
|
||||||
|
unix 2 [ ] STREAM CONNECTED 35419
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31399 /run/dbus/system_bus_socket
|
||||||
|
unix 2 [ ] DGRAM 32430
|
||||||
|
unix 2 [ ] DGRAM 29403
|
||||||
|
unix 3 [ ] STREAM CONNECTED 166232 /var/lib/sss/pipes/nss
|
||||||
|
unix 2 [ ] DGRAM 31127
|
||||||
|
unix 2 [ ] DGRAM 29538
|
||||||
|
unix 2 [ ] STREAM CONNECTED 33876
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31020 /var/lib/sss/pipes/private/sbus-monitor
|
||||||
|
unix 3 [ ] STREAM CONNECTED 30998
|
||||||
|
unix 3 [ ] STREAM CONNECTED 36475
|
||||||
|
unix 2 [ ] DGRAM 36002
|
||||||
|
unix 3 [ ] STREAM CONNECTED 33769
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31390 /var/lib/sss/pipes/private/sbus-monitor
|
||||||
|
unix 2 [ ] STREAM CONNECTED 33132
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31398
|
||||||
|
unix 3 [ ] STREAM CONNECTED 30022
|
||||||
|
unix 3 [ ] DGRAM 24748
|
||||||
|
unix 3 [ ] DGRAM 24747
|
||||||
|
unix 2 [ ] DGRAM 36348
|
||||||
|
unix 2 [ ] DGRAM 32085
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31168 /run/systemd/journal/stdout
|
||||||
|
unix 3 [ ] DGRAM 15455
|
||||||
|
unix 3 [ ] STREAM CONNECTED 30830
|
||||||
|
unix 3 [ ] STREAM CONNECTED 26911
|
||||||
|
unix 3 [ ] STREAM CONNECTED 35960
|
||||||
|
unix 2 [ ] DGRAM 24662
|
||||||
|
unix 2 [ ] STREAM CONNECTED 36345
|
||||||
|
unix 3 [ ] STREAM CONNECTED 32538
|
||||||
|
unix 3 [ ] STREAM CONNECTED 28747
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31026
|
||||||
|
unix 3 [ ] DGRAM 28615
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31713 /run/dbus/system_bus_socket
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31167
|
||||||
|
unix 3 [ ] STREAM CONNECTED 35989 /run/systemd/journal/stdout
|
||||||
|
unix 3 [ ] STREAM CONNECTED 36303 /run/systemd/journal/stdout
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31809 /run/systemd/journal/stdout
|
||||||
|
unix 3 [ ] STREAM CONNECTED 29396 /run/systemd/journal/stdout
|
||||||
|
unix 2 [ ] STREAM CONNECTED 34911
|
||||||
|
unix 3 [ ] DGRAM 36374
|
||||||
|
unix 2 [ ] STREAM CONNECTED 32241
|
||||||
|
unix 3 [ ] STREAM CONNECTED 32057 /run/dbus/system_bus_socket
|
||||||
|
unix 3 [ ] STREAM CONNECTED 32000 /run/systemd/journal/stdout
|
||||||
|
unix 2 [ ] DGRAM 33083
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31017
|
||||||
|
unix 3 [ ] DGRAM 36373
|
||||||
|
unix 3 [ ] STREAM CONNECTED 34101
|
||||||
|
unix 3 [ ] STREAM CONNECTED 32539 /run/systemd/journal/stdout
|
||||||
|
unix 3 [ ] STREAM CONNECTED 26914
|
||||||
|
unix 3 [ ] STREAM CONNECTED 29395
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31022
|
||||||
|
unix 3 [ ] DGRAM 15456
|
||||||
|
unix 3 [ ] STREAM CONNECTED 29251 /run/systemd/journal/stdout
|
||||||
|
unix 3 [ ] STREAM CONNECTED 26915
|
||||||
|
unix 2 [ ] STREAM CONNECTED 33052
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31999
|
||||||
|
unix 2 [ ] DGRAM 29496
|
||||||
|
unix 3 [ ] STREAM CONNECTED 28400
|
||||||
|
unix 3 [ ] STREAM CONNECTED 36378 /run/dbus/system_bus_socket
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31808
|
||||||
|
unix 3 [ ] STREAM CONNECTED 29250
|
||||||
|
unix 3 [ ] STREAM CONNECTED 24582
|
||||||
|
unix 3 [ ] STREAM CONNECTED 32056
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31347
|
||||||
|
unix 3 [ ] STREAM CONNECTED 28678 /run/systemd/journal/stdout
|
||||||
|
unix 2 [ ] DGRAM 30980
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31348 /run/systemd/journal/stdout
|
||||||
|
unix 3 [ ] STREAM CONNECTED 28677
|
||||||
|
unix 3 [ ] STREAM CONNECTED 34102 /run/dbus/system_bus_socket
|
||||||
|
unix 3 [ ] STREAM CONNECTED 24805 /run/systemd/journal/stdout
|
||||||
|
unix 3 [ ] STREAM CONNECTED 29322 /run/systemd/journal/stdout
|
||||||
|
unix 2 [ ] DGRAM 36357
|
||||||
|
unix 3 [ ] STREAM CONNECTED 30832 /run/systemd/journal/stdout
|
||||||
|
unix 2 [ ] DGRAM 26913
|
||||||
|
unix 2 [ ] STREAM CONNECTED 32010
|
||||||
|
unix 3 [ ] STREAM CONNECTED 28748 /run/systemd/journal/stdout
|
||||||
|
unix 2 [ ] DGRAM 28602
|
||||||
|
unix 3 [ ] STREAM CONNECTED 28401 /run/systemd/journal/stdout
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31069 /run/dbus/system_bus_socket
|
||||||
|
unix 3 [ ] DGRAM 28616
|
||||||
|
unix 3 [ ] STREAM CONNECTED 32334 /run/systemd/journal/stdout
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31712
|
||||||
|
unix 3 [ ] STREAM CONNECTED 36302
|
||||||
|
unix 3 [ ] STREAM CONNECTED 32333
|
||||||
|
unix 3 [ ] STREAM CONNECTED 32093
|
||||||
|
unix 3 [ ] STREAM CONNECTED 26912
|
||||||
|
unix 2 [ ] STREAM CONNECTED 35774
|
||||||
|
unix 3 [ ] STREAM CONNECTED 29321
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31025
|
||||||
|
unix 3 [ ] STREAM CONNECTED 28470
|
||||||
|
unix 3 [ ] STREAM CONNECTED 32094 /run/dbus/system_bus_socket
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31259 /run/systemd/journal/stdout
|
||||||
|
unix 2 [ ] DGRAM 36471
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31054
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31064 /run/dbus/system_bus_socket
|
||||||
|
unix 3 [ ] STREAM CONNECTED 28471 /run/systemd/journal/stdout
|
||||||
|
unix 3 [ ] STREAM CONNECTED 36377
|
||||||
|
unix 2 [ ] STREAM CONNECTED 35788
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31258
|
||||||
|
unix 3 [ ] STREAM CONNECTED 31065 /run/dbus/system_bus_socket
|
||||||
|
Active Bluetooth connections (w/o servers)
|
||||||
|
Proto Destination Source State PSM DCID SCID IMTU OMTU Security
|
||||||
|
Proto Destination Source State Channel
|
||||||
|
|
2
tests/fixtures/osx-10.14.6/ls-glob.json
vendored
2
tests/fixtures/osx-10.14.6/ls-glob.json
vendored
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
|||||||
[{"filename": "systemd-private-65c1089f1d4c4cf5bc50ca55478abfde-systemd-resolved.service-La9AqY", "parent": "."}, {"filename": "systemd-private-65c1089f1d4c4cf5bc50ca55478abfde-systemd-timesyncd.service-L7q4cJ", "parent": "."}, {"filename": "vmware-root_670-2722828838", "parent": "."}, {"filename": "a regular filename", "parent": "./lstest"}, {"filename": "this file has", "parent": "./lstest"}, {"filename": "a combination", "parent": "./lstest"}, {"filename": "of everything", "parent": "./lstest"}, {"filename": "this file has", "parent": "./lstest"}, {"filename": "a newline inside", "parent": "./lstest"}, {"filename": "this file has", "parent": "./lstest"}, {"filename": "four contiguous newlines inside", "parent": "./lstest"}, {"filename": "this file", "parent": "./lstest"}, {"filename": "has", "parent": "./lstest"}, {"filename": "six", "parent": "./lstest"}, {"filename": "newlines", "parent": "./lstest"}, {"filename": "within", "parent": "./lstest"}, {"filename": "this file starts with four newlines", "parent": "./lstest"}, {"filename": "this file starts with one newline", "parent": "./lstest"}]
|
[{"filename": "lstest", "parent": "."}, {"filename": "systemd-private-65c1089f1d4c4cf5bc50ca55478abfde-systemd-resolved.service-La9AqY", "parent": "."}, {"filename": "systemd-private-65c1089f1d4c4cf5bc50ca55478abfde-systemd-timesyncd.service-L7q4cJ", "parent": "."}, {"filename": "vmware-root_670-2722828838", "parent": "."}, {"filename": "a regular filename", "parent": "./lstest"}, {"filename": "this file has", "parent": "./lstest"}, {"filename": "a combination", "parent": "./lstest"}, {"filename": "of everything", "parent": "./lstest"}, {"filename": "this file has", "parent": "./lstest"}, {"filename": "a newline inside", "parent": "./lstest"}, {"filename": "this file has", "parent": "./lstest"}, {"filename": "four contiguous newlines inside", "parent": "./lstest"}, {"filename": "this file", "parent": "./lstest"}, {"filename": "has", "parent": "./lstest"}, {"filename": "six", "parent": "./lstest"}, {"filename": "newlines", "parent": "./lstest"}, {"filename": "within", "parent": "./lstest"}, {"filename": "this file starts with four newlines", "parent": "./lstest"}, {"filename": "this file starts with one newline", "parent": "./lstest"}]
|
||||||
|
2
tests/fixtures/ubuntu-18.04/ls-R.json
vendored
2
tests/fixtures/ubuntu-18.04/ls-R.json
vendored
File diff suppressed because one or more lines are too long
2
tests/fixtures/ubuntu-18.04/ls-glob.json
vendored
2
tests/fixtures/ubuntu-18.04/ls-glob.json
vendored
File diff suppressed because one or more lines are too long
@ -31,6 +31,9 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/last-w.out'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/last-w.out'), 'r', encoding='utf-8') as f:
|
||||||
self.ubuntu_18_4_last_w = f.read()
|
self.ubuntu_18_4_last_w = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/fedora32/last.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.fedora32_last = f.read()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/last.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/last.json'), 'r', encoding='utf-8') as f:
|
||||||
self.centos_7_7_last_json = json.loads(f.read())
|
self.centos_7_7_last_json = json.loads(f.read())
|
||||||
@ -53,6 +56,9 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/last-w.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/last-w.json'), 'r', encoding='utf-8') as f:
|
||||||
self.ubuntu_18_4_last_w_json = json.loads(f.read())
|
self.ubuntu_18_4_last_w_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/fedora32/last.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.fedora32_last_json = json.loads(f.read())
|
||||||
|
|
||||||
def test_last_centos_7_7(self):
|
def test_last_centos_7_7(self):
|
||||||
"""
|
"""
|
||||||
Test plain 'last' on Centos 7.7
|
Test plain 'last' on Centos 7.7
|
||||||
@ -95,6 +101,12 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.last.parse(self.ubuntu_18_4_last_w, quiet=True), self.ubuntu_18_4_last_w_json)
|
self.assertEqual(jc.parsers.last.parse(self.ubuntu_18_4_last_w, quiet=True), self.ubuntu_18_4_last_w_json)
|
||||||
|
|
||||||
|
def test_last_fedora32(self):
|
||||||
|
"""
|
||||||
|
Test plain 'last' on Fedora32
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.last.parse(self.fedora32_last, quiet=True), self.fedora32_last_json)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -40,6 +40,9 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/netstat-sudo-aeep.out'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/netstat-sudo-aeep.out'), 'r', encoding='utf-8') as f:
|
||||||
self.ubuntu_18_4_netstat_sudo_aeep = f.read()
|
self.ubuntu_18_4_netstat_sudo_aeep = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/fedora32/netstat.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.fedora32_netstat = f.read()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/netstat.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/netstat.json'), 'r', encoding='utf-8') as f:
|
||||||
self.centos_7_7_netstat_json = json.loads(f.read())
|
self.centos_7_7_netstat_json = json.loads(f.read())
|
||||||
@ -71,6 +74,9 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/netstat-sudo-aeep.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/netstat-sudo-aeep.json'), 'r', encoding='utf-8') as f:
|
||||||
self.ubuntu_18_4_netstat_sudo_aeep_json = json.loads(f.read())
|
self.ubuntu_18_4_netstat_sudo_aeep_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/fedora32/netstat.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.fedora32_netstat_json = json.loads(f.read())
|
||||||
|
|
||||||
def test_netstat_centos_7_7(self):
|
def test_netstat_centos_7_7(self):
|
||||||
"""
|
"""
|
||||||
Test 'netstat' on Centos 7.7
|
Test 'netstat' on Centos 7.7
|
||||||
@ -131,6 +137,12 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.netstat.parse(self.ubuntu_18_4_netstat_sudo_aeep, quiet=True), self.ubuntu_18_4_netstat_sudo_aeep_json)
|
self.assertEqual(jc.parsers.netstat.parse(self.ubuntu_18_4_netstat_sudo_aeep, quiet=True), self.ubuntu_18_4_netstat_sudo_aeep_json)
|
||||||
|
|
||||||
|
def test_netstat_fedora32(self):
|
||||||
|
"""
|
||||||
|
Test 'netstat' on Fedora32
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.netstat.parse(self.fedora32_netstat, quiet=True), self.fedora32_netstat_json)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user