From b3c5591d70c1c354d14267e804ab64872af97b40 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 29 Jan 2008 16:19:30 -0500 Subject: All exceptions, async or otherwise, now come back as easily detectable signatures. Use utils.is_error(result) to determine if something is an error or isn't. Example scripts as well as func-inventory have been updated. See async_test.py for examples. --- func/overlord/client.py | 10 ++++------ func/overlord/inventory.py | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'func/overlord') diff --git a/func/overlord/client.py b/func/overlord/client.py index f33bc4b..e293f1c 100755 --- a/func/overlord/client.py +++ b/func/overlord/client.py @@ -25,7 +25,7 @@ import command import groups import func.forkbomb as forkbomb import func.jobthing as jobthing - +import func.utils as utils # =================================== # defaults @@ -132,7 +132,7 @@ def isServer(server_string): class Client(object): def __init__(self, server_spec, port=DEFAULT_PORT, interactive=False, - verbose=False, noglobs=False, nforks=1, config=None, async=False, noexceptions=True): + verbose=False, noglobs=False, nforks=1, config=None, async=False): """ Constructor. @server_spec -- something like "*.example.org" or "foosball" @@ -153,7 +153,6 @@ class Client(object): self.noglobs = noglobs self.nforks = nforks self.async = async - self.noexceptions= noexceptions self.servers = expand_servers(self.server_spec, port=self.port, noglobs=self.noglobs,verbose=self.verbose) @@ -234,12 +233,11 @@ class Client(object): if self.interactive: print retval except Exception, e: - retval = e + (t, v, tb) = sys.exc_info() + retval = utils.nice_exception(t,v,tb) if self.interactive: sys.stderr.write("remote exception on %s: %s\n" % (server, str(e))) - if self.noglob and not self.noexceptions: - raise(e) if self.noglobs: return retval diff --git a/func/overlord/inventory.py b/func/overlord/inventory.py index 47fff6a..c2a1d30 100755 --- a/func/overlord/inventory.py +++ b/func/overlord/inventory.py @@ -21,8 +21,8 @@ import sys import pprint import xmlrpclib from func.minion import sub_process - import func.overlord.client as func_client +import func.utils as utils DEFAULT_TREE = "/var/lib/func/inventory/" @@ -80,19 +80,21 @@ class FuncInventory(object): # call all remote info methods and handle them if options.verbose: - # print "- DEBUG: %s" % host_methods print "- scanning ..." # for (host, modules) in host_modules.iteritems(): for (host, methods) in host_methods.iteritems(): - - for each_method in methods: + if utils.is_error(methods): + print "-- connection refused: %s" % host + break + + for each_method in methods: - if type(each_method) == int: - if self.options.verbose: - print "-- connection refused: %s" % host - break + #if type(each_method) == int: + # if self.options.verbose: + # print "-- connection refused: %s" % host + # break (module_name, method_name) = each_method.split(".") -- cgit