raspiblitz/home.admin/BlitzPy/README.md

74 lines
1.3 KiB
Markdown
Raw Normal View History

2020-05-23 12:51:30 +01:00
# BlitzPy
BlitzPy is a part of the RaspiBlitz project and implements a few common use cases.
## Installation
### Prerequisite
None
### Dependencies
None
### Install BlitzPy
```
cd ~/raspiblitz/home.admin/BlitzPy
2020-05-30 17:58:05 +02:00
pip install dist/BlitzPy-0.2.0-py2.py3-none-any.whl
2020-05-23 12:51:30 +01:00
OR
2020-05-30 17:58:05 +02:00
sudo -H python -m pip install dist/BlitzPy-0.2.0-py2.py3-none-any.whl
2020-05-23 12:51:30 +01:00
```
**or** consider using a virtual environment
```
python3 -m venv --system-site-packages venv
source venv/bin/activate
pip install BlitzPy
```
## Usage
### Import and use..
```
from blitzpy import RaspiBlitzConfig
cfg = RaspiBlitzConfig()
cfg.reload()
2020-05-30 17:57:29 +02:00
print(cfg.hostname.value)
if cfg.run_behind_tor.value:
2020-05-23 12:51:30 +01:00
print("using TOR!")
```
### Changing values
In order to change the content of a setting the `value` attribute needs to be updated!
```
from blitzpy import RaspiBlitzConfig
cfg = RaspiBlitzConfig()
cfg.reload()
2020-05-30 17:57:29 +02:00
print(cfg.hostname.value)
2020-05-23 12:51:30 +01:00
cfg.hostname.value = "New-Hostname!"
2020-05-30 17:57:29 +02:00
print(cfg.hostname.value)
2020-05-23 12:51:30 +01:00
```
### Exporting
Use `cfg.write()` to export file (will use default path - override with cfg.write(path="/tmp/foobar.conf").
```
from blitzpy import RaspiBlitzConfig
cfg = RaspiBlitzConfig()
cfg.reload()
cfg.rtl_web_interface.value = True
cfg.write()
```
## License
[MIT License](http://en.wikipedia.org/wiki/MIT_License)