1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/rsync_s.md

118 lines
3.7 KiB
Markdown
Raw Normal View History

2022-02-02 16:03:14 -08:00
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.rsync_s"></a>
# jc.parsers.rsync\_s
2022-03-04 13:27:39 -08:00
jc - JSON Convert `rsync` command output streaming parser
2022-02-02 16:03:14 -08:00
2022-04-28 13:38:24 -07:00
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
2022-05-26 15:07:54 -07:00
> Dictionaries (module)
2022-02-02 16:03:14 -08:00
Supports the `-i` or `--itemize-changes` options with all levels of
2022-05-26 16:03:30 -07:00
verbosity. This parser will process the `STDOUT` output or a log file
2022-02-14 09:37:37 -08:00
generated with the `--log-file` option.
2022-02-02 16:03:14 -08:00
Usage (cli):
$ rsync -i -a source/ dest | jc --rsync-s
2022-02-08 14:45:33 -08:00
or
$ cat rsync-backup.log | jc --rsync-s
2022-02-02 16:03:14 -08:00
Usage (module):
import jc
2022-03-10 13:32:26 -08:00
result = jc.parse('rsync_s', rsync_command_output.splitlines())
2022-02-02 16:03:14 -08:00
for item in result:
# do something
Schema:
{
"type": string, # 'file' or 'summary'
"date": string,
"time": string,
"process": integer,
"sent": integer,
"received": integer,
"total_size": integer,
"matches": integer,
"hash_hits": integer,
"false_alarms": integer,
"data": integer,
"bytes_sec": float,
"speedup": float,
"filename": string,
"date": string,
"time": string,
"process": integer,
"metadata": string,
"update_type": string/null, [0]
"file_type": string/null, [1]
"checksum_or_value_different": bool/null,
"size_different": bool/null,
"modification_time_different": bool/null,
"permissions_different": bool/null,
"owner_different": bool/null,
"group_different": bool/null,
"acl_different": bool/null,
"extended_attribute_different": bool/null,
2022-02-14 09:14:46 -08:00
"epoch": integer, [2]
2022-02-02 16:03:14 -08:00
2022-03-10 10:10:57 -08:00
# below object only exists if using -qq or ignore_exceptions=True
"_jc_meta": {
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
2022-02-02 16:03:14 -08:00
}
[0] 'file sent', 'file received', 'local change or creation',
'hard link', 'not updated', 'message'
[1] 'file', 'directory', 'symlink', 'device', 'special file'
[2] naive timestamp if time and date fields exist and can be converted.
Examples:
2022-02-07 06:42:35 -08:00
$ rsync -i -a source/ dest | jc --rsync-s
{"type":"file","filename":"./","metadata":".d..t......","update_...}
2022-02-02 16:03:14 -08:00
...
2022-02-07 06:42:35 -08:00
$ cat rsync_backup.log | jc --rsync-s
{"type":"file","filename":"./","date":"2022/01/28","time":"03:53...}
2022-02-02 16:03:14 -08:00
...
<a id="jc.parsers.rsync_s.parse"></a>
2022-03-05 12:15:14 -08:00
### parse
2022-02-02 16:03:14 -08:00
```python
2022-02-03 15:47:46 -08:00
@add_jc_meta
2022-04-28 13:30:11 -07:00
def parse(data: Iterable[str],
raw: bool = False,
quiet: bool = False,
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
2022-02-02 16:03:14 -08:00
```
2022-04-28 13:30:11 -07:00
Main text parsing generator function. Returns an iterable object.
2022-02-02 16:03:14 -08:00
Parameters:
data: (iterable) line-based text data to parse
(e.g. sys.stdin or str.splitlines())
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
2022-02-04 12:14:16 -08:00
ignore_exceptions: (boolean) ignore parsing exceptions if True
2022-02-02 16:03:14 -08:00
Returns:
2022-04-28 13:30:11 -07:00
Iterable of Dictionaries
2022-02-02 16:03:14 -08:00
### Parser Information
Compatibility: linux, darwin, freebsd
2022-02-07 06:29:17 -08:00
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)