From 0b0d0c5c0550baadcd4da4e266843f350b623c06 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sat, 31 Aug 2013 13:10:30 +0000 Subject: [PATCH] Create .pyhistory if it doesn't exist svn: r22974 --- gramps/webapp/shell.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/gramps/webapp/shell.py b/gramps/webapp/shell.py index 1d941dc33..db880c85c 100644 --- a/gramps/webapp/shell.py +++ b/gramps/webapp/shell.py @@ -28,8 +28,34 @@ import os os.environ['GRAMPS_RESOURCES'] = os.path.dirname(os.path.abspath("..")) pystartup = os.path.expanduser("~/.pystartup") -if os.path.exists(pystartup): - execfile(pystartup) +if not os.path.exists(pystartup): + fp = file(pystartup, "w") + fp.write(""" +import atexit +import os +import readline +import rlcompleter +import sys + +# change autocomplete to tab +readline.parse_and_bind("tab: complete") + +historyPath = os.path.expanduser("~/.pyhistory") + +def save_history(historyPath=historyPath): + import readline + readline.write_history_file(historyPath) + +if os.path.exists(historyPath): + readline.read_history_file(historyPath) + +atexit.register(save_history) + +# anything not deleted (sys and os) will remain in the interpreter session +del atexit, readline, rlcompleter, save_history, historyPath""") + fp.close() + +execfile(pystartup) from django.conf import settings import gramps.webapp.settings as default_settings try: