From 5c9d73fbb485b46a47597f1b4cf4f768c23a4b7e Mon Sep 17 00:00:00 2001 From: oysteini Date: Wed, 12 May 2010 17:42:48 +0000 Subject: [PATCH] Restart-kommando. --- text_based.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/text_based.py b/text_based.py index 0ed5d9c..cf7dfa8 100755 --- a/text_based.py +++ b/text_based.py @@ -3,6 +3,7 @@ import sqlalchemy import re import sys +import os import traceback import signal from helpers import * @@ -11,6 +12,7 @@ exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death'] help_commands = ['help', '?'] context_commands = ['what', '??'] local_help_commands = ['help!', '???'] +restart_commands = ['restart'] class ExitMenu(Exception): pass @@ -130,6 +132,10 @@ class Menu(): if result in context_commands: self.show_context() continue + if result in restart_commands: + if self.confirm('Restart Dibbler?'): + restart() + continue if empty_string_is_none and result == '': return None return result @@ -683,6 +689,12 @@ def retrieve_product(search_str, session): return search_ui(search_product, search_str, 'product', session) +def restart(): + # Does not work if the script is not executable, or if it was + # started by searching $PATH. + os.execv(sys.argv[0], sys.argv) + + if not conf.stop_allowed: signal.signal(signal.SIGTSTP, signal.SIG_IGN) main = Menu('Dibbler main menu',