supercomputer-console 1.3.0__tar.gz → 1.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: supercomputer-console
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: A retro mainframe operator console for your terminal: blinkenlights driven by real system load.
5
5
  Author: Roger Dubar
6
6
  License-Expression: MIT
@@ -110,10 +110,16 @@ uv tool install supercomputer-console
110
110
  pipx install supercomputer-console
111
111
  ```
112
112
 
113
+ On a Mac (or Linux) with Homebrew, without setting up Python yourself:
114
+
115
+ ```sh
116
+ brew install rdubar/tap/supercomputer
117
+ ```
118
+
113
119
  For the wallpaper generator, include the extra:
114
120
  `uv tool install "supercomputer-console[wallpaper]"`.
115
121
 
116
- Plans for Homebrew, single-binary builds and an iOS pocket console are in
122
+ Plans for single-binary builds and an iOS pocket console are in
117
123
  the [roadmap](https://github.com/rdubar/supercomputer/blob/main/ROADMAP.md). Changes are listed in the [changelog](https://github.com/rdubar/supercomputer/blob/main/CHANGELOG.md).
118
124
 
119
125
  ## Use
@@ -155,7 +161,8 @@ supercomputer-wallpaper out.png --size 2560x1440
155
161
  | Disks | 95% full | 98% full |
156
162
  | Services | a subsystem lamp's service stops | |
157
163
 
158
- `--bell` makes the console ring the terminal bell on a new alarm.
164
+ `--bell` makes the console ring the terminal bell on a new alarm, or when
165
+ a warning becomes critical.
159
166
 
160
167
  ### Seeing it in action
161
168
 
@@ -177,8 +184,8 @@ Reading a large file (`cat bigfile > /dev/null`) lights the storage lamps.
177
184
 
178
185
  `supercomputer --check` takes about a second, mostly spent waiting, so it is
179
186
  cheap to run on a timer. Add `--notify` for a desktop notification
180
- (`osascript` on macOS, `notify-send` on Linux). It notifies only when the set
181
- of alarms changes, not on every run, and remembers the last state in
187
+ (`osascript` on macOS, `notify-send` on Linux). It notifies when an alarm is
188
+ raised, escalates from warning to critical, or all clear, not on every run, and remembers the last state in
182
189
  `~/.cache/supercomputer/alarms`. Add `--quiet` to print nothing while all is
183
190
  well (with `--notify`, also while nothing has changed). For example, a crontab line:
184
191
 
@@ -85,10 +85,16 @@ uv tool install supercomputer-console
85
85
  pipx install supercomputer-console
86
86
  ```
87
87
 
88
+ On a Mac (or Linux) with Homebrew, without setting up Python yourself:
89
+
90
+ ```sh
91
+ brew install rdubar/tap/supercomputer
92
+ ```
93
+
88
94
  For the wallpaper generator, include the extra:
89
95
  `uv tool install "supercomputer-console[wallpaper]"`.
90
96
 
