mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 07:18:50 +00:00
P1: the rename of a stale strata.ps1 also leaves a line in launcher-heal.log beside it, for support (an update's own test start swallows the screen line)
This commit is contained in:
1 parent
1151d3f8fe
commit
55f7b69cbd
2 files changed
+11
No files matched your search
@@ -14,9 +14,11 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
HEADER = "# Strata Terminal launcher for PowerShell"
|
||||
RENAMED_TO = "strata-direct.ps1"
|
||||
LOG_NAME = "launcher-heal.log" # beside the renamed file: one line per rename
|
||||
|
||||
|
||||
def installed_bin():
|
||||
@@ -64,6 +66,12 @@ def heal(path_value: str | None = None, extra: list | None = None, say=None, win
|
||||
except OSError:
|
||||
continue
|
||||
renamed.append(ps1)
|
||||
try: # for support: when a update's own test start ran this, nobody saw the line below
|
||||
with open(os.path.join(os.path.dirname(ps1), LOG_NAME), "a", encoding="utf-8") as log:
|
||||
log.write(f"{time.strftime('%Y-%m-%d %H:%M:%S')} strata.ps1 was renamed to {RENAMED_TO} (a typed `strata` in PowerShell "
|
||||
"runs a .ps1 before a .cmd, and the default execution policy refuses it)\n")
|
||||
except OSError:
|
||||
pass
|
||||
say(f"strata: {ps1} was renamed to {RENAMED_TO}. PowerShell runs a .ps1 file before a .cmd file and refuses it with its "
|
||||
"default settings; now typing strata works there.")
|
||||
except Exception: # noqa: BLE001 - never a reason for a launcher to fail
|
||||
|
||||
@@ -54,6 +54,9 @@ class Heal(unittest.TestCase):
|
||||
self.assertEqual((self.dir / "strata-direct.ps1").read_text(encoding="utf-8"), OLD_PS1)
|
||||
self.assertEqual(len(self.said), 1)
|
||||
self.assertIn("strata-direct.ps1", self.said[0])
|
||||
log = (self.dir / launcher_heal.LOG_NAME).read_text(encoding="utf-8") # a line for support, also when nobody saw the one above
|
||||
self.assertEqual(len(log.splitlines()), 1)
|
||||
self.assertIn("strata.ps1 was renamed to strata-direct.ps1", log)
|
||||
self.assertEqual(self.run_heal(), []) # once: nothing left to do, nothing said again
|
||||
self.assertEqual(len(self.said), 1)
|
||||
|
||||
|
||||
Reference in new issue
Block a user