Skip to main content

This simple python library is a JBoss output lexer & parser based on PLY (yet another implementation of lex and yacc for Python).

JBoss CLI server has output that closely resembles JSON, but it is not 100% JSON so it is difficult to parse it with ordinary tools. With this library you can process JBoss output and parse it as JSON.

Example

from jbossply.jbossparser import JbossParser
test3 = """{
    "outcome" => "success",
    "result" => {
        "rule-1" => {
            "flags" => "L,QSA,R",
            "pattern" => "^/$",
            "substitution" => "/ejbca",
            "condition" => undefined
        },
        "rule-3" => {
            "flags" => "L,QSA,R",
            "pattern" => "^/pki/?$",
            "substitution" => "/ejbca/adminweb",
            "condition" => undefined
        }
    }
}
"""

parser = JbossParser()
print(parser.parse(test3))

Which gives output

{u'outcome': u'success', u'result': {u'rule-3': {u'pattern': u'^/pki/?$', u'flags': u'L,QSA,R', u'condition': None, u'substitution': u'/ejbca/adminweb'}, u'rule-1': {u'pattern': u'^/$', u'flags': u'L,QSA,R', u'condition': None, u'substitution': u'/ejbca'}}}

You may want to cache parser tables, then create JbossParser like this:

parser = JbossParser(write_tables=True, outputdir='/tmp/table-dir')

Command line usage

After installed with pip you may use also the command line helper jboss2json.

$ cat jboss-output.txt | jboss2json
{"outcome": "success", "result": {"rule-3": {"pattern": "^/pki/?$", "flags": "L,QSA,R", "condition": null, "substitution": "/ejbca/adminweb"}, "rule-1": {"pattern": "^/$", "flags": "L,QSA,R", "condition": null, "substitution": "/ejbca"}}}

Installation

You can install this package using pip:

pip install jbossply

Credits

The code is based on @vsajip repository json-ply

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jbossply-0.0.3.tar.gz (7.2 kB view details)

Uploaded Source

File details

Details for the file jbossply-0.0.3.tar.gz.

File metadata

  • Download URL: jbossply-0.0.3.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jbossply-0.0.3.tar.gz
Algorithm Hash digest
SHA256 3acf657b873c9e82ed64443c5577747cdbed046d94817246b61ce98e82e34454
MD5 22400ed19c627d5e72b0dde2eaebd096
BLAKE2b-256 c99bba217eb94a56e62128a86293573cec5da8677b156a76b5566e27ea762d65

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.3 This release

1 file

0.0.2

1 file

0.0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page