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