Restart-kommando.
This commit is contained in:
parent
302f5fb7fa
commit
5c9d73fbb4
|
@ -3,6 +3,7 @@
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
import signal
|
import signal
|
||||||
from helpers import *
|
from helpers import *
|
||||||
|
@ -11,6 +12,7 @@ exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death']
|
||||||
help_commands = ['help', '?']
|
help_commands = ['help', '?']
|
||||||
context_commands = ['what', '??']
|
context_commands = ['what', '??']
|
||||||
local_help_commands = ['help!', '???']
|
local_help_commands = ['help!', '???']
|
||||||
|
restart_commands = ['restart']
|
||||||
|
|
||||||
class ExitMenu(Exception):
|
class ExitMenu(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -130,6 +132,10 @@ class Menu():
|
||||||
if result in context_commands:
|
if result in context_commands:
|
||||||
self.show_context()
|
self.show_context()
|
||||||
continue
|
continue
|
||||||
|
if result in restart_commands:
|
||||||
|
if self.confirm('Restart Dibbler?'):
|
||||||
|
restart()
|
||||||
|
continue
|
||||||
if empty_string_is_none and result == '':
|
if empty_string_is_none and result == '':
|
||||||
return None
|
return None
|
||||||
return result
|
return result
|
||||||
|
@ -683,6 +689,12 @@ def retrieve_product(search_str, session):
|
||||||
return search_ui(search_product, search_str, 'product', 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:
|
if not conf.stop_allowed:
|
||||||
signal.signal(signal.SIGTSTP, signal.SIG_IGN)
|
signal.signal(signal.SIGTSTP, signal.SIG_IGN)
|
||||||
main = Menu('Dibbler main menu',
|
main = Menu('Dibbler main menu',
|
||||||
|
|
Loading…
Reference in New Issue