diff --git a/src/allmydata/scripts/tahoe_daemonize.py b/src/allmydata/scripts/tahoe_daemonize.py index 48fa16d56..40585fb26 100644 --- a/src/allmydata/scripts/tahoe_daemonize.py +++ b/src/allmydata/scripts/tahoe_daemonize.py @@ -115,6 +115,7 @@ class DaemonizeTheRealService(Service, HookMixin): - 'running': triggered when startup has completed; it triggers with None of successful or a Failure otherwise. """ + stderr = sys.stderr def __init__(self, nodetype, basedir, options): super(DaemonizeTheRealService, self).__init__() @@ -145,10 +146,12 @@ class DaemonizeTheRealService(Service, HookMixin): raise ValueError("unknown nodetype %s" % self.nodetype) def handle_config_error(fail): - fail.trap(UnknownConfigError) - self.stderr.write("\nConfiguration error:\n{}\n\n".format(fail.value)) + if fail.check(UnknownConfigError): + self.stderr.write("\nConfiguration error:\n{}\n\n".format(fail.value)) + else: + self.stderr.write("\nUnknown error\n") + fail.printTraceback(self.stderr) reactor.stop() - return d = service_factory() diff --git a/src/allmydata/test/cli/test_daemonize.py b/src/allmydata/test/cli/test_daemonize.py index 414061977..e9a6d1ca0 100644 --- a/src/allmydata/test/cli/test_daemonize.py +++ b/src/allmydata/test/cli/test_daemonize.py @@ -1,4 +1,7 @@ import os +from io import ( + BytesIO, +) from os.path import dirname, join from mock import patch, Mock from six.moves import StringIO @@ -52,6 +55,7 @@ class Util(unittest.TestCase): def test_daemonize_no_keygen(self): tmpdir = self.mktemp() + stderr = BytesIO() plug = DaemonizeTahoeNodePlugin('key-generator', tmpdir) with patch('twisted.internet.reactor') as r: @@ -59,8 +63,8 @@ class Util(unittest.TestCase): d = fn() d.addErrback(lambda _: None) # ignore the error we'll trigger r.callWhenRunning = call - r.stop = 'foo' service = plug.makeService(self.options) + service.stderr = stderr service.parent = Mock() # we'll raise ValueError because there's no key-generator # .. BUT we do this in an async function called via @@ -70,7 +74,7 @@ class Util(unittest.TestCase): def done(f): self.assertIn( "key-generator support removed", - str(f), + stderr.getvalue(), ) return None d.addBoth(done)