From 71f38487061cf6ad3e71b3cc1d0e80cb0f607111 Mon Sep 17 00:00:00 2001 From: Eijebong Date: Tue, 30 Dec 2014 22:58:22 +0100 Subject: Add a command to reload the config. --- src/core/commands.py | 9 +++++++++ src/core/core.py | 21 ++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/core/commands.py b/src/core/commands.py index 15ff96e2..5912abe2 100644 --- a/src/core/commands.py +++ b/src/core/commands.py @@ -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" + diff --git a/src/core/core.py b/src/core/core.py index ba9b16e0..a750cfa3 100644 --- a/src/core/core.py +++ b/src/core/core.py @@ -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='', 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 -- cgit v1.2.3