busylib 0.0.2__tar.gz → 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- busylib-0.1.0/PKG-INFO +228 -0
- busylib-0.1.0/README.md +203 -0
- busylib-0.1.0/busylib/__init__.py +1 -0
- busylib-0.1.0/busylib/client.py +359 -0
- busylib-0.1.0/busylib/exceptions.py +5 -0
- busylib-0.1.0/busylib/types.py +213 -0
- busylib-0.1.0/busylib.egg-info/PKG-INFO +228 -0
- {busylib-0.0.2 → busylib-0.1.0}/busylib.egg-info/SOURCES.txt +1 -0
- {busylib-0.0.2 → busylib-0.1.0}/pyproject.toml +3 -2
- {busylib-0.0.2 → busylib-0.1.0}/setup.py +0 -1
- busylib-0.1.0/tests/test_client.py +439 -0
- busylib-0.0.2/PKG-INFO +0 -162
- busylib-0.0.2/README.md +0 -136
- busylib-0.0.2/busylib/__init__.py +0 -82
- busylib-0.0.2/busylib/client.py +0 -108
- busylib-0.0.2/busylib/types.py +0 -9
- busylib-0.0.2/busylib.egg-info/PKG-INFO +0 -162
- busylib-0.0.2/tests/test_client.py +0 -103
- {busylib-0.0.2 → busylib-0.1.0}/LICENSE +0 -0
- {busylib-0.0.2 → busylib-0.1.0}/busylib.egg-info/dependency_links.txt +0 -0
- {busylib-0.0.2 → busylib-0.1.0}/busylib.egg-info/requires.txt +0 -0
- {busylib-0.0.2 → busylib-0.1.0}/busylib.egg-info/top_level.txt +0 -0
- {busylib-0.0.2 → busylib-0.1.0}/setup.cfg +0 -0
busylib-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: busylib
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python library for Busy Bar API
|
|
5
|
+
Author-email: Valerii Lisai <v.lisai@flipperdevices.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/busy-app/busylib
|
|
7
|
+
Project-URL: Repository, https://github.com/busy-app/busylib
|
|
8
|
+
Project-URL: Documentation, https://busylib.readthedocs.io
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: requests==2.32.4
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest==8.4.1; extra == "dev"
|
|
22
|
+
Requires-Dist: requests-mock==1.12.1; extra == "dev"
|
|
23
|
+
Requires-Dist: ruff; extra == "dev"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# busylib
|
|
27
|
+
|
|
28
|
+
A simple and intuitive Python client for interacting with the Busy Bar API. This library allows you to programmatically control the device's display, audio, and assets.
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- Easy-to-use API for all major device functions.
|
|
33
|
+
- Upload and manage assets for your applications.
|
|
34
|
+
- Control the display by drawing text and images.
|
|
35
|
+
- Play and stop audio files.
|
|
36
|
+
- Built-in validation for device IP addresses.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
You can install `busylib` directly from PyPI:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install busylib
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
First, import and initialize the `BusyBar` client with IP address of your device.
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from busylib import BusyBar
|
|
52
|
+
|
|
53
|
+
bb = BusyBar("10.0.4.20")
|
|
54
|
+
|
|
55
|
+
version_info = bb.get_version()
|
|
56
|
+
print(f"Device version: {version_info.version}")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
You can also use context manager.
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from busylib import BusyBar
|
|
63
|
+
|
|
64
|
+
with BusyBar("10.0.4.20") as bb:
|
|
65
|
+
version_info = bb.get_version()
|
|
66
|
+
print(f"Device version: {version_info.version}")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## API Examples
|
|
70
|
+
|
|
71
|
+
Here are some examples of how to use the library to control your Busy Bar device.
|
|
72
|
+
|
|
73
|
+
### Uploading an Asset
|
|
74
|
+
|
|
75
|
+
You can upload files (like images or sounds) to be used by your application on the device.
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
with open("path/to/your/image.png", "rb") as f:
|
|
79
|
+
file_bytes = f.read()
|
|
80
|
+
response = bb.upload_asset(
|
|
81
|
+
app_id="my-app",
|
|
82
|
+
filename="logo.png",
|
|
83
|
+
data=file_bytes
|
|
84
|
+
)
|
|
85
|
+
print(f"Upload result: {response.result}")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
with open("path/to/your/sound.wav", "rb") as f:
|
|
89
|
+
file_bytes = f.read()
|
|
90
|
+
response = bb.upload_asset(
|
|
91
|
+
app_id="my-app",
|
|
92
|
+
filename="notification.wav",
|
|
93
|
+
data=file_bytes
|
|
94
|
+
)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Drawing on the Display
|
|
98
|
+
|
|
99
|
+
Draw text or images on the device's screen. The `draw_on_display` method accepts a `DisplayElements` object containing a list of elements to render.
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from busylib import types
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
text_element = types.TextElement(
|
|
106
|
+
id="hello",
|
|
107
|
+
type="text",
|
|
108
|
+
x=10,
|
|
109
|
+
y=20,
|
|
110
|
+
text="Hello, World!",
|
|
111
|
+
display=types.DisplayName.FRONT,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
image_element = types.ImageElement(
|
|
115
|
+
id="logo",
|
|
116
|
+
type="image",
|
|
117
|
+
x=50,
|
|
118
|
+
y=40,
|
|
119
|
+
path="logo.png",
|
|
120
|
+
display=types.DisplayName.BACK,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
display_data = types.DisplayElements(
|
|
124
|
+
app_id="my-app",
|
|
125
|
+
elements=[text_element, image_element]
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
response = bb.draw_on_display(display_data)
|
|
129
|
+
print(f"Draw result: {response.result}")
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Clearing the Display
|
|
133
|
+
|
|
134
|
+
To clear everything from the screen:
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
response = bb.clear_display()
|
|
138
|
+
print(f"Clear result: {response.result}")
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Playing Audio
|
|
142
|
+
|
|
143
|
+
Play an audio file that you have already uploaded.
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
response = bb.play_audio(app_id="my-app", path="notification.wav")
|
|
147
|
+
print(f"Play result: {response.result}")
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Stopping Audio
|
|
151
|
+
|
|
152
|
+
To stop any audio that is currently playing:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
response = bb.stop_audio()
|
|
156
|
+
print(f"Stop result: {response.result}")
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Deleting All Assets for an App
|
|
160
|
+
|
|
161
|
+
This will remove all files associated with a specific `app_id`.
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
response = bb.delete_app_assets(app_id="my-app")
|
|
165
|
+
print(f"Delete result: {response.result}")
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Getting Device Status
|
|
169
|
+
|
|
170
|
+
You can get various status information from the device:
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
version = bb.get_version()
|
|
174
|
+
print(f"Version: {version.version}, Branch: {version.branch}")
|
|
175
|
+
|
|
176
|
+
status = bb.get_status()
|
|
177
|
+
if status.system:
|
|
178
|
+
print(f"Uptime: {status.system.uptime}")
|
|
179
|
+
if status.power:
|
|
180
|
+
print(f"Battery: {status.power.battery_charge}%")
|
|
181
|
+
|
|
182
|
+
brightness = bb.get_display_brightness()
|
|
183
|
+
print(f"Front brightness: {brightness.front}, Back brightness: {brightness.back}")
|
|
184
|
+
|
|
185
|
+
volume = bb.get_audio_volume()
|
|
186
|
+
print(f"Volume: {volume.volume}")
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Working with Storage
|
|
190
|
+
|
|
191
|
+
You can manage files in the device's storage:
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
file_data = b"Hello, world!"
|
|
195
|
+
response = bb.write_storage_file(path="/my-app/data.txt", data=file_data)
|
|
196
|
+
|
|
197
|
+
file_content = bb.read_storage_file(path="/my-app/data.txt")
|
|
198
|
+
print(file_content.decode('utf-8'))
|
|
199
|
+
|
|
200
|
+
storage_list = bb.list_storage_files(path="/my-app")
|
|
201
|
+
for item in storage_list.list:
|
|
202
|
+
if item.type == "file":
|
|
203
|
+
print(f"File: {item.name} ({item.size} bytes)")
|
|
204
|
+
else:
|
|
205
|
+
print(f"Directory: {item.name}")
|
|
206
|
+
|
|
207
|
+
response = bb.create_storage_directory(path="/my-app/subdirectory")
|
|
208
|
+
|
|
209
|
+
response = bb.remove_storage_file(path="/my-app/data.txt")
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Development
|
|
213
|
+
|
|
214
|
+
To set up a development environment, clone the repository and install the package in editable mode with test dependencies:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
git clone https://github.com/busy-app/busylib
|
|
218
|
+
cd busylib
|
|
219
|
+
python3 -m venv .venv
|
|
220
|
+
source .venv/bin/activate
|
|
221
|
+
make install-dev
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
To run the tests:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
make test
|
|
228
|
+
```
|
busylib-0.1.0/README.md
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# busylib
|
|
2
|
+
|
|
3
|
+
A simple and intuitive Python client for interacting with the Busy Bar API. This library allows you to programmatically control the device's display, audio, and assets.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Easy-to-use API for all major device functions.
|
|
8
|
+
- Upload and manage assets for your applications.
|
|
9
|
+
- Control the display by drawing text and images.
|
|
10
|
+
- Play and stop audio files.
|
|
11
|
+
- Built-in validation for device IP addresses.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
You can install `busylib` directly from PyPI:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install busylib
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
First, import and initialize the `BusyBar` client with IP address of your device.
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from busylib import BusyBar
|
|
27
|
+
|
|
28
|
+
bb = BusyBar("10.0.4.20")
|
|
29
|
+
|
|
30
|
+
version_info = bb.get_version()
|
|
31
|
+
print(f"Device version: {version_info.version}")
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
You can also use context manager.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from busylib import BusyBar
|
|
38
|
+
|
|
39
|
+
with BusyBar("10.0.4.20") as bb:
|
|
40
|
+
version_info = bb.get_version()
|
|
41
|
+
print(f"Device version: {version_info.version}")
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API Examples
|
|
45
|
+
|
|
46
|
+
Here are some examples of how to use the library to control your Busy Bar device.
|
|
47
|
+
|
|
48
|
+
### Uploading an Asset
|
|
49
|
+
|
|
50
|
+
You can upload files (like images or sounds) to be used by your application on the device.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
with open("path/to/your/image.png", "rb") as f:
|
|
54
|
+
file_bytes = f.read()
|
|
55
|
+
response = bb.upload_asset(
|
|
56
|
+
app_id="my-app",
|
|
57
|
+
filename="logo.png",
|
|
58
|
+
data=file_bytes
|
|
59
|
+
)
|
|
60
|
+
print(f"Upload result: {response.result}")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
with open("path/to/your/sound.wav", "rb") as f:
|
|
64
|
+
file_bytes = f.read()
|
|
65
|
+
response = bb.upload_asset(
|
|
66
|
+
app_id="my-app",
|
|
67
|
+
filename="notification.wav",
|
|
68
|
+
data=file_bytes
|
|
69
|
+
)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Drawing on the Display
|
|
73
|
+
|
|
74
|
+
Draw text or images on the device's screen. The `draw_on_display` method accepts a `DisplayElements` object containing a list of elements to render.
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from busylib import types
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
text_element = types.TextElement(
|
|
81
|
+
id="hello",
|
|
82
|
+
type="text",
|
|
83
|
+
x=10,
|
|
84
|
+
y=20,
|
|
85
|
+
text="Hello, World!",
|
|
86
|
+
display=types.DisplayName.FRONT,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
image_element = types.ImageElement(
|
|
90
|
+
id="logo",
|
|
91
|
+
type="image",
|
|
92
|
+
x=50,
|
|
93
|
+
y=40,
|
|
94
|
+
path="logo.png",
|
|
95
|
+
display=types.DisplayName.BACK,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
display_data = types.DisplayElements(
|
|
99
|
+
app_id="my-app",
|
|
100
|
+
elements=[text_element, image_element]
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
response = bb.draw_on_display(display_data)
|
|
104
|
+
print(f"Draw result: {response.result}")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Clearing the Display
|
|
108
|
+
|
|
109
|
+
To clear everything from the screen:
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
response = bb.clear_display()
|
|
113
|
+
print(f"Clear result: {response.result}")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Playing Audio
|
|
117
|
+
|
|
118
|
+
Play an audio file that you have already uploaded.
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
response = bb.play_audio(app_id="my-app", path="notification.wav")
|
|
122
|
+
print(f"Play result: {response.result}")
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Stopping Audio
|
|
126
|
+
|
|
127
|
+
To stop any audio that is currently playing:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
response = bb.stop_audio()
|
|
131
|
+
print(f"Stop result: {response.result}")
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Deleting All Assets for an App
|
|
135
|
+
|
|
136
|
+
This will remove all files associated with a specific `app_id`.
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
response = bb.delete_app_assets(app_id="my-app")
|
|
140
|
+
print(f"Delete result: {response.result}")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Getting Device Status
|
|
144
|
+
|
|
145
|
+
You can get various status information from the device:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
version = bb.get_version()
|
|
149
|
+
print(f"Version: {version.version}, Branch: {version.branch}")
|
|
150
|
+
|
|
151
|
+
status = bb.get_status()
|
|
152
|
+
if status.system:
|
|
153
|
+
print(f"Uptime: {status.system.uptime}")
|
|
154
|
+
if status.power:
|
|
155
|
+
print(f"Battery: {status.power.battery_charge}%")
|
|
156
|
+
|
|
157
|
+
brightness = bb.get_display_brightness()
|
|
158
|
+
print(f"Front brightness: {brightness.front}, Back brightness: {brightness.back}")
|
|
159
|
+
|
|
160
|
+
volume = bb.get_audio_volume()
|
|
161
|
+
print(f"Volume: {volume.volume}")
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Working with Storage
|
|
165
|
+
|
|
166
|
+
You can manage files in the device's storage:
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
file_data = b"Hello, world!"
|
|
170
|
+
response = bb.write_storage_file(path="/my-app/data.txt", data=file_data)
|
|
171
|
+
|
|
172
|
+
file_content = bb.read_storage_file(path="/my-app/data.txt")
|
|
173
|
+
print(file_content.decode('utf-8'))
|
|
174
|
+
|
|
175
|
+
storage_list = bb.list_storage_files(path="/my-app")
|
|
176
|
+
for item in storage_list.list:
|
|
177
|
+
if item.type == "file":
|
|
178
|
+
print(f"File: {item.name} ({item.size} bytes)")
|
|
179
|
+
else:
|
|
180
|
+
print(f"Directory: {item.name}")
|
|
181
|
+
|
|
182
|
+
response = bb.create_storage_directory(path="/my-app/subdirectory")
|
|
183
|
+
|
|
184
|
+
response = bb.remove_storage_file(path="/my-app/data.txt")
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Development
|
|
188
|
+
|
|
189
|
+
To set up a development environment, clone the repository and install the package in editable mode with test dependencies:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
git clone https://github.com/busy-app/busylib
|
|
193
|
+
cd busylib
|
|
194
|
+
python3 -m venv .venv
|
|
195
|
+
source .venv/bin/activate
|
|
196
|
+
make install-dev
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
To run the tests:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
make test
|
|
203
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .client import BusyBar
|