From a5a25e56e595ea4eff0449390d62ff72c9d192b3 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 13 Oct 2015 16:42:32 +0200 Subject: Info: EventDebug, Update and Quit are now command classes --- src/lib/Bcfg2/Server/Info.py | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/src/lib/Bcfg2/Server/Info.py b/src/lib/Bcfg2/Server/Info.py index 044936f14..418d984a1 100644 --- a/src/lib/Bcfg2/Server/Info.py +++ b/src/lib/Bcfg2/Server/Info.py @@ -385,6 +385,15 @@ class ExpireCache(InfoCmd): self.core.metadata_cache.expire() +class EventDebug(InfoCmd): + """ Enable debugging output for FAM events """ + only_interactive = True + aliases = ['event_debug'] + + def run(self, _): + self.core.fam.set_debug(True) + + class Bundles(InfoCmd): """ Print out group/bundle info """ @@ -673,6 +682,15 @@ class Query(InfoCmd): print("\n".join(res)) +class Quit(InfoCmd): + """ Exit program """ + only_interactive = True + aliases = ['exit', 'EOF'] + + def run(self, _): + raise SystemExit(0) + + class Shell(InfoCmd): """ Open an interactive shell to run multiple bcfg2-info commands """ interactive = False @@ -685,6 +703,14 @@ class Shell(InfoCmd): print("\nCtrl-C pressed, exiting...") +class Update(InfoCmd): + """ Process pending filesystem events """ + only_interactive = True + + def run(self, _): + self.core.fam.handle_events_in_interval(0.1) + + class ProfileTemplates(InfoCmd): """ Benchmark template rendering times """ @@ -870,23 +896,6 @@ class CLI(cmd.Cmd, Bcfg2.Options.CommandRegistry): dynamically adds methods for the registed subcommands. """ return dir(self) - def do_quit(self, _): - """ quit|exit - Exit program """ - raise SystemExit(0) - - do_EOF = do_quit - do_exit = do_quit - - def do_eventdebug(self, _): - """ eventdebug - Enable debugging output for FAM events """ - self.core.fam.set_debug(True) - - do_event_debug = do_eventdebug - - def do_update(self, _): - """ update - Process pending filesystem events """ - self.core.fam.handle_events_in_interval(0.1) - def onecmd(self, line): """ Overwrite cmd.Cmd.onecmd to catch all exceptions (except SystemExit) print an error message and continue cmdloop. """ -- cgit v1.2.3-1-g7c22