91
- Plans for Homebrew, single-binary builds and an iOS pocket console are in
97
+ Plans for single-binary builds and an iOS pocket console are in
92
98
  the [roadmap](https://github.com/rdubar/supercomputer/blob/main/ROADMAP.md). Changes are listed in the [changelog](https://github.com/rdubar/supercomputer/blob/main/CHANGELOG.md).
93
99
 
94
100
  ## Use
@@ -130,7 +136,8 @@ supercomputer-wallpaper out.png --size 2560x1440
130
136
  | Disks | 95% full | 98% full |
131
137
  | Services | a subsystem lamp's service stops | |
132
138
 
133
- `--bell` makes the console ring the terminal bell on a new alarm.
139
+ `--bell` makes the console ring the terminal bell on a new alarm, or when
140
+ a warning becomes critical.
134
141
 
135
142
  ### Seeing it in action
136
143
 
@@ -152,8 +159,8 @@ Reading a large file (`cat bigfile > /dev/null`) lights the storage lamps.
152
159
 
153
160
  `supercomputer --check` takes about a second, mostly spent waiting, so it is
154
161
  cheap to run on a timer. Add `--notify` for a desktop notification
155
- (`osascript` on macOS, `notify-send` on Linux). It notifies only when the set
156
- of alarms changes, not on every run, and remembers the last state in
162
+ (`osascript` on macOS, `notify-send` on Linux). It notifies when an alarm is
163
+ raised, escalates from warning to critical, or all clear, not on every run, and remembers the last state in
157
164
  `~/.cache/supercomputer/alarms`. Add `--quiet` to print nothing while all is
158
165
  well (with `--notify`, also while nothing has changed). For example, a crontab line:
159
166
 
@@ -27,7 +27,7 @@ import urllib.error
27
27
  import urllib.request
28
28
  import uuid
29
29
 
30
- __version__ = "1.3.0"
30
+ __version__ = "1.3.2"
31
31
  REPO_URL = "github.com/rdubar/supercomputer"
32
32
  PYPI_NAME = "supercomputer-console"
33
33
  PYPI_URL = f"https://pypi.org/pypi/{PYPI_NAME}/json"
@@ -399,6 +399,13 @@ def make_probe():
399
399
  WARN, CRIT = 1, 2
400
400
 
401
401
 
402
+ def raised(alarms, before):
403
+ """Alarms that are new or worse than in `before` ({key: level}), as
404
+ [(level, key, text, escalated)]. warning -> critical counts as raised."""
405
+ return [(lvl, key, text, key in before) for lvl, key, text in alarms
406
+ if lvl > before.get(key, 0)]
407
+
408
+
402
409
  def assess(probe, swap_rate=None, cpu_pinned=False):
403
410
  """Current alarms as [(level, key, text)]. Cheap: a few reads, no sleeping.
404
411
 
@@ -695,14 +702,17 @@ class Panel:
695
702
  # ------------------------------------------------------------ events
696
703
  def alarm_events(self):
697
704
  current = {key: (lvl, text) for lvl, key, text in self.s.alarms}
698
- for key, (lvl, text) in current.items():
699
- if key not in self.known_alarms:
700
- self.say(f"*** {'CRITICAL' if lvl == CRIT else 'ALARM'}: {text} ***")
701
- if self.bell:
702
- curses.beep()
703
- for key, (_, text) in self.known_alarms.items():
705
+ before = {key: lvl for key, (lvl, _) in self.known_alarms.items()}
706
+ for lvl, key, text, escalated in raised(self.s.alarms, before):
707
+ tag = "ESCALATED TO CRITICAL" if escalated else ("CRITICAL" if lvl == CRIT else "ALARM")
708
+ self.say(f"*** {tag}: {text} ***")
709
+ if self.bell:
710
+ curses.beep()
711
+ for key, (lvl, text) in self.known_alarms.items():
704
712
  if key not in current:
705
713
  self.say(f"ALARM CLEARED: {text}")
714
+ elif current[key][0] < lvl:
715
+ self.say(f"ALARM EASED: {current[key][1]}")
706
716
  self.known_alarms = current
707
717
 
708
718
  def events(self):
@@ -990,9 +1000,14 @@ def check(probe, do_notify=False, quiet=False):
990
1000
  busy = [1 - (cpu1[k][1] - cpu0[k][1]) / max(cpu1[k][0] - cpu0[k][0], 1) for k in cpu1 if k in cpu0]
991
1001
  alarms = assess(probe, swap_rate, bool(busy) and min(busy) > 0.98)
992
1002
  host = identity(probe)[0]
993
- keys = sorted(k for _, k, _ in alarms)
994
- before = read(STATE_FILE).split()
995
- changed = keys != before
1003
+ # State file: "key:level" per alarm. A bare "key" (written before 1.3.2)
1004
+ # counts as a warning, so upgrading doesn't re-announce it.
1005
+ now = {k: lvl for lvl, k, _ in alarms}
1006
+ before = {}
1007
+ for entry in read(STATE_FILE).split():
1008
+ m = re.fullmatch(r"(.+):([12])", entry)
1009
+ before[m[1] if m else entry] = int(m[2]) if m else WARN
1010
+ changed = now != before
996
1011
  # --quiet: silent when nominal; with --notify, also silent while unchanged
997
1012
  if not quiet or (alarms and not do_notify) or (do_notify and changed):
998
1013
  A, R = ("\033[1;33m", "\033[0m") if sys.stdout.isatty() else ("", "")
@@ -1003,7 +1018,7 @@ def check(probe, do_notify=False, quiet=False):
1003
1018
  print("\n".join(lines))
1004
1019
  if do_notify:
1005
1020
  if changed:
1006
- new = [t for _, k, t in alarms if k not in before]
1021
+ new = [("ESCALATED: " if esc else "") + t for _, _, t, esc in raised(alarms, before)]
1007
1022
  if new:
1008
1023
  notify(f"{host} SUPERCOMPUTER ALARM", "; ".join(new))
1009
1024
  elif not alarms:
@@ -1011,7 +1026,7 @@ def check(probe, do_notify=False, quiet=False):
1011
1026
  try:
1012
1027
  os.makedirs(os.path.dirname(STATE_FILE), exist_ok=True)
1013
1028
  with open(STATE_FILE, "w") as f:
1014
- f.write(" ".join(keys) + "\n")
1029
+ f.write(" ".join(f"{k}:{lvl}" for k, lvl in sorted(now.items())) + "\n")
1015
1030
  except OSError:
1016
1031
  pass
1017
1032
  return max((lvl for lvl, _, _ in alarms), default=0)
@@ -1076,6 +1091,8 @@ def install_method():
1076
1091
  if os.path.isdir(os.path.join(here, ".git")):
1077
1092
  return "git checkout", ["git", "-C", here, "pull", "--ff-only"]
1078
1093
  prefix = sys.prefix.replace("\\", "/")
1094
+ if "/Cellar/supercomputer/" in os.path.realpath(__file__) and shutil.which("brew"):
1095
+ return "Homebrew", ["brew", "upgrade", "rdubar/tap/supercomputer"]
1079
1096
  if "/uv/tools/" in prefix and shutil.which("uv"):
1080
1097
  return "uv tool", ["uv", "tool", "upgrade", PYPI_NAME]
1081
1098
  if "/pipx/venvs/" in prefix and shutil.which("pipx"):
@@ -1131,7 +1148,7 @@ def main():
1131
1148
  ap.add_argument("--version", action="store_true",
1132
1149
  help="show the version and check quickly for a newer release")
1133
1150
  ap.add_argument("--update", action="store_true",
1134
- help="upgrade to the latest release (uv, pipx, venv or git checkout)")
1151
+ help="upgrade to the latest release (uv, pipx, Homebrew, venv or git checkout)")
1135
1152
  args = ap.parse_args()
1136
1153
  if args.version:
1137
1154
  show_version()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: supercomputer-console
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: A retro mainframe operator console for your terminal: blinkenlights driven by real system load.
5
5
  Author: Roger Dubar
6
6
  License-Expression: MIT
@@ -110,10 +110,16 @@ uv tool install supercomputer-console
110
110
  pipx install supercomputer-console
111
111
  ```
112
112
 
113
+ On a Mac (or Linux) with Homebrew, without setting up Python yourself:
114
+
115
+ ```sh
116
+ brew install rdubar/tap/supercomputer
117
+ ```
118
+
113
119
  For the wallpaper generator, include the extra:
114
120
  `uv tool install "supercomputer-console[wallpaper]"`.
115
121
 
116
- Plans for Homebrew, single-binary builds and an iOS pocket console are in
122
+ Plans for single-binary builds and an iOS pocket console are in
117
123
  the [roadmap](https://github.com/rdubar/supercomputer/blob/main/ROADMAP.md). Changes are listed in the [changelog](https://github.com/rdubar/supercomputer/blob/main/CHANGELOG.md).
118
124
 
119
125
  ## Use
@@ -155,7 +161,8 @@ supercomputer-wallpaper out.png --size 2560x1440
155
161
  | Disks | 95% full | 98% full |
156
162
  | Services | a subsystem lamp's service stops | |
157
163
 
158
- `--bell` makes the console ring the terminal bell on a new alarm.
164
+ `--bell` makes the console ring the terminal bell on a new alarm, or when
165
+ a warning becomes critical.
159
166
 
160
167
  ### Seeing it in action
161
168
 
@@ -177,8 +184,8 @@ Reading a large file (`cat bigfile > /dev/null`) lights the storage lamps.
177
184
 
178
185
  `supercomputer --check` takes about a second, mostly spent waiting, so it is
179
186
  cheap to run on a timer. Add `--notify` for a desktop notification
180
- (`osascript` on macOS, `notify-send` on Linux). It notifies only when the set
181
- of alarms changes, not on every run, and remembers the last state in
187
+ (`osascript` on macOS, `notify-send` on Linux). It notifies when an alarm is
188
+ raised, escalates from warning to critical, or all clear, not on every run, and remembers the last state in
182
189
  `~/.cache/supercomputer/alarms`. Add `--quiet` to print nothing while all is
183
190
  well (with `--notify`, also while nothing has changed). For example, a crontab line:
184
191