Support Windows 7 with Python 3.8
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
# Network spike monitor
|
||||
|
||||
Windows 10/11, Python 3.10 or newer. No packages or administrator rights required.
|
||||
Windows 7 SP1 or newer, Python 3.8 or newer (use Python 3.8 on Windows 7). No packages or administrator rights required to run the monitor.
|
||||
|
||||
### Windows 7 setup
|
||||
|
||||
Install [Python 3.8.10](https://www.python.org/downloads/release/python-3810/) using its **Windows installer (32-bit)** or **Windows installer (64-bit)** to match your system. Select **Add Python 3.8 to PATH** during installation, then open a new command prompt. Use the traditional installer listed under Files, not the newer Python install manager. Python 3.8 is the last branch compatible with Windows 7; 3.8.10 is its last release with official Windows installers. Windows 7 must have Service Pack 1 and the updates needed by the Python installer.
|
||||
|
||||
Check `python --version` reports Python 3.8.x on Windows 7. On newer Windows, a newer supported Python release is fine. The monitor's ping and tracert options, trace cancellation, and logging use Python 3.8-compatible APIs. Python 3.8 is no longer maintained. Compatibility tests run on Python 3.8 on a newer Windows system; a physical Windows 7 installation has not been tested.
|
||||
|
||||
### Start monitoring
|
||||
|
||||
Double-click **Start Monitor.cmd**, or run:
|
||||
|
||||
|
||||
+6
-2
@@ -1,4 +1,4 @@
|
||||
"""Windows ping spike monitor. Python 3.10+, standard library only."""
|
||||
"""Windows ping spike monitor. Python 3.8+, standard library only."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
@@ -376,7 +376,11 @@ def main():
|
||||
log.write("error", f"Error: {error}", error=str(error))
|
||||
finally:
|
||||
stop.set()
|
||||
executor.shutdown(wait=True, cancel_futures=True)
|
||||
# Python 3.8 has no shutdown(cancel_futures=...). There is at most
|
||||
# one submitted trace; cancel it if queued, or let stop end it if running.
|
||||
if pending is not None:
|
||||
pending.cancel()
|
||||
executor.shutdown(wait=True)
|
||||
log.write("stop", "Monitor stopped.", samples=samples)
|
||||
log.file.close()
|
||||
return 1 if failed else 0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import pathlib
|
||||
import json
|
||||
import sys
|
||||
import subprocess
|
||||
import tempfile
|
||||
import threading
|
||||
import unittest
|
||||
@@ -11,6 +12,24 @@ from network_monitor import Detector, analyze_trace, parse_ping, parse_trace, ru
|
||||
|
||||
|
||||
class MonitorTests(unittest.TestCase):
|
||||
@unittest.skipUnless(sys.platform == "win32", "requires Windows ping and tracert")
|
||||
def test_main_finishes_diagnostic_and_closes_log(self):
|
||||
# Exercise real executor shutdown on the interpreter running the suite,
|
||||
# including Python 3.8, where cancel_futures is unavailable.
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(pathlib.Path(__file__).with_name("network_monitor.py")),
|
||||
"--target", "127.0.0.1", "--count", "1", "--trace-now",
|
||||
"--log-dir", directory],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=20)
|
||||
self.assertEqual(result.returncode, 0, result.stdout.decode(errors="replace"))
|
||||
entries = [json.loads(line) for line in
|
||||
(pathlib.Path(directory) / "events.jsonl").read_text().splitlines()]
|
||||
self.assertEqual(entries[-1]["event"], "stop")
|
||||
self.assertEqual(entries[-1]["samples"], 1)
|
||||
self.assertTrue(any(entry["event"] == "trace_complete" for entry in entries))
|
||||
self.assertFalse(any(entry["event"] == "error" for entry in entries))
|
||||
|
||||
def test_only_bad_pings_are_logged(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
log = Log(pathlib.Path(directory))
|
||||
|
||||
Reference in New Issue
Block a user