mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
@ -1,5 +1,13 @@
|
||||
jc changelog
|
||||
|
||||
20210106 v1.14.1
|
||||
- Add iw-scan parser tested on linux (beta)
|
||||
- Update date parser for Ubuntu 20.04 support
|
||||
- Update last parser for last -F support
|
||||
- Update last parser to add convenience fields and augment data for easier parsing
|
||||
- Update man page
|
||||
- Minor documentation updates
|
||||
|
||||
20201231 v1.14.0
|
||||
- Add hashsum parser tested on linux, macos
|
||||
- Add hash parser tested on linux, macos
|
||||
|
92
EXAMPLES.md
92
EXAMPLES.md
@ -412,6 +412,7 @@ date | jc --date -p # or: jc -p date
|
||||
"hour": 16,
|
||||
"minute": 48,
|
||||
"second": 11,
|
||||
"period": null,
|
||||
"month": "Jul",
|
||||
"weekday": "Fri",
|
||||
"weekday_num": 6,
|
||||
@ -1195,6 +1196,97 @@ iptables --line-numbers -v -L -t nat | jc --iptables -p # or: jc -p ip
|
||||
}
|
||||
]
|
||||
```
|
||||
### iw dev `device` scan
|
||||
```bash
|
||||
iw dev wlan0 scan | jc --iw-scan -p # or: jc -p iw dev wlan0 scan
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"bssid": "71:31:72:65:e1:a2",
|
||||
"interface": "wlan0",
|
||||
"freq": 2462,
|
||||
"capability": "ESS Privacy ShortSlotTime (0x0411)",
|
||||
"ssid": "WLAN-1234",
|
||||
"supported_rates": [
|
||||
1.0,
|
||||
2.0,
|
||||
5.5,
|
||||
11.0,
|
||||
18.0,
|
||||
24.0,
|
||||
36.0,
|
||||
54.0
|
||||
],
|
||||
"erp": "<no flags>",
|
||||
"erp_d4.0": "<no flags>",
|
||||
"rsn": "Version: 1",
|
||||
"group_cipher": "CCMP",
|
||||
"pairwise_ciphers": "CCMP",
|
||||
"authentication_suites": "PSK",
|
||||
"capabilities": "0x186c",
|
||||
"extended_supported_rates": [
|
||||
6.0,
|
||||
9.0,
|
||||
12.0,
|
||||
48.0
|
||||
],
|
||||
"ht_rx_mcs_rate_indexes_supported": "0-15",
|
||||
"primary_channel": 11,
|
||||
"secondary_channel_offset": "no secondary",
|
||||
"rifs": 1,
|
||||
"ht_protection": "no",
|
||||
"non-gf_present": 1,
|
||||
"obss_non-gf_present": 0,
|
||||
"dual_beacon": 0,
|
||||
"dual_cts_protection": 0,
|
||||
"stbc_beacon": 0,
|
||||
"l-sig_txop_prot": 0,
|
||||
"pco_active": 0,
|
||||
"pco_phase": 0,
|
||||
"bss_width_channel_transition_delay_factor": 5,
|
||||
"extended_capabilities": "HT Information Exchange Supported",
|
||||
"wmm": "Parameter version 1",
|
||||
"be": "CW 15-1023, AIFSN 3",
|
||||
"bk": "CW 15-1023, AIFSN 7",
|
||||
"vi": "CW 7-15, AIFSN 2, TXOP 3008 usec",
|
||||
"vo": "CW 3-7, AIFSN 2, TXOP 1504 usec",
|
||||
"wps": "Version: 1.0",
|
||||
"wi-fi_protected_setup_state": "2 (Configured)",
|
||||
"selected_registrar": "0x0",
|
||||
"response_type": "3 (AP)",
|
||||
"uuid": "00000000-0000-0003-0000-75317074f1a2",
|
||||
"manufacturer": "Corporation",
|
||||
"model": "VGV8539JW",
|
||||
"model_number": "1.47.000",
|
||||
"serial_number": "J144024542",
|
||||
"primary_device_type": "6-0050f204-1",
|
||||
"device_name": "Wireless Router(WFA)",
|
||||
"config_methods": "Label, PBC",
|
||||
"rf_bands": "0x3",
|
||||
"tsf_usec": 212098649788,
|
||||
"sta_channel_width_mhz": 20,
|
||||
"passive_dwell_tus": 20,
|
||||
"active_dwell_tus": 10,
|
||||
"channel_width_trigger_scan_interval_s": 300,
|
||||
"scan_passive_total_per_channel_tus": 200,
|
||||
"scan_active_total_per_channel_tus": 20,
|
||||
"beacon_interval_tus": 100,
|
||||
"signal_dbm": -80.0,
|
||||
"last_seen_ms": 11420,
|
||||
"selected_rates": [
|
||||
1.0,
|
||||
2.0,
|
||||
5.5,
|
||||
11.0
|
||||
],
|
||||
"obss_scan_activity_threshold_percent": 0.25,
|
||||
"ds_parameter_set_channel": 11,
|
||||
"max_amsdu_length_bytes": 7935,
|
||||
"minimum_rx_ampdu_time_spacing_usec": 16
|
||||
}
|
||||
]
|
||||
```
|
||||
### jobs
|
||||
```bash
|
||||
jobs -l | jc --jobs -p # or: jc -p jobs
|
||||
|
@ -138,13 +138,14 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio
|
||||
- `--group` enables the `/etc/group` file parser
|
||||
- `--gshadow` enables the `/etc/gshadow` file parser
|
||||
- `--hash` enables the `hash` command parser
|
||||
- `--hashsum` enables the `hashsum` command parser (`md5sum`, `shasum`, etc.)
|
||||
- `--hashsum` enables the `hashsum` command parser (`md5`, `md5sum`, `shasum`, `sha1sum`, `sha224sum`, `sha256sum`, `sha384sum`, `sha512sum`)
|
||||
- `--history` enables the `history` command parser
|
||||
- `--hosts` enables the `/etc/hosts` file parser
|
||||
- `--id` enables the `id` command parser
|
||||
- `--ifconfig` enables the `ifconfig` command parser
|
||||
- `--ini` enables the `INI` file parser
|
||||
- `--iptables` enables the `iptables` command parser
|
||||
- `--iw-scan` enables the `iw dev <device> scan` command parser (beta)
|
||||
- `--jobs` enables the `jobs` command parser
|
||||
- `--kv` enables the `Key/Value` file parser
|
||||
- `--last` enables the `last` and `lastb` command parser
|
||||
@ -228,7 +229,8 @@ cat lsof.out | jc --lsof -q
|
||||
|
||||
Tested on:
|
||||
- Centos 7.7
|
||||
- Ubuntu 18.4
|
||||
- Ubuntu 18.04
|
||||
- Ubuntu 20.04
|
||||
- Fedora32
|
||||
- OSX 10.11.6
|
||||
- OSX 10.14.6
|
||||
|
@ -32,6 +32,7 @@ pydocmd simple jc.parsers.id+ > ../docs/parsers/id.md
|
||||
pydocmd simple jc.parsers.ifconfig+ > ../docs/parsers/ifconfig.md
|
||||
pydocmd simple jc.parsers.ini+ > ../docs/parsers/ini.md
|
||||
pydocmd simple jc.parsers.iptables+ > ../docs/parsers/iptables.md
|
||||
pydocmd simple jc.parsers.iw_scan+ > ../docs/parsers/iw_scan.md
|
||||
pydocmd simple jc.parsers.jobs+ > ../docs/parsers/jobs.md
|
||||
pydocmd simple jc.parsers.kv+ > ../docs/parsers/kv.md
|
||||
pydocmd simple jc.parsers.last+ > ../docs/parsers/last.md
|
||||
|
@ -77,7 +77,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -109,11 +109,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
[
|
||||
{
|
||||
"ssid": string,
|
||||
@ -144,5 +144,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -119,11 +119,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -154,5 +154,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -101,11 +101,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -157,5 +157,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -61,11 +61,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -91,5 +91,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -156,7 +156,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -153,7 +153,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -80,11 +80,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Each dictionary represents a row in the csv file:
|
||||
List of Dictionaries. Each Dictionary represents a row in the csv file:
|
||||
|
||||
[
|
||||
{
|
||||
@ -109,5 +109,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -29,6 +29,7 @@ Examples:
|
||||
"hour": 16,
|
||||
"minute": 48,
|
||||
"second": 11,
|
||||
"period": null,
|
||||
"month": "Jul",
|
||||
"weekday": "Fri",
|
||||
"weekday_num": 6,
|
||||
@ -63,7 +64,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
@ -76,6 +77,7 @@ Returns:
|
||||
"hour": integer,
|
||||
"minute": integer,
|
||||
"second": integer,
|
||||
"period": string,
|
||||
"month": string,
|
||||
"weekday": string,
|
||||
"weekday_num": integer,
|
||||
|
@ -95,11 +95,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -134,5 +134,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -347,11 +347,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -421,5 +421,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -125,11 +125,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -162,5 +162,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -95,11 +95,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -124,5 +124,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -77,11 +77,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -107,5 +107,5 @@ Parameters:
|
||||
Returns:
|
||||
|
||||
Dictionary of raw structured data or
|
||||
list of dictionaries of processed structured data
|
||||
List of Dictionaries of processed structured data
|
||||
|
||||
|
@ -70,11 +70,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -99,5 +99,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -75,11 +75,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -109,5 +109,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -89,11 +89,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -122,5 +122,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -113,11 +113,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -146,5 +146,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -79,11 +79,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -114,5 +114,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -45,11 +45,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -74,5 +74,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -76,11 +76,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -105,5 +105,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -65,11 +65,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -95,5 +95,5 @@ Parameters:
|
||||
Returns:
|
||||
|
||||
Dictionary of raw structured data or
|
||||
list of dictionaries of processed structured data
|
||||
List of Dictionaries of processed structured data
|
||||
|
||||
|
@ -80,11 +80,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -111,5 +111,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -93,7 +93,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
@ -142,5 +142,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
|
@ -174,11 +174,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -229,5 +229,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -69,7 +69,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -157,11 +157,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -200,5 +200,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
160
docs/parsers/iw_scan.md
Normal file
160
docs/parsers/iw_scan.md
Normal file
@ -0,0 +1,160 @@
|
||||
|
||||
# jc.parsers.iw_scan
|
||||
jc - JSON CLI output utility `iw DEV scan` command output parser
|
||||
|
||||
This parser is considered beta quality. Not all fields are parsed.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ iw dev wlan0 scan | jc --iw-scan
|
||||
|
||||
or
|
||||
|
||||
$ jc iw dev wlan0 scan
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.iw-scan
|
||||
result = jc.parsers.iw-scan.parse(iw-scan_command_output)
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ iw dev wlan0 scan | jc --iw-scan -p
|
||||
[
|
||||
{
|
||||
"bssid": "71:31:72:65:e1:a2",
|
||||
"interface": "wlan0",
|
||||
"freq": 2462,
|
||||
"capability": "ESS Privacy ShortSlotTime (0x0411)",
|
||||
"ssid": "WLAN-1234",
|
||||
"supported_rates": [
|
||||
1.0,
|
||||
2.0,
|
||||
5.5,
|
||||
11.0,
|
||||
18.0,
|
||||
24.0,
|
||||
36.0,
|
||||
54.0
|
||||
],
|
||||
"erp": "<no flags>",
|
||||
"erp_d4.0": "<no flags>",
|
||||
"rsn": "Version: 1",
|
||||
"group_cipher": "CCMP",
|
||||
"pairwise_ciphers": "CCMP",
|
||||
"authentication_suites": "PSK",
|
||||
"capabilities": "0x186c",
|
||||
"extended_supported_rates": [
|
||||
6.0,
|
||||
9.0,
|
||||
12.0,
|
||||
48.0
|
||||
],
|
||||
"ht_rx_mcs_rate_indexes_supported": "0-15",
|
||||
"primary_channel": 11,
|
||||
"secondary_channel_offset": "no secondary",
|
||||
"rifs": 1,
|
||||
"ht_protection": "no",
|
||||
"non-gf_present": 1,
|
||||
"obss_non-gf_present": 0,
|
||||
"dual_beacon": 0,
|
||||
"dual_cts_protection": 0,
|
||||
"stbc_beacon": 0,
|
||||
"l-sig_txop_prot": 0,
|
||||
"pco_active": 0,
|
||||
"pco_phase": 0,
|
||||
"bss_width_channel_transition_delay_factor": 5,
|
||||
"extended_capabilities": "HT Information Exchange Supported",
|
||||
"wmm": "Parameter version 1",
|
||||
"be": "CW 15-1023, AIFSN 3",
|
||||
"bk": "CW 15-1023, AIFSN 7",
|
||||
"vi": "CW 7-15, AIFSN 2, TXOP 3008 usec",
|
||||
"vo": "CW 3-7, AIFSN 2, TXOP 1504 usec",
|
||||
"wps": "Version: 1.0",
|
||||
"wi-fi_protected_setup_state": "2 (Configured)",
|
||||
"selected_registrar": "0x0",
|
||||
"response_type": "3 (AP)",
|
||||
"uuid": "00000000-0000-0003-0000-75317074f1a2",
|
||||
"manufacturer": "Corporation",
|
||||
"model": "VGV8539JW",
|
||||
"model_number": "1.47.000",
|
||||
"serial_number": "J144024542",
|
||||
"primary_device_type": "6-0050f204-1",
|
||||
"device_name": "Wireless Router(WFA)",
|
||||
"config_methods": "Label, PBC",
|
||||
"rf_bands": "0x3",
|
||||
"tsf_usec": 212098649788,
|
||||
"sta_channel_width_mhz": 20,
|
||||
"passive_dwell_tus": 20,
|
||||
"active_dwell_tus": 10,
|
||||
"channel_width_trigger_scan_interval_s": 300,
|
||||
"scan_passive_total_per_channel_tus": 200,
|
||||
"scan_active_total_per_channel_tus": 20,
|
||||
"beacon_interval_tus": 100,
|
||||
"signal_dbm": -80.0,
|
||||
"last_seen_ms": 11420,
|
||||
"selected_rates": [
|
||||
1.0,
|
||||
2.0,
|
||||
5.5,
|
||||
11.0
|
||||
],
|
||||
"obss_scan_activity_threshold_percent": 0.25,
|
||||
"ds_parameter_set_channel": 11,
|
||||
"max_amsdu_length_bytes": 7935,
|
||||
"minimum_rx_ampdu_time_spacing_usec": 16
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
```
|
||||
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
]
|
||||
{
|
||||
"foo": string/integer/float, # best guess based on value
|
||||
"bar": string/integer/float,
|
||||
"baz": string/integer/float
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
@ -99,11 +99,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -131,5 +131,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
# jc.parsers.last
|
||||
jc - JSON CLI output utility `last` and `lastb` command output parser
|
||||
|
||||
Supports -w and -F options.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ last | jc --last
|
||||
@ -21,30 +23,36 @@ Compatibility:
|
||||
|
||||
Examples:
|
||||
|
||||
$ last | jc --last -p
|
||||
$ last -F | jc --last -p
|
||||
[
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttys002",
|
||||
"hostname": null,
|
||||
"login": "Thu Feb 27 14:31",
|
||||
"login": "Mon Dec 28 17:24:10 2020",
|
||||
"logout": "still logged in"
|
||||
},
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttys003",
|
||||
"hostname": null,
|
||||
"login": "Thu Feb 27 10:38",
|
||||
"logout": "10:38",
|
||||
"duration": "00:00"
|
||||
"login": "Mon Dec 28 17:24:10 2020",
|
||||
"logout": "Mon Dec 28 17:25:01 2020",
|
||||
"duration": "00:00",
|
||||
"login_epoch": 1565891826,
|
||||
"logout_epoch": 1565895404,
|
||||
"duration_seconds": 3578
|
||||
},
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttys003",
|
||||
"hostname": null,
|
||||
"login": "Thu Feb 27 10:18",
|
||||
"logout": "10:18",
|
||||
"duration": "00:00"
|
||||
"login": "Mon Dec 28 17:24:10 2020",
|
||||
"logout": "Mon Dec 28 17:25:01 2020",
|
||||
"duration": "00:00",
|
||||
"login_epoch": 1565891826,
|
||||
"logout_epoch": 1565895404,
|
||||
"duration_seconds": 3578
|
||||
},
|
||||
...
|
||||
]
|
||||
@ -94,20 +102,23 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"user": string,
|
||||
"tty": string,
|
||||
"hostname": string,
|
||||
"login": string,
|
||||
"logout": string,
|
||||
"duration": string
|
||||
"user": string,
|
||||
"tty": string,
|
||||
"hostname": string,
|
||||
"login": string,
|
||||
"logout": string,
|
||||
"duration": string,
|
||||
"login_epoch": integer, # available with last -F option
|
||||
"logout_epoch": integer, # available with last -F option
|
||||
"duration_seconds": integer # available with last -F option
|
||||
}
|
||||
]
|
||||
|
||||
@ -127,5 +138,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -166,11 +166,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -201,5 +201,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -238,11 +238,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -305,5 +305,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -129,11 +129,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -162,5 +162,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -119,11 +119,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -156,5 +156,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -79,11 +79,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -112,5 +112,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -270,11 +270,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -391,5 +391,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -205,11 +205,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -244,5 +244,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -97,11 +97,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -131,5 +131,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -132,7 +132,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -54,11 +54,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -84,5 +84,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -65,11 +65,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -103,5 +103,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -199,11 +199,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -243,5 +243,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -106,11 +106,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -147,5 +147,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -103,11 +103,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -138,5 +138,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -273,11 +273,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -317,5 +317,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -127,11 +127,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -177,5 +177,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -63,7 +63,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -63,11 +63,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -95,5 +95,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -82,11 +82,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -113,5 +113,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -57,11 +57,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -87,5 +87,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -54,11 +54,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -83,5 +83,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -61,7 +61,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -130,7 +130,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -119,7 +119,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -51,7 +51,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -57,7 +57,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -105,11 +105,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -140,5 +140,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -60,11 +60,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -91,5 +91,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -125,11 +125,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -161,5 +161,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@ -77,7 +77,7 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -89,11 +89,11 @@ Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Each dictionary represents a YAML document:
|
||||
List of Dictionaries. Each dictionary represents a YAML document:
|
||||
|
||||
[
|
||||
{
|
||||
@ -118,5 +118,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries representing the YAML documents.
|
||||
|
||||
|
@ -21,7 +21,7 @@ import jc.appdirs as appdirs
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.14.0'
|
||||
version = '1.14.1'
|
||||
description = 'JSON CLI output utility'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -57,6 +57,7 @@ parsers = [
|
||||
'ifconfig',
|
||||
'ini',
|
||||
'iptables',
|
||||
'iw-scan',
|
||||
'jobs',
|
||||
'kv',
|
||||
'last',
|
||||
|
@ -83,7 +83,7 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -116,11 +116,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
[
|
||||
{
|
||||
"ssid": string,
|
||||
@ -173,7 +173,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -125,11 +125,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -173,7 +173,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -108,11 +108,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -178,7 +178,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -67,11 +67,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -105,7 +105,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -163,7 +163,7 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -159,7 +159,7 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -86,11 +86,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Each dictionary represents a row in the csv file:
|
||||
List of Dictionaries. Each Dictionary represents a row in the csv file:
|
||||
|
||||
[
|
||||
{
|
||||
@ -116,7 +116,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -27,6 +27,7 @@ Examples:
|
||||
"hour": 16,
|
||||
"minute": 48,
|
||||
"second": 11,
|
||||
"period": null,
|
||||
"month": "Jul",
|
||||
"weekday": "Fri",
|
||||
"weekday_num": 6,
|
||||
@ -49,7 +50,7 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = 'date command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -68,7 +69,7 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
@ -81,6 +82,7 @@ def process(proc_data):
|
||||
"hour": integer,
|
||||
"minute": integer,
|
||||
"second": integer,
|
||||
"period": string,
|
||||
"month": string,
|
||||
"weekday": string,
|
||||
"weekday_num": integer,
|
||||
@ -120,6 +122,7 @@ def process(proc_data):
|
||||
"hour": int(proc_data['hour']),
|
||||
"minute": int(proc_data['minute']),
|
||||
"second": int(proc_data['second']),
|
||||
"period": proc_data['period'] if 'period' in proc_data else None,
|
||||
"month": proc_data['month'],
|
||||
"weekday": proc_data['weekday'],
|
||||
"weekday_num": weekday_map[proc_data['weekday']],
|
||||
@ -152,16 +155,31 @@ def parse(data, raw=False, quiet=False):
|
||||
data = data.replace(':', ' ')
|
||||
split_data = data.split()
|
||||
|
||||
raw_output = {
|
||||
"year": split_data[7],
|
||||
"month": split_data[1],
|
||||
"day": split_data[2],
|
||||
"weekday": split_data[0],
|
||||
"hour": split_data[3],
|
||||
"minute": split_data[4],
|
||||
"second": split_data[5],
|
||||
"timezone": split_data[6]
|
||||
}
|
||||
# date v8.32 uses a different format depending on locale, so need to support LANG=en_US.UTF-8
|
||||
if len(split_data) == 9 and ('AM' in split_data or 'am' in split_data or 'PM' in split_data or 'pm' in split_data):
|
||||
raw_output = {
|
||||
"year": split_data[8],
|
||||
"month": split_data[1],
|
||||
"day": split_data[2],
|
||||
"weekday": split_data[0],
|
||||
"hour": split_data[3],
|
||||
"minute": split_data[4],
|
||||
"second": split_data[5],
|
||||
"period": split_data[6],
|
||||
"timezone": split_data[7]
|
||||
}
|
||||
else:
|
||||
# standard LANG=C date output
|
||||
raw_output = {
|
||||
"year": split_data[7],
|
||||
"month": split_data[1],
|
||||
"day": split_data[2],
|
||||
"weekday": split_data[0],
|
||||
"hour": split_data[3],
|
||||
"minute": split_data[4],
|
||||
"second": split_data[5],
|
||||
"timezone": split_data[6]
|
||||
}
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
@ -101,11 +101,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -186,7 +186,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
if not quiet:
|
||||
|
@ -352,11 +352,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -566,7 +566,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
if not quiet:
|
||||
|
@ -131,11 +131,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -180,7 +180,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -102,11 +102,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -140,7 +140,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -82,11 +82,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -120,7 +120,7 @@ def parse(data, raw=False, quiet=False):
|
||||
Returns:
|
||||
|
||||
Dictionary of raw structured data or
|
||||
list of dictionaries of processed structured data
|
||||
List of Dictionaries of processed structured data
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -76,11 +76,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -105,7 +105,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -51,11 +51,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -82,7 +82,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -81,11 +81,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -125,7 +125,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -93,11 +93,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -135,7 +135,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -118,11 +118,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -163,7 +163,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -84,11 +84,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -125,7 +125,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -50,11 +50,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -89,7 +89,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -82,11 +82,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -112,7 +112,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -70,11 +70,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -108,7 +108,7 @@ def parse(data, raw=False, quiet=False):
|
||||
Returns:
|
||||
|
||||
Dictionary of raw structured data or
|
||||
list of dictionaries of processed structured data
|
||||
List of Dictionaries of processed structured data
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -84,11 +84,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -116,7 +116,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -99,7 +99,7 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
@ -169,7 +169,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -390,11 +390,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -475,7 +475,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -75,7 +75,7 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -162,11 +162,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -243,7 +243,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
332
jc/parsers/iw_scan.py
Normal file
332
jc/parsers/iw_scan.py
Normal file
@ -0,0 +1,332 @@
|
||||
"""jc - JSON CLI output utility `iw DEV scan` command output parser
|
||||
|
||||
This parser is considered beta quality. Not all fields are parsed.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ iw dev wlan0 scan | jc --iw-scan
|
||||
|
||||
or
|
||||
|
||||
$ jc iw dev wlan0 scan
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.iw-scan
|
||||
result = jc.parsers.iw-scan.parse(iw-scan_command_output)
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ iw dev wlan0 scan | jc --iw-scan -p
|
||||
[
|
||||
{
|
||||
"bssid": "71:31:72:65:e1:a2",
|
||||
"interface": "wlan0",
|
||||
"freq": 2462,
|
||||
"capability": "ESS Privacy ShortSlotTime (0x0411)",
|
||||
"ssid": "WLAN-1234",
|
||||
"supported_rates": [
|
||||
1.0,
|
||||
2.0,
|
||||
5.5,
|
||||
11.0,
|
||||
18.0,
|
||||
24.0,
|
||||
36.0,
|
||||
54.0
|
||||
],
|
||||
"erp": "<no flags>",
|
||||
"erp_d4.0": "<no flags>",
|
||||
"rsn": "Version: 1",
|
||||
"group_cipher": "CCMP",
|
||||
"pairwise_ciphers": "CCMP",
|
||||
"authentication_suites": "PSK",
|
||||
"capabilities": "0x186c",
|
||||
"extended_supported_rates": [
|
||||
6.0,
|
||||
9.0,
|
||||
12.0,
|
||||
48.0
|
||||
],
|
||||
"ht_rx_mcs_rate_indexes_supported": "0-15",
|
||||
"primary_channel": 11,
|
||||
"secondary_channel_offset": "no secondary",
|
||||
"rifs": 1,
|
||||
"ht_protection": "no",
|
||||
"non-gf_present": 1,
|
||||
"obss_non-gf_present": 0,
|
||||
"dual_beacon": 0,
|
||||
"dual_cts_protection": 0,
|
||||
"stbc_beacon": 0,
|
||||
"l-sig_txop_prot": 0,
|
||||
"pco_active": 0,
|
||||
"pco_phase": 0,
|
||||
"bss_width_channel_transition_delay_factor": 5,
|
||||
"extended_capabilities": "HT Information Exchange Supported",
|
||||
"wmm": "Parameter version 1",
|
||||
"be": "CW 15-1023, AIFSN 3",
|
||||
"bk": "CW 15-1023, AIFSN 7",
|
||||
"vi": "CW 7-15, AIFSN 2, TXOP 3008 usec",
|
||||
"vo": "CW 3-7, AIFSN 2, TXOP 1504 usec",
|
||||
"wps": "Version: 1.0",
|
||||
"wi-fi_protected_setup_state": "2 (Configured)",
|
||||
"selected_registrar": "0x0",
|
||||
"response_type": "3 (AP)",
|
||||
"uuid": "00000000-0000-0003-0000-75317074f1a2",
|
||||
"manufacturer": "Corporation",
|
||||
"model": "VGV8539JW",
|
||||
"model_number": "1.47.000",
|
||||
"serial_number": "J144024542",
|
||||
"primary_device_type": "6-0050f204-1",
|
||||
"device_name": "Wireless Router(WFA)",
|
||||
"config_methods": "Label, PBC",
|
||||
"rf_bands": "0x3",
|
||||
"tsf_usec": 212098649788,
|
||||
"sta_channel_width_mhz": 20,
|
||||
"passive_dwell_tus": 20,
|
||||
"active_dwell_tus": 10,
|
||||
"channel_width_trigger_scan_interval_s": 300,
|
||||
"scan_passive_total_per_channel_tus": 200,
|
||||
"scan_active_total_per_channel_tus": 20,
|
||||
"beacon_interval_tus": 100,
|
||||
"signal_dbm": -80.0,
|
||||
"last_seen_ms": 11420,
|
||||
"selected_rates": [
|
||||
1.0,
|
||||
2.0,
|
||||
5.5,
|
||||
11.0
|
||||
],
|
||||
"obss_scan_activity_threshold_percent": 0.25,
|
||||
"ds_parameter_set_channel": 11,
|
||||
"max_amsdu_length_bytes": 7935,
|
||||
"minimum_rx_ampdu_time_spacing_usec": 16
|
||||
},
|
||||
...
|
||||
]
|
||||
"""
|
||||
import re
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '0.5'
|
||||
description = 'iw dev <device> scan command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
details = 'Enhancements by Philipp Schmitt (https://pschmitt.dev/)'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
magic_commands = ['iw dev']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
]
|
||||
{
|
||||
"foo": string/integer/float, # best guess based on value
|
||||
"bar": string/integer/float,
|
||||
"baz": string/integer/float
|
||||
}
|
||||
]
|
||||
"""
|
||||
|
||||
# convert ints and floats for top-level keys
|
||||
for item in proc_data:
|
||||
for key in item:
|
||||
try:
|
||||
item[key] = int(item[key])
|
||||
except (Exception):
|
||||
try:
|
||||
item[key] = float(item[key])
|
||||
except (Exception):
|
||||
pass
|
||||
# convert ints and floats for lists
|
||||
if isinstance(item[key], list):
|
||||
new_list = []
|
||||
for list_item in item[key]:
|
||||
try:
|
||||
new_list.append(int(list_item))
|
||||
except (Exception):
|
||||
try:
|
||||
new_list.append(float(list_item))
|
||||
except (Exception):
|
||||
pass
|
||||
item[key] = new_list
|
||||
|
||||
return proc_data
|
||||
|
||||
def post_parse(data):
|
||||
# remove empty items
|
||||
cleandata = []
|
||||
for ssid in data:
|
||||
ssid = { k : v for k, v in ssid.items() if v}
|
||||
cleandata.append(ssid)
|
||||
|
||||
# remove asterisks from begining of values
|
||||
for ssid in cleandata:
|
||||
for key in ssid:
|
||||
if ssid[key].startswith('*'):
|
||||
ssid[key] = ssid[key][1:].strip()
|
||||
|
||||
for item in cleandata:
|
||||
if 'country' in item:
|
||||
country_split = item['country'].split()
|
||||
item['country'] = country_split[0]
|
||||
if len(country_split) > 1:
|
||||
item['environment'] = country_split[2]
|
||||
|
||||
if 'tsf' in item:
|
||||
item['tsf_usec'] = item['tsf'].split()[0]
|
||||
del item['tsf']
|
||||
|
||||
if 'sta_channel_width' in item:
|
||||
item['sta_channel_width_mhz'] = item['sta_channel_width'].replace(' MHz', '')
|
||||
del item['sta_channel_width']
|
||||
|
||||
if 'passive_dwell' in item:
|
||||
item['passive_dwell_tus'] = item['passive_dwell'].replace(' TUs', '')
|
||||
del item['passive_dwell']
|
||||
|
||||
if 'active_dwell' in item:
|
||||
item['active_dwell_tus'] = item['active_dwell'].replace(' TUs', '')
|
||||
del item['active_dwell']
|
||||
|
||||
if 'channel_width_trigger_scan_interval' in item:
|
||||
item['channel_width_trigger_scan_interval_s'] = item['channel_width_trigger_scan_interval'].replace(' s', '')
|
||||
del item['channel_width_trigger_scan_interval']
|
||||
|
||||
if 'scan_passive_total_per_channel' in item:
|
||||
item['scan_passive_total_per_channel_tus'] = item['scan_passive_total_per_channel'].replace(' TUs', '')
|
||||
del item['scan_passive_total_per_channel']
|
||||
|
||||
if 'scan_active_total_per_channel' in item:
|
||||
item['scan_active_total_per_channel_tus'] = item['scan_active_total_per_channel'].replace(' TUs', '')
|
||||
del item['scan_active_total_per_channel']
|
||||
|
||||
if 'beacon_interval' in item:
|
||||
item['beacon_interval_tus'] = item['beacon_interval'].replace(' TUs', '')
|
||||
del item['beacon_interval']
|
||||
|
||||
if 'signal' in item:
|
||||
item['signal_dbm'] = item['signal'].replace(' dBm', '')
|
||||
del item['signal']
|
||||
|
||||
if 'last_seen' in item:
|
||||
item['last_seen_ms'] = item['last_seen'].replace(' ms ago', '')
|
||||
del item['last_seen']
|
||||
|
||||
if 'supported_rates' in item:
|
||||
selected_rates = []
|
||||
for rate in item['supported_rates'].split():
|
||||
if rate.endswith('*'):
|
||||
selected_rates.append(rate.replace('*', ''))
|
||||
item['selected_rates'] = selected_rates
|
||||
item['supported_rates'] = item['supported_rates'].replace('*', '').split()
|
||||
|
||||
if 'extended_supported_rates' in item:
|
||||
item['extended_supported_rates'] = item['extended_supported_rates'].split()
|
||||
|
||||
if 'obss_scan_activity_threshold' in item:
|
||||
item['obss_scan_activity_threshold_percent'] = item['obss_scan_activity_threshold'].replace(' %', '')
|
||||
del item['obss_scan_activity_threshold']
|
||||
|
||||
if 'ds_parameter_set' in item:
|
||||
item['ds_parameter_set_channel'] = item['ds_parameter_set'].replace('channel ', '')
|
||||
del item['ds_parameter_set']
|
||||
|
||||
if 'max_amsdu_length' in item:
|
||||
item['max_amsdu_length_bytes'] = item['max_amsdu_length'].replace(' bytes', '')
|
||||
del item['max_amsdu_length']
|
||||
|
||||
if 'available_admission_capacity' in item:
|
||||
item['available_admission_capacity'] = item['available_admission_capacity'].replace(' [*32us]', '')
|
||||
|
||||
if 'power_constraint' in item:
|
||||
item['power_constraint_db'] = item['power_constraint'].replace(' dB', '')
|
||||
del item['power_constraint']
|
||||
|
||||
if 'minimum_rx_ampdu_time_spacing' in item:
|
||||
item['minimum_rx_ampdu_time_spacing_usec'] = item['minimum_rx_ampdu_time_spacing'].split()[0]
|
||||
del item['minimum_rx_ampdu_time_spacing']
|
||||
|
||||
if 'vht_rx_highest_supported' in item:
|
||||
item['vht_rx_highest_supported_mbps'] = item['vht_rx_highest_supported'].replace(' Mbps', '')
|
||||
del item['vht_rx_highest_supported']
|
||||
|
||||
if 'vht_tx_highest_supported' in item:
|
||||
item['vht_tx_highest_supported_mbps'] = item['vht_tx_highest_supported'].replace(' Mbps', '')
|
||||
del item['vht_tx_highest_supported']
|
||||
|
||||
return process(cleandata)
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
"""
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
section = {}
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
for line in filter(None, data.splitlines()):
|
||||
if line.startswith('BSS'):
|
||||
if section:
|
||||
raw_output.append(section)
|
||||
section = {}
|
||||
|
||||
split_line = line.replace('(', ' ').replace(')', ' ').split()
|
||||
section['bssid'] = split_line[1]
|
||||
section['interface'] = split_line[3]
|
||||
|
||||
continue
|
||||
|
||||
if re.match(r"^\s+.+", line):
|
||||
# ignore problematic lines
|
||||
if 'Maximum RX AMPDU length' in line:
|
||||
continue
|
||||
|
||||
split_line = line.split(':', maxsplit=1)
|
||||
if len(split_line) == 2:
|
||||
split_line[0] = split_line[0].lower().replace('*', '').replace('(', '').replace(')', '').replace(',', '').replace('-', '_').strip().replace(' ', '_')
|
||||
section[split_line[0]] = split_line[1].strip()
|
||||
|
||||
continue
|
||||
|
||||
if section:
|
||||
raw_output.append(section)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return post_parse(raw_output)
|
@ -105,11 +105,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -146,7 +146,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -1,5 +1,7 @@
|
||||
"""jc - JSON CLI output utility `last` and `lastb` command output parser
|
||||
|
||||
Supports -w and -F options.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ last | jc --last
|
||||
@ -19,30 +21,36 @@ Compatibility:
|
||||
|
||||
Examples:
|
||||
|
||||
$ last | jc --last -p
|
||||
$ last -F | jc --last -p
|
||||
[
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttys002",
|
||||
"hostname": null,
|
||||
"login": "Thu Feb 27 14:31",
|
||||
"login": "Mon Dec 28 17:24:10 2020",
|
||||
"logout": "still logged in"
|
||||
},
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttys003",
|
||||
"hostname": null,
|
||||
"login": "Thu Feb 27 10:38",
|
||||
"logout": "10:38",
|
||||
"duration": "00:00"
|
||||
"login": "Mon Dec 28 17:24:10 2020",
|
||||
"logout": "Mon Dec 28 17:25:01 2020",
|
||||
"duration": "00:00",
|
||||
"login_epoch": 1565891826,
|
||||
"logout_epoch": 1565895404,
|
||||
"duration_seconds": 3578
|
||||
},
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttys003",
|
||||
"hostname": null,
|
||||
"login": "Thu Feb 27 10:18",
|
||||
"logout": "10:18",
|
||||
"duration": "00:00"
|
||||
"login": "Mon Dec 28 17:24:10 2020",
|
||||
"logout": "Mon Dec 28 17:25:01 2020",
|
||||
"duration": "00:00",
|
||||
"login_epoch": 1565891826,
|
||||
"logout_epoch": 1565895404,
|
||||
"duration_seconds": 3578
|
||||
},
|
||||
...
|
||||
]
|
||||
@ -77,15 +85,16 @@ Examples:
|
||||
|
||||
"""
|
||||
import re
|
||||
from datetime import datetime
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
version = '1.4'
|
||||
description = 'last and lastb command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
# details = 'enter any other details here'
|
||||
details = 'Enhancements by https://github.com/zerolagtime'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'aix', 'freebsd']
|
||||
@ -101,20 +110,23 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"user": string,
|
||||
"tty": string,
|
||||
"hostname": string,
|
||||
"login": string,
|
||||
"logout": string,
|
||||
"duration": string
|
||||
"user": string,
|
||||
"tty": string,
|
||||
"hostname": string,
|
||||
"login": string,
|
||||
"logout": string,
|
||||
"duration": string,
|
||||
"login_epoch": integer, # available with last -F option
|
||||
"logout_epoch": integer, # available with last -F option
|
||||
"duration_seconds": integer # available with last -F option
|
||||
}
|
||||
]
|
||||
"""
|
||||
@ -131,12 +143,29 @@ def process(proc_data):
|
||||
if 'hostname' in entry and entry['hostname'] == '-':
|
||||
entry['hostname'] = None
|
||||
|
||||
if 'hostname' in entry and entry['hostname'] is not None and entry['hostname'][0] == ":":
|
||||
entry['hostname'] = f'CONSOLE{entry["hostname"]}'
|
||||
|
||||
if 'logout' in entry and 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'
|
||||
|
||||
if 'login' in entry and re.match(r'.*\d\d:\d\d:\d\d \d\d\d\d.*',entry['login']):
|
||||
entry['login_epoch'] = int(datetime.strptime(entry['login'], '%a %b %d %H:%M:%S %Y').strftime('%s'))
|
||||
|
||||
if 'logout' in entry and re.match(r'.*\d\d:\d\d:\d\d \d\d\d\d.*',entry['logout']):
|
||||
entry['logout_epoch'] = int(datetime.strptime(entry['logout'], '%a %b %d %H:%M:%S %Y').strftime('%s'))
|
||||
|
||||
if 'login_epoch' in entry and 'logout_epoch' in entry:
|
||||
entry['duration_seconds'] = int(entry['logout_epoch']) - int(entry['login_epoch'])
|
||||
|
||||
if 'duration' in entry and re.match(r'^\d+\+', entry['duration']):
|
||||
m = re.match(r'^(?P<days>\d+)\+(?P<hours>\d\d):(?P<minutes>\d\d)', entry['duration'])
|
||||
days, hours, minutes = m.groups()
|
||||
entry['duration'] = f'{int(days)*24 + int(hours)}:{minutes}'
|
||||
|
||||
return proc_data
|
||||
|
||||
|
||||
@ -152,7 +181,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
@ -187,13 +216,34 @@ def parse(data, raw=False, quiet=False):
|
||||
output_line['user'] = linedata[0]
|
||||
output_line['tty'] = linedata[1]
|
||||
output_line['hostname'] = linedata[2]
|
||||
output_line['login'] = ' '.join(linedata[3:7])
|
||||
|
||||
if len(linedata) > 8:
|
||||
output_line['logout'] = linedata[8]
|
||||
# last -F support
|
||||
if re.match(r'\d\d:\d\d:\d\d \d\d\d\d', ' '.join(linedata[6:8])):
|
||||
output_line['login'] = ' '.join(linedata[3:8])
|
||||
|
||||
if len(linedata) > 9:
|
||||
output_line['duration'] = linedata[9].replace('(', '').replace(')', '')
|
||||
if len(linedata) > 9 and linedata[9] != 'crash' and linedata[9] != 'down':
|
||||
output_line['logout'] = ' '.join(linedata[9:14])
|
||||
|
||||
if len(linedata) > 9 and (linedata[9] == 'crash' or linedata[9] == 'down'):
|
||||
output_line['logout'] = linedata[9]
|
||||
# add more items to the list to line up duration
|
||||
linedata.insert(10, '-')
|
||||
linedata.insert(10, '-')
|
||||
linedata.insert(10, '-')
|
||||
linedata.insert(10, '-')
|
||||
|
||||
if len(linedata) > 14:
|
||||
output_line['duration'] = linedata[14].replace('(', '').replace(')', '')
|
||||
|
||||
# normal last support
|
||||
else:
|
||||
output_line['login'] = ' '.join(linedata[3:7])
|
||||
|
||||
if len(linedata) > 8:
|
||||
output_line['logout'] = linedata[8]
|
||||
|
||||
if len(linedata) > 9:
|
||||
output_line['duration'] = linedata[9].replace('(', '').replace(')', '')
|
||||
|
||||
raw_output.append(output_line)
|
||||
|
||||
|
@ -172,11 +172,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -217,7 +217,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -244,11 +244,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -331,7 +331,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
@ -135,11 +135,11 @@ def process(proc_data):
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@ -178,7 +178,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user