Add a command to reload the config.

This commit is contained in:
Eijebong 2014-12-30 22:58:22 +01:00
parent 96442e93e3
commit 71f3848706
3 changed files with 25 additions and 7 deletions

View file

@ -265,6 +265,8 @@ These commands work in *any* tab.
/self
Reminds you of who you are and what your status is.
/reload
Reload the config. You can achieve the same by sending SIGUSR1 to poezio.
/close
Close the tab.

View file

@ -1036,5 +1036,14 @@ def command_self(self):
config_opts.version))
self.information(info, 'Info')
@command_args_parser.ignored
def command_reload(self):
"""
/reload
"""
self.reload_config()
def dumb_callback(*args, **kwargs):
"mock callback"

View file

@ -397,19 +397,14 @@ class Core(object):
"""
self.xmpp.password = value
def sigusr_handler(self, num, stack):
"""
Handle SIGUSR1 (10)
When caught, reload all the possible files.
"""
log.debug("SIGUSR1 caught, reloading the files…")
def reload_config(self):
# reload all log files
log.debug("Reloading the log files…")
logger.reload_all()
log.debug("Log files reloaded.")
# reload the theme
log.debug("Reloading the theme…")
self.command_theme("")
theming.reload_theme()
log.debug("Theme reloaded.")
# reload the config from the disk
log.debug("Reloading the config…")
@ -429,6 +424,14 @@ class Core(object):
# in case some roster options have changed
roster.modified()
def sigusr_handler(self, num, stack):
"""
Handle SIGUSR1 (10)
When caught, reload all the possible files.
"""
log.debug("SIGUSR1 caught, reloading the files…")
self.reload_config()
def exit_from_signal(self, *args, **kwargs):
"""
Quit when receiving SIGHUP or SIGTERM or SIGPIPE
@ -1877,6 +1880,9 @@ class Core(object):
self.register_command('ad-hoc', self.command_adhoc,
usage='<jid>',
shortdesc=_('List available ad-hoc commands on the given jid'))
self.register_command('reload', self.command_reload,
shortdesc=_('Reload the config. You can achieve the same by '
'sending SIGUSR1 to poezio.'))
if config.get('enable_user_activity'):
self.register_command('activity', self.command_activity,
@ -2000,6 +2006,7 @@ class Core(object):
command_xml_tab = commands.command_xml_tab
command_adhoc = commands.command_adhoc
command_self = commands.command_self
command_reload = commands.command_reload
completion_help = completions.completion_help
completion_status = completions.completion_status
completion_presence = completions.completion_presence