2021-04-09 10:36:42 -07:00
|
|
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
2022-01-25 17:07:47 -08:00
|
|
|
<a id="jc.parsers.dpkg_l"></a>
|
|
|
|
|
2024-03-14 22:46:52 -07:00
|
|
|
# jc.parsers.dpkg_l
|
2021-04-01 20:12:58 -07:00
|
|
|
|
2022-03-04 13:27:39 -08:00
|
|
|
jc - JSON Convert `dpkg -l` command output parser
|
2021-04-01 20:12:58 -07:00
|
|
|
|
2022-01-19 17:30:14 -08:00
|
|
|
Set the `COLUMNS` environment variable to a large value to avoid field
|
|
|
|
truncation. For example:
|
2021-04-01 20:12:58 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
$ COLUMNS=500 dpkg -l | jc --dpkg-l
|
2021-04-01 20:12:58 -07:00
|
|
|
|
|
|
|
Usage (cli):
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
$ dpkg -l | jc --dpkg-l
|
2021-04-01 20:12:58 -07:00
|
|
|
|
2022-08-15 13:51:48 -07:00
|
|
|
or
|
2021-04-01 20:12:58 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
$ jc dpkg -l
|
2021-04-01 20:12:58 -07:00
|
|
|
|
|
|
|
Usage (module):
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
import jc
|
|
|
|
result = jc.parse('dpkg_l', dpkg_command_output)
|
2022-01-18 14:18:12 -08:00
|
|
|
|
2021-04-08 12:42:01 -07:00
|
|
|
Schema:
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"codes": string,
|
|
|
|
"name": string,
|
|
|
|
"version": string,
|
|
|
|
"architecture": string,
|
|
|
|
"description": string,
|
|
|
|
"desired": string,
|
|
|
|
"status": string,
|
|
|
|
"error": string
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
$ dpkg -l | jc --dpkg-l -p
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"codes": "ii",
|
|
|
|
"name": "accountsservice",
|
|
|
|
"version": "0.6.45-1ubuntu1.3",
|
|
|
|
"architecture": "amd64",
|
|
|
|
"description": "query and manipulate user account information",
|
|
|
|
"desired": "install",
|
|
|
|
"status": "installed"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"codes": "rc",
|
|
|
|
"name": "acl",
|
|
|
|
"version": "2.2.52-3build1",
|
|
|
|
"architecture": "amd64",
|
|
|
|
"description": "Access control list utilities",
|
|
|
|
"desired": "remove",
|
|
|
|
"status": "config-files"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"codes": "uWR",
|
|
|
|
"name": "acpi",
|
|
|
|
"version": "1.7-1.1",
|
|
|
|
"architecture": "amd64",
|
|
|
|
"description": "displays information on ACPI devices",
|
|
|
|
"desired": "unknown",
|
|
|
|
"status": "trigger await",
|
|
|
|
"error": "reinstall required"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"codes": "rh",
|
|
|
|
"name": "acpid",
|
|
|
|
"version": "1:2.0.28-1ubuntu1",
|
|
|
|
"architecture": "amd64",
|
|
|
|
"description": "Advanced Configuration and Power Interface...",
|
|
|
|
"desired": "remove",
|
|
|
|
"status": "half installed"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"codes": "pn",
|
|
|
|
"name": "adduser",
|
|
|
|
"version": "3.116ubuntu1",
|
|
|
|
"architecture": "all",
|
|
|
|
"description": "add and remove users and groups",
|
|
|
|
"desired": "purge",
|
|
|
|
"status": "not installed"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
|
|
|
|
|
|
|
$ dpkg -l | jc --dpkg-l -p -r
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"codes": "ii",
|
|
|
|
"name": "accountsservice",
|
|
|
|
"version": "0.6.45-1ubuntu1.3",
|
|
|
|
"architecture": "amd64",
|
|
|
|
"description": "query and manipulate user account information"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"codes": "rc",
|
|
|
|
"name": "acl",
|
|
|
|
"version": "2.2.52-3build1",
|
|
|
|
"architecture": "amd64",
|
|
|
|
"description": "Access control list utilities"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"codes": "uWR",
|
|
|
|
"name": "acpi",
|
|
|
|
"version": "1.7-1.1",
|
|
|
|
"architecture": "amd64",
|
|
|
|
"description": "displays information on ACPI devices"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"codes": "rh",
|
|
|
|
"name": "acpid",
|
|
|
|
"version": "1:2.0.28-1ubuntu1",
|
|
|
|
"architecture": "amd64",
|
|
|
|
"description": "Advanced Configuration and Power Interface..."
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"codes": "pn",
|
|
|
|
"name": "adduser",
|
|
|
|
"version": "3.116ubuntu1",
|
|
|
|
"architecture": "all",
|
|
|
|
"description": "add and remove users and groups"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
2022-01-25 17:07:47 -08:00
|
|
|
|
|
|
|
<a id="jc.parsers.dpkg_l.parse"></a>
|
|
|
|
|
2022-03-05 12:15:14 -08:00
|
|
|
### parse
|
2022-01-25 17:07:47 -08:00
|
|
|
|
2021-04-01 20:12:58 -07:00
|
|
|
```python
|
2022-01-25 17:07:47 -08:00
|
|
|
def parse(data, raw=False, quiet=False)
|
2021-04-01 20:12:58 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
Main text parsing function
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
Parameters:
|
2021-04-01 20:12:58 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
data: (string) text data to parse
|
|
|
|
raw: (boolean) unprocessed output if True
|
|
|
|
quiet: (boolean) suppress warning messages if True
|
2021-04-01 20:12:58 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
Returns:
|
2021-04-01 20:12:58 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
List of Dictionaries. Raw or processed structured data.
|
2021-04-01 20:12:58 -07:00
|
|
|
|
2022-01-25 19:18:54 -08:00
|
|
|
### Parser Information
|
2021-04-09 10:36:42 -07:00
|
|
|
Compatibility: linux
|
|
|
|
|
2023-12-21 14:55:21 -08:00
|
|
|
Source: [`jc/parsers/dpkg_l.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/dpkg_l.py)
|
|
|
|
|
2022-07-16 20:52:19 -07:00
|
|
|
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|