Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexitx/ap-parse
Parser for iw and iwinfo on OpenWrt devices
https://github.com/alexitx/ap-parse
device iw iwinfo openwrt parser parsing python python3 station wifi
Last synced: 8 days ago
JSON representation
Parser for iw and iwinfo on OpenWrt devices
- Host: GitHub
- URL: https://github.com/alexitx/ap-parse
- Owner: alexitx
- License: mit
- Created: 2022-03-10T17:58:40.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-18T09:23:05.000Z (about 2 years ago)
- Last Synced: 2024-10-13T23:05:17.975Z (about 1 month ago)
- Topics: device, iw, iwinfo, openwrt, parser, parsing, python, python3, station, wifi
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ap-parse
Parser for iw and iwinfo on OpenWrt devices. Currently supports only device list and connected
stations data. Output from iw and iwinfo on other platforms might work, but it's not tested.## Table of contents
- [Installation](#installation)
- [Usage](#usage)
- [CLI](#cli)
- [API](#api)
- [License](#license)## Installation
```sh
python -m pip install -U ap-parse
```## Usage
Log in to the device via SSH and run the the command of choice. Feed the output to ap-parse either
programmatically or via the CLI.- List devices with iw:
```sh
iw dev
```- List stations with iw:
```sh
iw dev station dump
```- List devices with iwinfo:
```sh
iwinfo
```- List stations with iwinfo:
```sh
iwinfo assoclist
```### CLI
Pipe the command output to ap-parse. Example for iwinfo device list:
```
ssh iwinfo | python -m apparse iwinfo device
```| Argument | Type | Values | Description |
|----------|------|---------------------|------------------------------------------|
| backend | str | `iw`, `iwinfo` | Utility used to generate the output data |
| type | str | `device`, `station` | Type of the output data |### API
Save the command output to a file and pass it as a string to the appropriate parser.
Example for iwinfo device list:
```sh
ssh iwinfo > output.txt
``````python
import apparsewith open('output.txt', 'r', encoding='utf-8') as f:
raw_data = f.read()parsed_data = apparse.parse_iwinfo_station(raw_data)
print(parsed_data)
```In case you wish to add or remove fields or modify regexes, subclass one of the parser classes under
its respective module `apparse.*_parser`.## License
MIT license. See [LICENSE][license] for more information.
[license]: https://github.com/alexitx/ap-parse/blob/master/LICENSE