interactive client: change command history location

- place file in ~/.local/state/
- create the directory if needed
- use pathlib

Change-Id: I9381c65fd63cea44013f2cfd16e14b8dc26c465c
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/37111
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
2025-08-07 09:31:03 +02:00
parent 8ba9f91f8a
commit bea6ea38ae

View File

@@ -29,7 +29,7 @@ import os
import traceback
import threading
import logging
from os.path import expanduser
from pathlib import Path
from frappy.lib import delayed_import
from frappy.client import SecopClient, UnregisterCallback
from frappy.errors import SECoPError
@@ -497,7 +497,7 @@ class Console(code.InteractiveConsole):
history = None
if readline:
try:
history = expanduser(f'~/.config/frappy/{name}-history')
history = Path(f'~/.local/state/frappy-{name}-history').expanduser()
readline.read_history_file(history)
except FileNotFoundError:
pass
@@ -505,6 +505,7 @@ class Console(code.InteractiveConsole):
self.interact('', '')
finally:
if history:
history.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
readline.write_history_file(history)
def raw_input(self, prompt=""):