piwave 2.0.5__py3-none-any.whl → 2.0.7__py3-none-any.whl

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.
piwave/piwave.py CHANGED
@@ -13,6 +13,7 @@ import sys
13
13
  from typing import List, Optional, Callable
14
14
  from pathlib import Path
15
15
  from urllib.parse import urlparse
16
+ import atexit
16
17
 
17
18
  class Log:
18
19
  COLORS = { # absolutely not taken from stackoverflow trust
@@ -48,8 +49,17 @@ class Log:
48
49
  'update': 'UPD',
49
50
  }
50
51
 
52
+ SILENT = False
53
+
54
+ @classmethod
55
+ def config(cls, silent: bool = False):
56
+ cls.SILENT = silent
57
+
51
58
  @classmethod
52
59
  def print(cls, message: str, style: str = '', icon: str = '', end: str = '\n'):
60
+
61
+ if cls.SILENT: return
62
+
53
63
  color = cls.COLORS.get(style, '')
54
64
  icon_char = cls.ICONS.get(icon, '')
55
65
  if icon_char:
@@ -110,6 +120,7 @@ class PiWave:
110
120
  pi: str = "FFFF",
111
121
  loop: bool = False,
112
122
  debug: bool = False,
123
+ silent: bool = False,
113
124
  on_track_change: Optional[Callable] = None,
114
125
  on_error: Optional[Callable] = None):
115
126
  """Initialize PiWave FM transmitter.
@@ -126,6 +137,8 @@ class PiWave:
126
137
  :type loop: bool
127
138
  :param debug: Enable debug logging
128
139
  :type debug: bool
140
+ :param silent: Removes every output log
141
+ :type silent: bool
129
142
  :param on_track_change: Callback function called when track changes
130
143
  :type on_track_change: Optional[Callable]
131
144
  :param on_error: Callback function called when an error occurs
@@ -158,13 +171,15 @@ class PiWave:
158
171
 
159
172
  self.temp_dir = tempfile.mkdtemp(prefix="piwave_")
160
173
  self.stream_process: Optional[subprocess.Popen] = None
174
+
175
+ Log.config(silent=silent)
161
176
 
162
177
  self.pi_fm_rds_path = self._find_pi_fm_rds_path()
163
178
 
164
179
  self._validate_environment()
165
180
 
166
- signal.signal(signal.SIGINT, self._handle_interrupt)
167
- signal.signal(signal.SIGTERM, self._handle_interrupt)
181
+ atexit.register(self.cleanup)
182
+
168
183
 
169
184
  Log.info(f"PiWave initialized - Frequency: {frequency}MHz, PS: {ps}, Loop: {loop}")
170
185
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: piwave
3
- Version: 2.0.5
3
+ Version: 2.0.7
4
4
  Summary: A python module to broadcast radio waves with your Raspberry Pi.
5
5
  Home-page: https://github.com/douxxtech/piwave
6
6
  Author: Douxx
@@ -122,6 +122,7 @@ To install PiWave manually, follow these steps:
122
122
  pi="ABCD",
123
123
  loop=True,
124
124
  debug=True,
125
+ silent=False,
125
126
  on_track_change=lambda file, index: print(f"Now playing: {file}"),
126
127
  on_error=lambda error: print(f"Error occurred: {error}")
127
128
  )
@@ -181,6 +182,7 @@ To install PiWave manually, follow these steps:
181
182
  - `pi`: Program Identifier (up to 4 characters, default: "FFFF").
182
183
  - `loop`: Whether to loop playback of files (default: False).
183
184
  - `debug`: Enable detailed debug logging (default: False).
185
+ - `silent`: Disables every log output (default: False).
184
186
  - `on_track_change`: Callback function when the track changes (default: None).
185
187
  - `on_error`: Callback function when an error occurs (default: None).
186
188
 
@@ -0,0 +1,7 @@
1
+ piwave/__init__.py,sha256=tAmruZvneieh6fgkf7chKzOX9Q6fEB-5Jt9FJ7Fl5xQ,74
2
+ piwave/piwave.py,sha256=GkhNuw_mZnEZbUf6AC4mx4QwYpeFsSDpj1RqXUTf3Ms,24613
3
+ piwave-2.0.7.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
4
+ piwave-2.0.7.dist-info/METADATA,sha256=7I5mVMuiAcAzklTaum2d7CqL_V4Z-urMPc6Vcgv4Cno,6845
5
+ piwave-2.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ piwave-2.0.7.dist-info/top_level.txt,sha256=xUbZ7Rk6OymSdDxmb9bfO8N-avJ9VYxP41GnXfwKYi8,7
7
+ piwave-2.0.7.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- piwave/__init__.py,sha256=tAmruZvneieh6fgkf7chKzOX9Q6fEB-5Jt9FJ7Fl5xQ,74
2
- piwave/piwave.py,sha256=NzSCOGaHCEquWYQvxlaYvnn4zRfx13vuCWBX6ETPEXA,24378
3
- piwave-2.0.5.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
4
- piwave-2.0.5.dist-info/METADATA,sha256=ANndDO8Kds5p9NZZD1ZMEVTBzxs3ZU2o59-QCBhf_YQ,6768
5
- piwave-2.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- piwave-2.0.5.dist-info/top_level.txt,sha256=xUbZ7Rk6OymSdDxmb9bfO8N-avJ9VYxP41GnXfwKYi8,7
7
- piwave-2.0.5.dist-info/RECORD,,
File without changes