telert 0.2.6__tar.gz → 0.2.7__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 (28) hide show
  1. {telert-0.2.6/telert.egg-info → telert-0.2.7}/PKG-INFO +11 -4
  2. {telert-0.2.6 → telert-0.2.7}/README.md +10 -3
  3. {telert-0.2.6 → telert-0.2.7}/pyproject.toml +23 -33
  4. {telert-0.2.6 → telert-0.2.7}/telert/__init__.py +1 -1
  5. {telert-0.2.6 → telert-0.2.7}/telert/cli.py +114 -40
  6. {telert-0.2.6 → telert-0.2.7/telert.egg-info}/PKG-INFO +11 -4
  7. {telert-0.2.6 → telert-0.2.7}/LICENSE +0 -0
  8. {telert-0.2.6 → telert-0.2.7}/MANIFEST.in +0 -0
  9. {telert-0.2.6 → telert-0.2.7}/setup.cfg +0 -0
  10. {telert-0.2.6 → telert-0.2.7}/telert/api.py +0 -0
  11. {telert-0.2.6 → telert-0.2.7}/telert/data/notification-icon.png +0 -0
  12. {telert-0.2.6 → telert-0.2.7}/telert/data/notification.mp3 +0 -0
  13. {telert-0.2.6 → telert-0.2.7}/telert/messaging.py +0 -0
  14. {telert-0.2.6 → telert-0.2.7}/telert/monitoring/__init__.py +0 -0
  15. {telert-0.2.6 → telert-0.2.7}/telert/monitoring/activity_logs.py +0 -0
  16. {telert-0.2.6 → telert-0.2.7}/telert/monitoring/base.py +0 -0
  17. {telert-0.2.6 → telert-0.2.7}/telert/monitoring/cli.py +0 -0
  18. {telert-0.2.6 → telert-0.2.7}/telert/monitoring/cli_logs.py +0 -0
  19. {telert-0.2.6 → telert-0.2.7}/telert/monitoring/debug_logs.py +0 -0
  20. {telert-0.2.6 → telert-0.2.7}/telert/monitoring/log.py +0 -0
  21. {telert-0.2.6 → telert-0.2.7}/telert/monitoring/network.py +0 -0
  22. {telert-0.2.6 → telert-0.2.7}/telert/monitoring/process.py +0 -0
  23. {telert-0.2.6 → telert-0.2.7}/telert.egg-info/SOURCES.txt +0 -0
  24. {telert-0.2.6 → telert-0.2.7}/telert.egg-info/dependency_links.txt +0 -0
  25. {telert-0.2.6 → telert-0.2.7}/telert.egg-info/entry_points.txt +0 -0
  26. {telert-0.2.6 → telert-0.2.7}/telert.egg-info/requires.txt +0 -0
  27. {telert-0.2.6 → telert-0.2.7}/telert.egg-info/top_level.txt +0 -0
  28. {telert-0.2.6 → telert-0.2.7}/telert.png +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: telert
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: Ultimate command monitoring & notification system: Telegram, Slack, Discord, Teams, Pushover, Email, desktop & more. Monitor Python code and CLI tasks with context managers, decorators, and webhooks.
5
5
  Author-email: Mihir Khandekar <mihirkhandekar@gmail.com>
6
6
  License-Expression: MIT
@@ -54,7 +54,7 @@ Dynamic: license-file
54
54
  <img src="https://github.com/navig-me/telert/raw/main/telert.png" alt="telert logo" width="150">
55
55
  </p>
56
56
 
57
- **Version 0.2.6**
57
+ **Version 0.2.7**
58
58
 
