From f94fde9157671f0b84b6eb7f4a776238f0b2c052 Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Thu, 5 Sep 2013 02:14:19 +0200 Subject: [PATCH] --no-remote --- today.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/today.py b/today.py index 127e41d..9f97594 100755 --- a/today.py +++ b/today.py @@ -24,6 +24,8 @@ class Config(object): self.green = u"" else: self.endcolor = self.blue = self.red = self.green = "" + #: Faut-il contacter le serveur distant + self.do_remote = True #: Serveur distant où aller récupérer les checks self.distant_server = "pimeys" #: path de today-server.py sur le serveur distant @@ -303,8 +305,9 @@ def check_all(): return checks def get_everything(): - """Récupère toutes les infos""" - work = [action() for action in AUTOMATED_ACTIONS.values()] + """Récupère toutes les infos.""" + work = [action() for (keyword, action) in AUTOMATED_ACTIONS.iteritems() + if (config.do_remote or not keyword in REMOTE_ACTIONS)] chain = u"\n\n".join([result for result in work if result]) return chain @@ -422,6 +425,9 @@ OTHER_ACTIONS = { "init" : initialize, } +#: Les actions qui nécessitent un accès au serveur distant +REMOTE_ACTIONS = ["check", "sync"] + #: Toutes les actions ACTIONS = dict(AUTOMATED_ACTIONS) ACTIONS.update(OTHER_ACTIONS) @@ -432,6 +438,10 @@ if __name__ == "__main__": import sys if "--no-color" in sys.argv: config.endcolor, config.red, config.blue = u"", u"", u"" + sys.argv.remove("--no-color") + if "--no-remote" in sys.argv: + config.do_remote = False + sys.argv.remove("--no-remote") if len(sys.argv) == 1: # Juste un today output = ACTIONS[None]() -- 2.39.2