How to use the jc.parsers.w.parse function in jc

To help you get started, we’ve selected a few jc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kellyjonbrazil / jc / tests / test_w.py View on Github external
def test_w_osx_10_14_6(self):
        """
        Test 'w' on OSX 10.14.6
        """
        self.assertEqual(jc.parsers.w.parse(self.osx_10_14_6_w, quiet=True), self.osx_10_14_6_json)
github kellyjonbrazil / jc / tests / test_w.py View on Github external
def test_w_centos_7_7(self):
        """
        Test 'w' on Centos 7.7
        """
        self.assertEqual(jc.parsers.w.parse(self.centos_7_7_w, quiet=True), self.centos_7_7_w_json)
github kellyjonbrazil / jc / tests / test_w.py View on Github external
def test_w_ubuntu_18_4(self):
        """
        Test 'w' on Ubuntu 18.4
        """
        self.assertEqual(jc.parsers.w.parse(self.ubuntu_18_4_w, quiet=True), self.ubuntu_18_4_w_json)
github kellyjonbrazil / jc / tests / test_w.py View on Github external
def test_w_osx_10_11_6(self):
        """
        Test 'w' on OSX 10.11.6
        """
        self.assertEqual(jc.parsers.w.parse(self.osx_10_11_6_w, quiet=True), self.osx_10_11_6_json)
github kellyjonbrazil / jc / jc / jc.py View on Github external
result = jc.parsers.netstat.parse(data, raw=raw, quiet=quiet)

    elif '--ps' in sys.argv:
        result = jc.parsers.ps.parse(data, raw=raw, quiet=quiet)

    elif '--route' in sys.argv:
        result = jc.parsers.route.parse(data, raw=raw, quiet=quiet)

    elif '--uname' in sys.argv:
        result = jc.parsers.uname.parse(data, raw=raw, quiet=quiet)

    elif '--uptime' in sys.argv:
        result = jc.parsers.uptime.parse(data, raw=raw, quiet=quiet)

    elif '--w' in sys.argv:
        result = jc.parsers.w.parse(data, raw=raw, quiet=quiet)

    else:
        helptext('missing or incorrect arguments')
        exit()

    # output resulting dictionary as json
    if pretty:
        print(json.dumps(result, indent=2))
    else:
        print(json.dumps(result))
github kellyjonbrazil / jc / jc / cli.py View on Github external
'--lsblk': jc.parsers.lsblk.parse,
        '--lsmod': jc.parsers.lsmod.parse,
        '--lsof': jc.parsers.lsof.parse,
        '--mount': jc.parsers.mount.parse,
        '--netstat': jc.parsers.netstat.parse,
        '--ps': jc.parsers.ps.parse,
        '--route': jc.parsers.route.parse,
        '--ss': jc.parsers.ss.parse,
        '--stat': jc.parsers.stat.parse,
        '--systemctl': jc.parsers.systemctl.parse,
        '--systemctl-lj': jc.parsers.systemctl_lj.parse,
        '--systemctl-ls': jc.parsers.systemctl_ls.parse,
        '--systemctl-luf': jc.parsers.systemctl_luf.parse,
        '--uname': jc.parsers.uname.parse,
        '--uptime': jc.parsers.uptime.parse,
        '--w': jc.parsers.w.parse
    }

    found = False

    if debug:
        for arg in sys.argv:
            if arg in parser_map:
                result = parser_map[arg](data, raw=raw, quiet=quiet)
                found = True
                break
    else:
        for arg in sys.argv:
            if arg in parser_map:
                try:
                    result = parser_map[arg](data, raw=raw, quiet=quiet)
                    found = True