This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""jc - JSON Convert Fortigate Configuration file parser | |
Usage (cli): | |
$ cat config | jc --fortigate | |
Usage (module): | |
import jc | |
result = jc.parse('fortigate', fortigate_config_file_string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Requires: ifconfig, ping, arp, date, wc, jq, and jc | |
if [[ $1 == "" ]]; then | |
echo "Please enter the interface name as command argument." | |
echo | |
echo "Options:" | |
# Only show interfaces with an assigned IP address | |
jc ifconfig | jq -r '.[] | select(.ipv4_addr != null) | .name' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""jc - JSON Convert `dpkg -l` command output parser for Russia locale | |
Set the `COLUMNS` environment variable to a large value to avoid field | |
truncation. For example: | |
$ COLUMNS=500 dpkg -l | jc --dpkg-l | |
Usage (cli): | |
$ dpkg -l | jc --dpkg-l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# | |
# Convert traceroute command output to a graphviz DOT graph | |
# Use `jc` to convert `traceroute` output to JSON before piping to tr2dot.py | |
# | |
# Version 1.0 | |
# Kelly Brazil (kellyjonbrazil@gmail.com) | |
# | |
# Requires graphviz (pip3 install graphviz) | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
salt.serializers.jc | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
Implements JC serializer. | |
JC converts the output of many commands and file-types to structured format. | |
https://github.com/kellyjonbrazil/jc | |
Requires JC is installed via pip: $ pip3 install jc | |
Requires Python >= 3.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
JC Outputter for Salt | |
JC converts the output of many commands and file-types to structured format. | |
https://github.com/kellyjonbrazil/jc | |
Requires JC is installed via pip: $ pip3 install jc | |
Requires Python >= 3.6 | |
Usage: | |
This outputter requires a parser to be defined via the JC_PARSER env variable: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""More comprehensive traceback formatting for Python scripts. | |
To enable this module, do: | |
import tracebackplus; tracebackplus.enable() | |
at the top of your script. The optional arguments to enable() are: | |
logdir - if set, tracebacks are written to files in this directory | |
context - number of lines of source code to show for each stack frame |