59
59
  [![PyPI Downloads](https://static.pepy.tech/badge/telert)](https://pepy.tech/projects/telert)
60
60
  [![GitHub Stars](https://img.shields.io/github/stars/navig-me/telert?style=social)](https://github.com/navig-me/telert/stargazers)
@@ -579,11 +579,18 @@ fi
579
579
  Get notifications for ALL commands that take longer than a certain time:
580
580
 
581
581
  ```bash
582
- # Configure Bash to notify for any command taking longer than 30 seconds
582
+ # Configure hook to notify for any command taking longer than 30 seconds
583
583
  eval "$(telert hook -l 30)"
584
+ ```
585
+
586
+ **For persistent configuration:**
584
587
 
585
- # Add to your .bashrc for persistent configuration
588
+ ```bash
589
+ # Add to your .bashrc (Bash users)
586
590
  echo 'eval "$(telert hook -l 30)"' >> ~/.bashrc
591
+
592
+ # Add to your .zshrc (Zsh users)
593
+ echo 'eval "$(telert hook -l 30)"' >> ~/.zshrc
587
594
  ```
588
595
 
589
596
  #### CLI Help
@@ -6,7 +6,7 @@
6
6
  <img src="https://github.com/navig-me/telert/raw/main/telert.png" alt="telert logo" width="150">
7
7
  </p>
8
8
 
9
- **Version 0.2.6**
9
+ **Version 0.2.7**
10
10
 
11
11
  [![PyPI Downloads](https://static.pepy.tech/badge/telert)](https://pepy.tech/projects/telert)
12
12
  [![GitHub Stars](https://img.shields.io/github/stars/navig-me/telert?style=social)](https://github.com/navig-me/telert/stargazers)
@@ -531,11 +531,18 @@ fi
531
531
  Get notifications for ALL commands that take longer than a certain time:
532
532
 
533
533
  ```bash
534
- # Configure Bash to notify for any command taking longer than 30 seconds
534
+ # Configure hook to notify for any command taking longer than 30 seconds
535
535
  eval "$(telert hook -l 30)"
536
+ ```
537
+
538
+ **For persistent configuration:**
536
539
 
537
- # Add to your .bashrc for persistent configuration
540
+ ```bash
541
+ # Add to your .bashrc (Bash users)
538
542
  echo 'eval "$(telert hook -l 30)"' >> ~/.bashrc
543
+
544
+ # Add to your .zshrc (Zsh users)
545
+ echo 'eval "$(telert hook -l 30)"' >> ~/.zshrc
539
546
  ```
540
547
 
541
548
  #### CLI Help
@@ -1,8 +1,8 @@
1
1
  [project]
2
2
  name = "telert"
3
- version = "0.2.6"
3
+ version = "0.2.7"
4
4
  description = "Ultimate command monitoring & notification system: Telegram, Slack, Discord, Teams, Pushover, Email, desktop & more. Monitor Python code and CLI tasks with context managers, decorators, and webhooks."
5
- authors = [{name = "Mihir Khandekar", email = "mihirkhandekar@gmail.com"}]
5
+ authors = [{ name = "Mihir Khandekar", email = "mihirkhandekar@gmail.com" }]
6
6
  license = "MIT"
7
7
  readme = "README.md"
8
8
  requires-python = ">=3.8"
@@ -10,26 +10,26 @@ dependencies = [
10
10
  "requests>=2.25",
11
11
  "beautifulsoup4>=4.9.0",
12
12
  "psutil>=5.9.0",
13
- "ping3>=4.0.0"
13
+ "ping3>=4.0.0",
14
14
  ]
15
15
  keywords = [
16
- "telegram",
17
- "notification",
18
- "cli",
19
- "terminal",
20
- "email",
21
- "alert",
22
- "pushover",
23
- "slack",
24
- "discord",
25
- "microsoft-teams",
26
- "desktop-notifications",
27
- "monitoring",
28
- "python-decorators",
16
+ "telegram",
17
+ "notification",
18
+ "cli",
19
+ "terminal",
20
+ "email",
21
+ "alert",
22
+ "pushover",
23
+ "slack",
24
+ "discord",
25
+ "microsoft-teams",
26
+ "desktop-notifications",
27
+ "monitoring",
28
+ "python-decorators",
29
29
  "context-managers",
30
30
  "process-monitoring",
31
31
  "log-file-monitoring",
32
- "network-monitoring"
32
+ "network-monitoring",
33
33
  ]
34
34
  classifiers = [
35
35
  "Development Status :: 4 - Beta",
@@ -47,7 +47,7 @@ classifiers = [
47
47
  "Topic :: Communications",
48
48
  "Topic :: Software Development",
49
49
  "Topic :: System :: Monitoring",
50
- "Topic :: Utilities"
50
+ "Topic :: Utilities",
51
51
  ]
52
52
 
53
53
  [project.urls]
@@ -61,25 +61,15 @@ classifiers = [
61
61
  telert = "telert.cli:main"
62
62
 
63
63
  [project.optional-dependencies]
64
- dev = [
65
- "build",
66
- "twine",
67
- "pytest"
68
- ]
69
- audio = [
70
- "playsound"
71
- ]
64
+ dev = ["build", "twine", "pytest"]
65
+ audio = ["playsound"]
72
66
  desktop = []
73
- all = [
74
- "playsound",
75
- "psutil",
76
- "ping3"
77
- ]
67
+ all = ["playsound", "psutil", "ping3"]
78
68
 
79
69
  [tool.setuptools]
80
70
  packages = ["telert", "telert.data", "telert.monitoring"]
81
71
  py-modules = []
82
- package-dir = {"" = "."}
72
+ package-dir = { "" = "." }
83
73
  include-package-data = true
84
74
 
85
75
  [tool.setuptools.package-data]
@@ -90,4 +80,4 @@ telert = ["data/*.wav", "data/*.mp3", "data/*.png", "data/*.svg"]
90
80
 
91
81
  [build-system]
92
82
  requires = ["setuptools>=61", "wheel"]
93
- build-backend = "setuptools.build_meta"
83
+ build-backend = "setuptools.build_meta"
@@ -20,7 +20,7 @@ __all__ = [
20
20
  "set_default_providers",
21
21
  "list_providers",
22
22
  ]
23
- __version__ = "0.2.6"
23
+ __version__ = "0.2.7"
24
24
 
25
25
  from telert.api import (
26
26
  configure,
@@ -538,7 +538,9 @@ def do_status(a):
538
538
  or discord_config
539
539
  or email_config
540
540
  ):
541
- print("No providers configured. Use `telert config` or `telert init` to set up a provider.")
541
+ print(
542
+ "No providers configured. Use `telert config` or `telert init` to set up a provider."
543
+ )
542
544
  return
543
545
 
544
546
  # Show environment variable information
@@ -622,16 +624,82 @@ def do_status(a):
622
624
 
623
625
  def do_hook(a):
624
626
  """Generate a shell hook for command notifications."""
625
- t = a.longer_than
626
- print(
627
- textwrap.dedent(f"""
628
- telert_preexec() {{ TELERT_CMD=\"$BASH_COMMAND\"; TELERT_START=$EPOCHSECONDS; }}
629
- telert_precmd() {{ local st=$?; local d=$((EPOCHSECONDS-TELERT_START));
630
- if (( d >= {t} )); then telert send \"$TELERT_CMD exited $st in $(printf '%dm%02ds' $((d/60)) $((d%60)))\"; fi; }}
631
- trap telert_preexec DEBUG
632
- PROMPT_COMMAND=telert_precmd:$PROMPT_COMMAND
633
- """).strip()
634
- )
627
+ shell = a.shell or os.path.basename(os.environ.get("SHELL", "bash"))
628
+ threshold = a.longer_than
629
+
630
+ if "zsh" in shell:
631
+ hook_script = textwrap.dedent(f"""
632
+ # Load zsh hooks module if not already loaded
633
+ if [[ -z "$__TELERT_HOOKS_LOADED" ]]; then
634
+ autoload -U add-zsh-hook 2>/dev/null || {{
635
+ echo "Warning: add-zsh-hook not available, using fallback implementation... Please ensure zsh is properly installed and configured."
636
+ # Fallback for systems without zsh-hooks
637
+ _telert_preexec() {{
638
+ __TELERT_CMD__="$1"
639
+ __TELERT_START__=$EPOCHSECONDS
640
+ }}
641
+
642
+ _telert_precmd() {{
643
+ if [[ -n "$__TELERT_START__" ]]; then
644
+ local st=$?
645
+ local end=$EPOCHSECONDS
646
+ local duration=$((end - __TELERT_START__))
647
+ if (( duration >= {threshold} )); then
648
+ telert send "$__TELERT_CMD__ exited with $st in $(printf '%dm%02ds' $((duration/60)) $((duration%60)))"
649
+ fi
650
+ unset __TELERT_START__
651
+ fi
652
+ }}
653
+
654
+ # Set up hooks manually
655
+ preexec_functions=(_telert_preexec ${{preexec_functions[@]}})
656
+ precmd_functions=(_telert_precmd ${{precmd_functions[@]}})
657
+ export __TELERT_HOOKS_LOADED=1
658
+ return
659
+ }}
660
+ fi
661
+
662
+ # Standard hook setup
663
+ autoload -U zsh/datetime
664
+
665
+ _telert_preexec() {{
666
+ # Try multiple methods to get the command
667
+ if [[ -n "$1" ]]; then
668
+ typeset -g __TELERT_CMD__="$1"
669
+ elif [[ -n "$HISTCMD" ]] && [[ -n "${{history[$HISTCMD]}}" ]]; then
670
+ typeset -g __TELERT_CMD__="${{history[$HISTCMD]}}"
671
+ else
672
+ # Last resort: try to get from history builtin
673
+ typeset -g __TELERT_CMD__="$(history -1 2>/dev/null | head -1 | sed 's/^[[:space:]]*[0-9]*[[:space:]]*//')"
674
+ fi
675
+ typeset -g __TELERT_START__=$EPOCHSECONDS
676
+ }}
677
+
678
+ _telert_precmd() {{
679
+ if [[ -n "$__TELERT_START__" ]]; then
680
+ local st=$?
681
+ local end=$EPOCHSECONDS
682
+ local duration=$((end - __TELERT_START__))
683
+ if (( duration >= {threshold} )); then
684
+ telert send "$__TELERT_CMD__ exited with $st in $(printf '%dm%02ds' $((duration/60)) $((duration%60)))"
685
+ fi
686
+ unset __TELERT_START__
687
+ unset __TELERT_CMD__
688
+ fi
689
+ }}
690
+
691
+ add-zsh-hook preexec _telert_preexec
692
+ add-zsh-hook precmd _telert_precmd
693
+ """).strip()
694
+ else: # Default to bash
695
+ hook_script = textwrap.dedent(f"""
696
+ telert_preexec() {{{{ export __TELERT_CMD__="$BASH_COMMAND"; export TELERT_START=$EPOCHSECONDS; }}}}
697
+ telert_precmd() {{{{ local st=$?; if [[ -n "$TELERT_START" ]]; then local d=$((EPOCHSECONDS-TELERT_START)); if (( d >= {threshold} )); then telert send "$__TELERT_CMD__ exited with $st in $(printf '%dm%02ds' $((d/60)) $((d%60)))"; fi; unset TELERT_START; fi; }}}}
698
+ trap 'telert_preexec' DEBUG
699
+ PROMPT_COMMAND="telert_precmd${{{{PROMPT_COMMAND:+;}}}}$PROMPT_COMMAND"
700
+ """).strip()
701
+
702
+ print(hook_script)
635
703
 
636
704
 
637
705
  def do_send(a):
@@ -1276,7 +1344,9 @@ def do_init(a):
1276
1344
  print("❌ SMTP server is required. Skipping email setup.")
1277
1345
  continue
1278
1346
 
1279
- port_str = input("SMTP server port (optional, default: 587 for TLS): ").strip()
1347
+ port_str = input(
1348
+ "SMTP server port (optional, default: 587 for TLS): "
1349
+ ).strip()
1280
1350
  if port_str:
1281
1351
  try:
1282
1352
  port = int(port_str)
@@ -1290,7 +1360,9 @@ def do_init(a):
1290
1360
  password = input("SMTP password (optional): ").strip()
1291
1361
 
1292
1362
  from_addr = input("Sender email address (optional): ").strip()
1293
- to_addrs = input("Recipient email address(es) - comma separated for multiple: ").strip()
1363
+ to_addrs = input(
1364
+ "Recipient email address(es) - comma separated for multiple: "
1365
+ ).strip()
1294
1366
 
1295
1367
  if not to_addrs:
1296
1368
  print("❌ At least one recipient email address is required")
@@ -1298,11 +1370,15 @@ def do_init(a):
1298
1370
 
1299
1371
  to_list = [addr.strip() for addr in to_addrs.split(",")]
1300
1372
 
1301
- subject_template = input("Subject template (optional, default: 'Telert Alert: {label} - {status}'): ").strip()
1373
+ subject_template = input(
1374
+ "Subject template (optional, default: 'Telert Alert: {label} - {status}'): "
1375
+ ).strip()
1302
1376
  if not subject_template:
1303
1377
  subject_template = "Telert Alert: {label} - {status}"
1304
1378
 
1305
- use_html_str = input("Send HTML formatted emails? (y/n, default: n): ").strip().lower()
1379
+ use_html_str = (
1380
+ input("Send HTML formatted emails? (y/n, default: n): ").strip().lower()
1381
+ )
1306
1382
  use_html = use_html_str in ("y", "yes", "true", "1")
1307
1383
 
1308
1384
  config_params = {
@@ -1439,22 +1515,18 @@ def main():
1439
1515
  description="Send alerts from shell commands to messaging services",
1440
1516
  epilog="Example: telert run ls -la",
1441
1517
  )
1442
- p.add_argument(
1443
- "--version", action="version", version=f"telert {__version__}"
1444
- )
1518
+ p.add_argument("--version", action="version", version=f"telert {__version__}")
1445
1519
 
1446
1520
  sp = p.add_subparsers(dest="command", metavar="COMMAND")
1447
-
1521
+
1448
1522
  # Add monitoring commands
1449
1523
  setup_monitor_cli(sp)
1450
1524
 
1451
1525
  # config
1452
1526
  c = sp.add_parser("config", help="configure messaging providers")
1453
- config_sp = c.add_subparsers(
1454
- dest="provider", help="provider type to configure"
1455
- )
1456
-
1457
- # Set defaults command
1527
+ config_sp = c.add_subparsers(dest="provider", help="provider type to configure")
1528
+
1529
+ # Set defaults command
1458
1530
  set_defaults_parser = config_sp.add_parser(
1459
1531
  "set-defaults", help="set multiple default providers in priority order"
1460
1532
  )
@@ -1634,36 +1706,33 @@ def main():
1634
1706
  action="store_true",
1635
1707
  help="add to existing default providers",
1636
1708
  )
1637
-
1709
+
1638
1710
  # Email configuration subparser
1639
1711
  email_parser = config_sp.add_parser(
1640
1712
  "email", help="configure email (SMTP) messaging"
1641
1713
  )
1642
- email_parser.add_argument(
1643
- "--server", required=True, help="SMTP server address"
1644
- )
1714
+ email_parser.add_argument("--server", required=True, help="SMTP server address")
1645
1715
  email_parser.add_argument(
1646
1716
  "--port", type=int, default=587, help="SMTP server port (default: 587 for TLS)"
1647
1717
  )
1718
+ email_parser.add_argument("--username", help="SMTP username for authentication")
1719
+ email_parser.add_argument("--password", help="SMTP password for authentication")
1720
+ email_parser.add_argument("--from", dest="from_addr", help="sender email address")
1648
1721
  email_parser.add_argument(
1649
- "--username", help="SMTP username for authentication"
1650
- )
1651
- email_parser.add_argument(
1652
- "--password", help="SMTP password for authentication"
1653
- )
1654
- email_parser.add_argument(
1655
- "--from", dest="from_addr", help="sender email address"
1656
- )
1657
- email_parser.add_argument(
1658
- "--to", dest="to_addrs", help="recipient email address(es) - comma separated for multiple"
1722
+ "--to",
1723
+ dest="to_addrs",
1724
+ help="recipient email address(es) - comma separated for multiple",
1659
1725
  )
1660
1726
  email_parser.add_argument(
1661
1727
  "--subject-template",
1662
1728
  default="Telert Alert: {label} - {status}",
1663
- help="template for email subject line (default: 'Telert Alert: {label} - {status}')"
1729
+ help="template for email subject line (default: 'Telert Alert: {label} - {status}')",
1664
1730
  )
1665
1731
  email_parser.add_argument(
1666
- "--html", dest="use_html", action="store_true", help="send HTML formatted emails"
1732
+ "--html",
1733
+ dest="use_html",
1734
+ action="store_true",
1735
+ help="send HTML formatted emails",
1667
1736
  )
1668
1737
  email_parser.add_argument(
1669
1738
  "--set-default", action="store_true", help="set as the only default provider"
@@ -1693,6 +1762,11 @@ def main():
1693
1762
  default=10,
1694
1763
  help="minimum duration in seconds to trigger notification",
1695
1764
  )
1765
+ hk.add_argument(
1766
+ "--shell",
1767
+ choices=["bash", "zsh"],
1768
+ help="specify the shell type (default: auto-detect from $SHELL)",
1769
+ )
1696
1770
  hk.set_defaults(func=do_hook)
1697
1771
 
1698
1772
  # send
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: telert
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: Ultimate command monitoring & notification system: Telegram, Slack, Discord, Teams, Pushover, Email, desktop & more. Monitor Python code and CLI tasks with context managers, decorators, and webhooks.
5
5
  Author-email: Mihir Khandekar <mihirkhandekar@gmail.com>
6
6
  License-Expression: MIT
@@ -54,7 +54,7 @@ Dynamic: license-file
54
54
  <img src="https://github.com/navig-me/telert/raw/main/telert.png" alt="telert logo" width="150">
55
55
  </p>
56
56
 
57
- **Version 0.2.6**
57
+ **Version 0.2.7**
58
58
 
59
59
  [![PyPI Downloads](https://static.pepy.tech/badge/telert)](https://pepy.tech/projects/telert)
60
60
  [![GitHub Stars](https://img.shields.io/github/stars/navig-me/telert?style=social)](https://github.com/navig-me/telert/stargazers)
@@ -579,11 +579,18 @@ fi
579
579
  Get notifications for ALL commands that take longer than a certain time:
580
580
 
581
581
  ```bash
582
- # Configure Bash to notify for any command taking longer than 30 seconds
582
+ # Configure hook to notify for any command taking longer than 30 seconds
583
583
  eval "$(telert hook -l 30)"
584
+ ```
585
+
586
+ **For persistent configuration:**
584
587
 
585
- # Add to your .bashrc for persistent configuration
588
+ ```bash
589
+ # Add to your .bashrc (Bash users)
586
590
  echo 'eval "$(telert hook -l 30)"' >> ~/.bashrc
591
+
592
+ # Add to your .zshrc (Zsh users)
593
+ echo 'eval "$(telert hook -l 30)"' >> ~/.zshrc
587
594
  ```
588
595
 
589
596
  #### CLI Help
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes