httpcheck 1.4.2__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.
Files changed (32) hide show
  1. httpcheck-1.4.2/LICENSE +21 -0
  2. httpcheck-1.4.2/PKG-INFO +469 -0
  3. httpcheck-1.4.2/README.md +424 -0
  4. httpcheck-1.4.2/httpcheck/__init__.py +63 -0
  5. httpcheck-1.4.2/httpcheck/cli.py +601 -0
  6. httpcheck-1.4.2/httpcheck/common.py +143 -0
  7. httpcheck-1.4.2/httpcheck/file_handler.py +237 -0
  8. httpcheck-1.4.2/httpcheck/logger.py +155 -0
  9. httpcheck-1.4.2/httpcheck/notification.py +53 -0
  10. httpcheck-1.4.2/httpcheck/output_formatter.py +294 -0
  11. httpcheck-1.4.2/httpcheck/site_checker.py +213 -0
  12. httpcheck-1.4.2/httpcheck/tld_manager.py +244 -0
  13. httpcheck-1.4.2/httpcheck/validation.py +631 -0
  14. httpcheck-1.4.2/httpcheck.egg-info/PKG-INFO +469 -0
  15. httpcheck-1.4.2/httpcheck.egg-info/SOURCES.txt +30 -0
  16. httpcheck-1.4.2/httpcheck.egg-info/dependency_links.txt +1 -0
  17. httpcheck-1.4.2/httpcheck.egg-info/entry_points.txt +2 -0
  18. httpcheck-1.4.2/httpcheck.egg-info/requires.txt +22 -0
  19. httpcheck-1.4.2/httpcheck.egg-info/top_level.txt +1 -0
  20. httpcheck-1.4.2/pyproject.toml +85 -0
  21. httpcheck-1.4.2/setup.cfg +4 -0
  22. httpcheck-1.4.2/tests/test_cli_integration.py +1061 -0
  23. httpcheck-1.4.2/tests/test_common.py +202 -0
  24. httpcheck-1.4.2/tests/test_file_handler.py +399 -0
  25. httpcheck-1.4.2/tests/test_httpcheck.py +795 -0
  26. httpcheck-1.4.2/tests/test_init.py +82 -0
  27. httpcheck-1.4.2/tests/test_output_formats.py +393 -0
  28. httpcheck-1.4.2/tests/test_performance.py +354 -0
  29. httpcheck-1.4.2/tests/test_request_customization.py +327 -0
  30. httpcheck-1.4.2/tests/test_site_checker.py +577 -0
  31. httpcheck-1.4.2/tests/test_tld_manager.py +101 -0
  32. httpcheck-1.4.2/tests/test_validation.py +647 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Thomas Juul Dyhr
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,469 @@
1
+ Metadata-Version: 2.4
2
+ Name: httpcheck
3
+ Version: 1.4.2
4
+ Summary: HTTP status code checker with advanced features
5
+ Author-email: Thomas Juul Dyhr <thomas@dyhr.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/docdyhr/httpcheck
8
+ Project-URL: Bug Tracker, https://github.com/docdyhr/httpcheck/issues
9
+ Project-URL: Documentation, https://github.com/docdyhr/httpcheck/blob/master/README.md
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: System Administrators
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: System :: Monitoring
21
+ Classifier: Topic :: System :: Networking :: Monitoring
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: requests>=2.32.5
26
+ Requires-Dist: tabulate>=0.9.0
27
+ Requires-Dist: tqdm>=4.67.0
28
+ Requires-Dist: validators>=0.22.0
29
+ Provides-Extra: macos
30
+ Requires-Dist: rumps>=0.4.0; extra == "macos"
31
+ Requires-Dist: pyobjc-framework-Cocoa>=10.0; extra == "macos"
32
+ Requires-Dist: pyobjc-framework-Foundation>=10.0; extra == "macos"
33
+ Requires-Dist: pyobjc-framework-AppKit>=10.0; extra == "macos"
34
+ Requires-Dist: pyobjc-core>=10.0; extra == "macos"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=7.0; extra == "dev"
37
+ Requires-Dist: pytest-mock>=3.0; extra == "dev"
38
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
39
+ Requires-Dist: pytest-benchmark>=5.0; extra == "dev"
40
+ Requires-Dist: pylint>=3.1.0; extra == "dev"
41
+ Requires-Dist: mypy>=1.0; extra == "dev"
42
+ Provides-Extra: build
43
+ Requires-Dist: py2app>=0.28; extra == "build"
44
+ Dynamic: license-file
45
+
46
+ [![CI/CD Pipeline](https://github.com/docdyhr/httpcheck/actions/workflows/ci.yml/badge.svg)](https://github.com/docdyhr/httpcheck/actions/workflows/ci.yml)
47
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
48
+ ![Python Version](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)
49
+ [![GitHub issues](https://img.shields.io/github/issues/docdyhr/httpcheck)](https://github.com/docdyhr/httpcheck/issues)
50
+ ![GitHub repo size](https://img.shields.io/github/repo-size/docdyhr/httpcheck)
51
+ ![GitHub](https://img.shields.io/github/license/docdyhr/httpcheck)
52
+
53
+ # Check Websites HTTP Status Codes with httpcheck
54
+
55
+ <img src="images/onSiteLogo.png" alt="onSite Logo" width="50%">
56
+
57
+ * **Name**: httpcheck (CLI) / onSite (Menu Bar App)
58
+ * **Current Version**: 1.4.1 (Security & Architecture Patch)
59
+ * **Target Version**: 1.5.0 (Performance & Configuration Features)
60
+ * **Programming Language**: Python 3.9+
61
+ * **Author**: Thomas Juul Dyhr
62
+ * **Purpose**: Advanced HTTP status checker with monitoring capabilities
63
+ * **Development Status**: Active - See [ROADMAP.md](ROADMAP.md) for development plan
64
+
65
+ ## 🚀 Release Status
66
+
67
+ **httpcheck v1.4.1 has been released! 🔒**
68
+
69
+ ✅ **NEW in v1.4.1:**
70
+ - **Security Patches**: Updated dependencies (requests 2.32.5, urllib3 2.5.0)
71
+ - **Improved Entry Point**: Refactored CLI to proper package function
72
+ - **Mypy Support**: Added type checking configuration
73
+ - **Pytest Fix**: Resolved asyncio deprecation warning
74
+
75
+ ✅ **v1.4.0 Foundation:**
76
+ - **Modular Architecture**: 8 specialized modules
77
+ - **Enhanced Security**: Enterprise-grade input validation
78
+ - **Comprehensive Testing**: 88% test coverage with 190 test cases
79
+ - **Multiple Output Formats**: JSON and CSV support
80
+ - **Advanced Request Control**: Custom headers, SSL options
81
+ - **Package Installation**: `pip install -e .`
82
+
83
+ 🚀 **Next: v1.5.0 Development Focus**
84
+ - **Async I/O**: 2-3x performance improvement for large site lists
85
+ - **Configuration Files**: User-defined defaults and settings
86
+ - **Monitoring Mode**: Continuous site monitoring with notifications
87
+ - **Enhanced UX**: Colored output and improved progress reporting
88
+
89
+ See detailed plans in:
90
+ - [DEVELOPMENT_PLAN.md](DEVELOPMENT_PLAN.md) - Executive overview and timeline
91
+ - [DEVELOPMENT.md](DEVELOPMENT.md) - Technical implementation guide
92
+ - [TODO.md](TODO.md) - Current prioritized task list
93
+ - [ROADMAP.md](ROADMAP.md) - Long-term vision through v2.0.0
94
+
95
+ ## usage:
96
+
97
+ ```
98
+ httpcheck [-h] [-t] [--disable-tld-checks] [--tld-warning-only]
99
+ [--update-tld-list] [--tld-cache-days TLD_CACHE_DAYS]
100
+ [-q | -v | -c | -f] [--timeout TIMEOUT] [--retries RETRIES]
101
+ [--workers WORKERS] [--file-summary]
102
+ [--comment-style {hash,slash,both}]
103
+ [--follow-redirects {always,never,http-only,https-only}]
104
+ [--max-redirects MAX_REDIRECTS] [--show-redirect-timing]
105
+ [--output {table,json,csv}] [--version] [site ...]
106
+ ```
107
+
108
+ ### positional arguments
109
+
110
+ site return http status codes for one or more websites
111
+
112
+ ### optional arguments
113
+
114
+ -h, --help show this help message and exit
115
+ -t, --tld check if domain is in global list of TLDs
116
+ --disable-tld-checks disable TLD validation checks
117
+ --tld-warning-only show warnings for invalid TLDs without failing
118
+ --update-tld-list force update of the TLD list from publicsuffix.org
119
+ --tld-cache-days TLD_CACHE_DAYS
120
+ number of days to keep the TLD cache valid (default: 30)
121
+ -q, --quiet only print errors
122
+ -v, --verbose increase output verbosity
123
+ -c, --code only print status code
124
+ -f, --fast fast check wtih threading
125
+ --timeout TIMEOUT set the timeout for each request
126
+ --retries RETRIES set the number of retries for each request
127
+ --retry-delay DELAY delay in seconds between retry attempts (default: 1.0)
128
+ --workers WORKERS set the number of worker threads
129
+ -H, --header HEADER add custom HTTP header (can be used multiple times)
130
+ --no-verify-ssl disable SSL certificate verification
131
+ --file-summary show summary of file parsing results (valid URLs, comments, etc.)
132
+ --comment-style {hash,slash,both}
133
+ comment style to recognize: hash (#), slash (//), or both (default: both)
134
+ --follow-redirects {always,never,http-only,https-only}
135
+ control redirect following behavior (default: always)
136
+ --max-redirects MAX_REDIRECTS
137
+ maximum number of redirects to follow (default: 30)
138
+ --show-redirect-timing show detailed timing for each redirect in the chain
139
+ --output {table,json,csv}
140
+ output format: table (default), json, or csv
141
+ --version show program's version number and exit
142
+
143
+ ### additional information
144
+
145
+ enter sites in url or 'no' url form: 'httpcheck duckduckgo.com'
146
+ read sites from a file: 'httpcheck @domains.txt'.
147
+
148
+ output formats:
149
+ - Table (default): Human-readable columnar output
150
+ - JSON: Machine-parsable format for automation
151
+ - CSV: Comma-separated values for spreadsheets
152
+
153
+ Example: 'httpcheck google.com github.com --output json'
154
+
155
+ [List of HTTP status codes](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes)
156
+
157
+ ## installation
158
+
159
+ clone repo and install requirements.
160
+
161
+ ### clone the repository
162
+
163
+ ```shell
164
+ git clone https://github.com/docdyhr/httpcheck
165
+ cd httpcheck/
166
+ ```
167
+
168
+ ### install requirements
169
+
170
+ ```shell
171
+ python3 -m pip install . --user
172
+ ```
173
+
174
+ On macOS, install terminal-notifier for notifications:
175
+
176
+ ```shell
177
+ brew install terminal-notifier
178
+ ```
179
+
180
+ ### alternative install
181
+
182
+ set up a virtual environment with venv.
183
+
184
+ ```shell
185
+ python3 -m venv .venv
186
+ source .venv/bin/activate
187
+ pip install -e .
188
+ ```
189
+
190
+ or
191
+
192
+ ```shell
193
+ mv httpcheck.py ~/bin/httpcheck # any other bin folder
194
+ chmod + ~/bin/httpcheck
195
+ ```
196
+
197
+ ## features
198
+
199
+ * Check HTTP status codes for one or more websites
200
+ * Support for macOS notifications on failures
201
+ * **NEW: Menu bar app for continuous monitoring**
202
+ * Live status indicator in menu bar (🟢/🔴)
203
+ * Background checking with configurable intervals
204
+ * Rich native macOS notifications with actions
205
+ * Click notifications to open failing sites
206
+ * Easy site management through menu interface
207
+ * Advanced redirect tracking and control
208
+ * Follow all redirects, none, or limit by protocol (HTTP/HTTPS)
209
+ * Configure maximum number of redirects to follow
210
+ * View detailed per-hop timing information in redirect chains
211
+ * Enhanced TLD validation
212
+ * Caches TLD list for better performance
213
+ * Auto-updates from Public Suffix List
214
+ * Configurable cache duration
215
+ * Optional warning-only mode
216
+ * Enhanced file input handling
217
+ * Support for comments using # or // style
218
+ * Handles inline comments
219
+ * Automatically strips whitespace
220
+ * Detailed file parsing statistics
221
+ * Threading support for faster checks
222
+ * Progress bar for multiple site checks
223
+ * Configurable timeouts and retries
224
+ * Pipe and file input support
225
+ * **NEW: Multiple output formats**
226
+ * JSON format for easy parsing and automation
227
+ * CSV format for spreadsheet integration
228
+ * Table format (default) for human readability
229
+ * Verbose mode includes redirect details in all formats
230
+ * **NEW: Request customization options**
231
+ * Custom HTTP headers support with -H flag
232
+ * Configurable retry delay between attempts
233
+ * SSL certificate verification control
234
+ * Enhanced timeout configuration
235
+
236
+ ## usage examples
237
+
238
+ ```shell
239
+ python3 httpcheck.py https://duckduckgo.com
240
+ ```
241
+
242
+ returns ex. 'duckduckgo.com 200'
243
+
244
+ ### python from venv
245
+
246
+ ```shell
247
+ python httpcheck.py -v https://api.github.com/invalid
248
+ ```
249
+
250
+ returns verbose output ex. '[-] api.github.com --> Client errors: 404 Not Found'
251
+
252
+ ### installed as binary
253
+
254
+ ```shell
255
+ httpcheck -q @domains.txt
256
+ ```
257
+
258
+ only returns http status code errors ex. 'api.github.com 404'
259
+
260
+ ```shell
261
+ httpcheck -c 1.1.1.1
262
+ ```
263
+
264
+ status code only ex. '200'
265
+
266
+ ### notifications
267
+
268
+ On macOS, the tool will show notifications when sites fail checks. For sites with failures:
269
+
270
+ * Shows failure count
271
+ * Lists failed sites (when less than 10)
272
+ * Groups notifications to avoid duplicates
273
+
274
+ ### advanced usage examples
275
+
276
+ Control redirect behavior:
277
+
278
+ ```shell
279
+ # Don't follow any redirects
280
+ httpcheck --follow-redirects never example.com
281
+
282
+ # Only follow redirects to HTTP URLs (not HTTPS)
283
+ httpcheck --follow-redirects http-only example.com
284
+
285
+ # Only follow redirects to HTTPS URLs (not HTTP)
286
+ httpcheck --follow-redirects https-only example.com
287
+
288
+ # Show detailed timing for each redirect
289
+ httpcheck --show-redirect-timing http://example.com
290
+
291
+ # Limit redirect chain length
292
+ httpcheck --max-redirects 5 example.com
293
+
294
+ # Show timing for each redirect hop
295
+ httpcheck -v --show-redirect-timing example.com
296
+ ```
297
+
298
+ ### tld validation examples
299
+
300
+ Control TLD validation behavior:
301
+
302
+ ```shell
303
+ # Enable TLD validation
304
+ httpcheck -t example.com
305
+
306
+ # Force update of the TLD list from Public Suffix List
307
+ httpcheck -t --update-tld-list example.com
308
+
309
+ # Warn about invalid TLDs but don't fail
310
+ httpcheck -t --tld-warning-only example.com
311
+
312
+ # Disable TLD checks completely
313
+ httpcheck --disable-tld-checks example.com
314
+
315
+ # Set cache expiration to 60 days
316
+ httpcheck -t --tld-cache-days 60 example.com
317
+ ```
318
+
319
+ ### output format examples
320
+
321
+ Export results in different formats:
322
+
323
+ ```shell
324
+ # JSON output for single site
325
+ httpcheck google.com --output json
326
+
327
+ # JSON output for multiple sites with verbose details
328
+ httpcheck google.com github.com --output json -v
329
+
330
+ # CSV output for spreadsheet import
331
+ httpcheck @domains.txt --output csv
332
+
333
+ # CSV with full details including redirects
334
+ httpcheck @domains.txt --output csv -v
335
+
336
+ # Process JSON output with jq
337
+ httpcheck @sites.txt --output json | jq '.[] | select(.status != "200")'
338
+
339
+ # Save CSV report with date
340
+ httpcheck @sites.txt --output csv -v > report_$(date +%Y%m%d).csv
341
+
342
+ # Filter errors only in JSON format
343
+ httpcheck @sites.txt --output json -q | jq '.[] | .domain'
344
+ ```
345
+
346
+ ### request customization examples
347
+
348
+ Add custom headers and control SSL verification:
349
+
350
+ ```shell
351
+ # Add authorization header
352
+ httpcheck -H "Authorization: Bearer token123" api.example.com
353
+
354
+ # Multiple custom headers
355
+ httpcheck -H "User-Agent: MyBot 1.0" -H "Accept: application/json" api.example.com
356
+
357
+ # Disable SSL verification for self-signed certificates
358
+ httpcheck --no-verify-ssl https://self-signed.example.com
359
+
360
+ # Custom timeout and retry configuration
361
+ httpcheck --timeout 30 --retries 5 --retry-delay 2.0 slow.example.com
362
+
363
+ # Combine with other options
364
+ httpcheck -H "API-Key: secret" --output json --no-verify-ssl https://api.example.com
365
+ ```
366
+
367
+ ### file input examples
368
+
369
+ Create a domains file with comments and use it with httpcheck:
370
+
371
+ ```txt
372
+ # domains.txt - Example domains file
373
+ google.com # Search engine
374
+ facebook.com // Social media
375
+ twitter.com
376
+ // Commented out: example.com
377
+ ```
378
+
379
+ ```shell
380
+ # Basic file usage
381
+ httpcheck @domains.txt
382
+
383
+ # Show file parsing statistics
384
+ httpcheck --file-summary @domains.txt
385
+
386
+ # Only recognize # style comments
387
+ httpcheck --comment-style hash @domains.txt
388
+
389
+ # Only recognize // style comments
390
+ httpcheck --comment-style slash @domains.txt
391
+ ```
392
+
393
+ ## onSite - menu bar app (macOS)
394
+
395
+ For continuous monitoring with a native macOS experience, use onSite - the menu bar app:
396
+
397
+ ### installation
398
+
399
+ ```shell
400
+ # Install additional dependencies for menu bar app
401
+ pip install rumps pyobjc-framework-Cocoa py2app
402
+
403
+ # Run the menu bar app directly
404
+ python3 httpcheck_menubar.py
405
+ ```
406
+
407
+ ### building a standalone app
408
+
409
+ Create a native macOS app bundle:
410
+
411
+ ```shell
412
+ # Build the app (creates dist/onSite.app)
413
+ python setup.py py2app
414
+
415
+ # Copy to Applications folder
416
+ cp -r "dist/onSite.app" /Applications/
417
+
418
+ # Run from Applications or Spotlight
419
+ open "/Applications/onSite.app"
420
+ ```
421
+
422
+ ### menu bar app features
423
+
424
+ * **Live Status Indicator**: Menu bar shows ⚡ (white lightning - all
425
+ good/checking), 🔴⚡ (red + lightning - failures)
426
+ * **Badge Count**: Shows number of failed sites next to the icon
427
+ * **Rich Notifications**: Native macOS notifications with:
428
+ * Site down alerts with status codes
429
+ * Recovery notifications when sites come back online
430
+ * Click actions to open failing sites in browser
431
+ * Custom sounds for different alert types
432
+ * **Background Monitoring**: Configurable check intervals (default 15 minutes, minimum 60 seconds)
433
+ * **Site Management**: Add, remove, and edit monitored sites through menu
434
+ * **Settings**: Configure check intervals, clear failed sites, view logs
435
+ * **Configuration Storage**: Sites and settings saved to `~/.httpcheck/`
436
+
437
+ ### menu bar app usage
438
+
439
+ 1. **Add Sites**: Click menu bar icon → "Add Site..." → Enter URL (automatically checks status)
440
+ 2. **Manual Check**: Click "Check Now" for immediate status check
441
+ 3. **Auto-Check**: Toggle automatic background checking on/off (default: 15 minutes)
442
+ 4. **View Status**: Click on menu to see all sites with status indicators
443
+ 5. **Settings**: Adjust check interval, clear failed sites, view logs
444
+
445
+ ### keyboard shortcuts and tips
446
+
447
+ * Menu bar shows white lightning ⚡ for normal status, red lightning 🔴⚡ for failures
448
+ * Failed site count appears as badge number
449
+ * Notifications include action buttons (Check Now, View, Dismiss)
450
+ * Clicking notifications opens the failing site in your default browser
451
+ * Logs are stored in `~/Library/Logs/onSite/onsite.log` following macOS best practices
452
+ * Log rotation: 5MB max size, 5 backup files maintained automatically
453
+ * Logs viewable through Console.app or "View logs" menu item
454
+ * Configuration files stored in `~/.httpcheck/` for easy backup
455
+
456
+ ## history
457
+
458
+ checking one or more websites by constantly opening a browser seems a waste of
459
+ time. Providing a cli tool that can be used in a bash shell, pipe or for
460
+ scheduling tasks in cron, notifying the user, seems the way to go. The python
461
+ requests library seems perfect for the job.
462
+
463
+ ## todo
464
+
465
+ [TODO.md](https://github.com/docdyhr/httpcheck/blob/master/TODO.md)
466
+
467
+ ## license
468
+
469
+ [MIT](https://github.com/docdyhr/httpcheck/blob/master/LICENSE)