django-growl-notifier 1.0.4__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Hadi Cahyadi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include django_growl *.py
4
+ recursive-include django_growl *.png
@@ -0,0 +1,513 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-growl-notifier
3
+ Version: 1.0.4
4
+ Summary: Send Django server notifications to Growl
5
+ Home-page: https://github.com/cumulus13/django-growl-notifier
6
+ Author: Hadi Cahyadi
7
+ Author-email: Hadi Cahyadi <cumulus13@gmail.com>
8
+ License: MIT
9
+ Keywords: django,growl,notifications,development
10
+ Classifier: Framework :: Django
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: Django>=3.2
16
+ Requires-Dist: gntp>=1.0.3
17
+ Dynamic: author
18
+ Dynamic: home-page
19
+ Dynamic: license-file
20
+ Dynamic: requires-python
21
+
22
+ # Django Growl Notifier
23
+
24
+ [![PyPI version](https://badge.fury.io/py/django-growl-notifier.svg)](https://badge.fury.io/py/django-growl-notifier)
25
+ [![Python Versions](https://img.shields.io/pypi/pyversions/django-growl-notifier.svg)](https://pypi.org/project/django-growl-notifier/)
26
+ [![Django Versions](https://img.shields.io/badge/django-3.2%20%7C%204.0%20%7C%205.0-blue.svg)](https://www.djangoproject.com/)
27
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
28
+
29
+ Send Django development server notifications to Growl (or compatible notification systems like Growl for Windows, Snarl, or prowlnotify).
30
+
31
+ ## โœจ Features
32
+
33
+ - ๐Ÿš€ **Automatic notifications** when Django server starts
34
+ - ๐Ÿ”ฅ **Error notifications** with detailed stacktrace
35
+ - ๐ŸŒ **Multiple Growl hosts** support - broadcast to multiple machines
36
+ - ๐ŸŽจ **Custom icons** support for notifications
37
+ - โš™๏ธ **Easy configuration** - minimal setup required
38
+ - ๐ŸŽฏ **Manual notifications** - trigger notifications anywhere in your code
39
+ - ๐Ÿ”‡ **Silent mode** - disable notifications when needed
40
+ - ๐Ÿ“ **Detailed logging** - track notification delivery
41
+
42
+ ## ๐Ÿ“ฆ Installation
43
+
44
+ ### Via pip
45
+
46
+ ```bash
47
+ pip install django-growl-notifier
48
+ ```
49
+
50
+ ### From source
51
+
52
+ ```bash
53
+ git clone https://github.com/cumulus13/django-growl-notifier.git
54
+ cd django-growl-notifier
55
+ pip install -e .
56
+ ```
57
+
58
+ ## ๐Ÿš€ Quick Setup
59
+
60
+ ### 1. Add to INSTALLED_APPS
61
+
62
+ Add `django_growl` to your `INSTALLED_APPS` in `settings.py`:
63
+
64
+ ```python
65
+ INSTALLED_APPS = [
66
+ # ... your other apps
67
+ 'django_growl',
68
+ ]
69
+ ```
70
+
71
+ ### 2. Configure Growl Hosts
72
+
73
+ Add Growl configuration to your `settings.py`:
74
+
75
+ ```python
76
+ # Required: List of Growl hosts (IP:PORT or just IP)
77
+ GROWL_HOSTS = [
78
+ '127.0.0.1:23053', # Local machine
79
+ '192.168.1.100:23053', # Remote machine on network
80
+ ]
81
+
82
+ # Optional settings
83
+ GROWL_APP_NAME = 'My Django App' # Default: 'Django Server'
84
+ GROWL_ENABLED = True # Default: True
85
+ ```
86
+
87
+ ### 3. Run Your Server
88
+
89
+ ```bash
90
+ # Option 1: Use regular runserver (with auto-notify)
91
+ python manage.py runserver
92
+
93
+ # Option 2: Use custom command with explicit notification
94
+ python manage.py runserver_growl
95
+
96
+ # Option 3: Specify address and port
97
+ python manage.py runserver 0.0.0.0:8000
98
+ ```
99
+
100
+ You'll see a Growl notification when the server starts! ๐ŸŽ‰
101
+
102
+ ## โš™๏ธ Configuration
103
+
104
+ ### All Available Settings
105
+
106
+ ```python
107
+ # settings.py
108
+
109
+ # ============================================
110
+ # REQUIRED SETTINGS
111
+ # ============================================
112
+
113
+ # List of Growl notification hosts
114
+ # Format: 'IP:PORT' or 'IP' (defaults to port 23053)
115
+ GROWL_HOSTS = [
116
+ '127.0.0.1:23053',
117
+ '192.168.1.50', # Will use port 23053
118
+ ]
119
+
120
+ # ============================================
121
+ # OPTIONAL SETTINGS
122
+ # ============================================
123
+
124
+ # Application name displayed in Growl
125
+ GROWL_APP_NAME = 'Django Server' # Default
126
+
127
+ # Enable or disable all notifications
128
+ GROWL_ENABLED = True # Default
129
+
130
+ # Custom icon for notifications
131
+ # Supports: file path, file:// URI, or http(s):// URL
132
+ GROWL_ICON = '/path/to/your/icon.png'
133
+
134
+ # Enable error notifications via middleware
135
+ GROWL_NOTIFY_ERRORS = True # Default
136
+
137
+ # Make error notifications sticky (stay visible)
138
+ GROWL_STICKY_ERRORS = True # Default
139
+
140
+ # Make server start notifications sticky
141
+ GROWL_STICKY_SERVER = False # Default
142
+ ```
143
+
144
+ ### Icon Configuration
145
+
146
+ Django Growl Notifier supports custom icons for notifications:
147
+
148
+ ```python
149
+ # Use a local file
150
+ GROWL_ICON = '/path/to/django-logo.png'
151
+
152
+ # Use file URI
153
+ GROWL_ICON = 'file:///path/to/icon.png'
154
+
155
+ # Use HTTP URL (if Growl supports it)
156
+ GROWL_ICON = 'https://example.com/icon.png'
157
+ ```
158
+
159
+ **Icon Priority:**
160
+ 1. Parameter passed to `send_notification(icon=...)`
161
+ 2. `GROWL_ICON` environment variable
162
+ 3. `GROWL_ICON` in settings.py
163
+ 4. Default `icon.png` in package directory
164
+
165
+ ## ๐Ÿ“– Usage
166
+
167
+ ### Automatic Server Start Notifications
168
+
169
+ Notifications are sent automatically when you start the Django development server:
170
+
171
+ ```bash
172
+ $ python manage.py runserver
173
+ System check identified no issues (0 silenced).
174
+ December 03, 2025 - 11:35:30
175
+ Django version 5.2.8, using settings 'myproject.settings'
176
+ Starting development server at http://127.0.0.1:8000/
177
+ โœ“ Growl notification sent to 2 host(s)
178
+ Quit the server with CONTROL-C.
179
+ ```
180
+
181
+ ### Error Notifications with Middleware
182
+
183
+ Get notified automatically when errors occur in your Django application.
184
+
185
+ **Setup:**
186
+
187
+ Add the middleware to your `settings.py`:
188
+
189
+ ```python
190
+ MIDDLEWARE = [
191
+ # ... your other middleware
192
+ 'django_growl.middleware.GrowlErrorMiddleware',
193
+ ]
194
+
195
+ # Optional: Configure error notification behavior
196
+ GROWL_NOTIFY_ERRORS = True # Enable error notifications
197
+ GROWL_STICKY_ERRORS = True # Make error notifications sticky
198
+ ```
199
+
200
+ **What you get:**
201
+ - Automatic notifications on 500 errors
202
+ - Full exception details and stacktrace
203
+ - Request path and HTTP method
204
+ - Sticky notifications (so you don't miss them)
205
+
206
+ ### Manual Notifications
207
+
208
+ Send custom notifications from anywhere in your Django code:
209
+
210
+ ```python
211
+ from django_growl import send_notification
212
+
213
+ # Basic notification
214
+ send_notification(
215
+ title="Task Complete",
216
+ message="Database backup finished successfully"
217
+ )
218
+
219
+ # With all options
220
+ send_notification(
221
+ title="User Registration",
222
+ message="New user: john@example.com",
223
+ note_type='Info', # 'Info', 'Error', or 'Server Status'
224
+ sticky=True, # Keep notification visible
225
+ icon='/path/to/icon.png' # Custom icon for this notification
226
+ )
227
+ ```
228
+
229
+ **Use Cases:**
230
+ - Celery task completion
231
+ - Scheduled job notifications
232
+ - Custom admin actions
233
+ - Database migrations
234
+ - Deployment scripts
235
+
236
+ ### Programmatic Control
237
+
238
+ ```python
239
+ from django_growl import get_growl_notifier
240
+
241
+ # Get the notifier instance
242
+ notifier = get_growl_notifier()
243
+
244
+ # Check if enabled
245
+ if notifier.enabled:
246
+ notifier.notify(
247
+ title="Custom Alert",
248
+ message="Something important happened",
249
+ note_type='Info',
250
+ sticky=False
251
+ )
252
+ ```
253
+
254
+ ## ๐ŸŽจ Examples
255
+
256
+ ### Example 1: Task Completion in Views
257
+
258
+ ```python
259
+ from django.shortcuts import render
260
+ from django_growl import send_notification
261
+ from .models import Report
262
+
263
+ def generate_report(request):
264
+ # Generate report
265
+ report = Report.objects.create(...)
266
+
267
+ # Notify via Growl
268
+ send_notification(
269
+ title="Report Generated",
270
+ message=f"Report #{report.id} is ready for download",
271
+ sticky=True
272
+ )
273
+
274
+ return render(request, 'report.html', {'report': report})
275
+ ```
276
+
277
+ ### Example 2: Celery Task Notification
278
+
279
+ ```python
280
+ from celery import shared_task
281
+ from django_growl import send_notification
282
+
283
+ @shared_task
284
+ def process_large_dataset(dataset_id):
285
+ # Process data...
286
+ result = do_processing(dataset_id)
287
+
288
+ # Notify when complete
289
+ send_notification(
290
+ title="Processing Complete",
291
+ message=f"Dataset {dataset_id} processed: {result.count} records",
292
+ note_type='Info'
293
+ )
294
+
295
+ return result
296
+ ```
297
+
298
+ ### Example 3: Management Command
299
+
300
+ ```python
301
+ from django.core.management.base import BaseCommand
302
+ from django_growl import send_notification
303
+
304
+ class Command(BaseCommand):
305
+ help = 'Cleanup old data'
306
+
307
+ def handle(self, *args, **options):
308
+ # Cleanup logic
309
+ deleted_count = cleanup_old_data()
310
+
311
+ # Notify
312
+ send_notification(
313
+ title="Cleanup Complete",
314
+ message=f"Removed {deleted_count} old records"
315
+ )
316
+
317
+ self.stdout.write(self.style.SUCCESS('Done!'))
318
+ ```
319
+
320
+ ### Example 4: Custom Admin Action
321
+
322
+ ```python
323
+ from django.contrib import admin
324
+ from django_growl import send_notification
325
+
326
+ @admin.register(MyModel)
327
+ class MyModelAdmin(admin.ModelAdmin):
328
+ actions = ['export_selected']
329
+
330
+ def export_selected(self, request, queryset):
331
+ count = queryset.count()
332
+ # Export logic...
333
+
334
+ send_notification(
335
+ title="Export Complete",
336
+ message=f"Exported {count} items",
337
+ sticky=True
338
+ )
339
+
340
+ self.message_user(request, f"Exported {count} items")
341
+
342
+ export_selected.short_description = "Export selected items"
343
+ ```
344
+
345
+ ## ๐Ÿ”ง Troubleshooting
346
+
347
+ ### Notifications Not Appearing
348
+
349
+ 1. **Check if Growl is running:**
350
+ ```bash
351
+ # Windows: Check Task Manager for Growl.exe
352
+ # Mac: Check if Growl is running in menu bar
353
+ ```
354
+
355
+ 2. **Verify network connectivity:**
356
+ ```bash
357
+ # Test if port is open
358
+ telnet 192.168.1.100 23053
359
+ ```
360
+
361
+ 3. **Check Django logs:**
362
+ ```python
363
+ # settings.py - Enable debug logging
364
+ LOGGING = {
365
+ 'version': 1,
366
+ 'handlers': {
367
+ 'console': {'class': 'logging.StreamHandler'},
368
+ },
369
+ 'loggers': {
370
+ 'django_growl': {
371
+ 'handlers': ['console'],
372
+ 'level': 'DEBUG',
373
+ },
374
+ },
375
+ }
376
+ ```
377
+
378
+ 4. **Verify settings:**
379
+ ```python
380
+ # In Django shell
381
+ from django.conf import settings
382
+ print(settings.GROWL_HOSTS)
383
+ print(settings.GROWL_ENABLED)
384
+ ```
385
+
386
+ ### Common Issues
387
+
388
+ **Issue:** "Failed to register Growl notifier"
389
+ - **Solution:** Check if Growl is accepting network notifications. Enable "Listen for incoming notifications" in Growl settings.
390
+
391
+ **Issue:** Notifications work locally but not on remote hosts
392
+ - **Solution:** Check firewall settings. Port 23053 must be open on remote machines.
393
+
394
+ **Issue:** Icons not showing
395
+ - **Solution:** Verify icon path exists and is accessible. Use absolute paths or URIs.
396
+
397
+ **Issue:** Too many notifications during development
398
+ - **Solution:** Temporarily disable:
399
+ ```python
400
+ GROWL_ENABLED = False
401
+ ```
402
+
403
+ ## ๐Ÿ” Advanced Usage
404
+
405
+ ### Environment Variable Override
406
+
407
+ You can override settings using environment variables:
408
+
409
+ ```bash
410
+ # Disable notifications temporarily
411
+ export GROWL_ENABLED=false
412
+ python manage.py runserver
413
+
414
+ # Use custom icon
415
+ export GROWL_ICON=/path/to/custom-icon.png
416
+ python manage.py runserver
417
+ ```
418
+
419
+ ### Multiple Notification Types
420
+
421
+ ```python
422
+ from django_growl import send_notification
423
+
424
+ # Info notification (default)
425
+ send_notification("Task Done", "Completed successfully", note_type='Info')
426
+
427
+ # Error notification
428
+ send_notification("Task Failed", "Error occurred", note_type='Error')
429
+
430
+ # Server status notification
431
+ send_notification("Server Event", "Config reloaded", note_type='Server Status')
432
+ ```
433
+
434
+ ### Conditional Notifications
435
+
436
+ ```python
437
+ from django.conf import settings
438
+ from django_growl import send_notification
439
+
440
+ def my_view(request):
441
+ # Only notify in development
442
+ if settings.DEBUG:
443
+ send_notification("Debug", "View accessed")
444
+
445
+ # Only notify for specific users
446
+ if request.user.is_staff:
447
+ send_notification("Admin Action", f"{request.user} performed action")
448
+ ```
449
+
450
+ ## ๐Ÿงช Testing
451
+
452
+ ```bash
453
+ # Install dev dependencies
454
+ pip install -e .[dev]
455
+
456
+ # Run tests
457
+ python -m pytest
458
+
459
+ # With coverage
460
+ python -m pytest --cov=django_growl
461
+ ```
462
+
463
+ ## ๐Ÿค Contributing
464
+
465
+ Contributions are welcome! Please feel free to submit a Pull Request.
466
+
467
+ 1. Fork the repository
468
+ 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
469
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
470
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
471
+ 5. Open a Pull Request
472
+
473
+ ## ๐Ÿ“‹ Requirements
474
+
475
+ - Python >= 3.8
476
+ - Django >= 3.2
477
+ - gntp >= 1.0.3
478
+ - version_get
479
+ - Growl for Windows, Growl (macOS), or compatible notification system use GNTP
480
+
481
+ ## ๐Ÿ“„ License
482
+
483
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
484
+
485
+ ## ๐Ÿ‘ค Author
486
+
487
+ **Hadi Cahyadi**
488
+ - Email: [cumulus13@gmail.com](mailto:cumulus13@gmail.com)
489
+ - GitHub: [@cumulus13](https://github.com/cumulus13)
490
+
491
+ ## ๐Ÿ’– Support
492
+
493
+ If you find this project helpful, please consider supporting:
494
+
495
+ [![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/cumulus13)
496
+ [![Donate via Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/cumulus13)
497
+ [![Support on Patreon](https://img.shields.io/badge/Patreon-Support-red.svg)](https://www.patreon.com/cumulus13)
498
+
499
+ ## ๐Ÿ™ Acknowledgments
500
+
501
+ - Thanks to the [Growl](https://growl.github.io/growl/) team for the notification system
502
+ - Thanks to the Django community for the excellent web framework
503
+ - Built with โค๏ธ by developers, for developers
504
+
505
+ ## ๐Ÿ“š Related Projects
506
+
507
+ - [gntp](https://github.com/kfdm/gntp) - Growl Notification Transport Protocol library
508
+ - [django-notifications](https://github.com/django-notifications/django-notifications) - Generic notification system for Django
509
+ - [Growl for Windows](http://www.growlforwindows.com/) - Windows implementation of Growl
510
+
511
+ ---
512
+
513
+ **Star โญ this repo if you find it useful!**