Misleading "please run connect() first" error when SMTP server is down
Bug #76239 reported by
Matthew Paul Thomas
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar PQM Plugin |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
bzr 0.13.0, Ubuntu 6.10
What happened:
14:26:22@trivial> bzr pqm-submit -m "[...]"
bzr: ERROR: please run connect() first
14:29:23@trivial> bzr connect
bzr: ERROR: unknown command "connect"
What should have happened:
14:26:22@trivial> bzr pqm-submit -m "[...]"
bzr: ERROR: smtp.myrealbox.com disconnected. Check that the server is online, and your e-mail settings in ~/.bazaar/
description: | updated |
To post a comment you must log in.
Can you include the traceback from ~/.bzr.log? I realize it may be hard to reproduce now.
But I'm trying to figure out which line is failing. We specifically do:
smtp = smtplib.SMTP() server)
smtp.connect(
try: SMTPException:
# The world can always use a little bit more encryption :)
smtp.starttls()
except smtplib.
pass
if smtp_username is not None:
smtp_password = bzrlib. ui.ui_factory. get_password(
smtp.login( smtp_username, smtp_password) SMTPHeloError, e: ('SMTP server refused HELO: %d %s'
% (e.smtp_code, e.smtp_error)) SMTPAuthenticat ionError, e: ('SMTP server refused authentication: %d %s'
% (e.smtp_code, e.smtp_error)) SMTPException, e: (str(e) )
if smtp_password is None:
'Please enter SMTP password for %(host)s', host=server)
try:
except smtplib.
raise BzrCommandError
except smtplib.
raise BzrCommandError
except smtplib.
raise BzrCommandError
Which looks like we should be doing the right thing. It would seem that 'connect()' should be failing.
I suppose it is possible that we are running into the final
except smtplib. SMTPException, e: (str(e) )
raise BzrCommandError
Which means that we need to trap another specific exception at this point.
I can see this happening: 'mynonexistants erver.com' ) python2. 4/smtplib. py", line 292, in connect getaddrinfo( host, port, 0, socket. SOCK_STREAM) :
>>> s.connect(
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/
for res in socket.
socket.gaierror: (-2, 'Name or service not known')
But that is if the domain doesn't resolve.
If I stop the local mail server I get: 'localhost' ) python2. 4/smtplib. py", line 306, in connect
>>> s.connect(
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/
raise socket.error, msg
socket.error: (111, 'Connection refused')
Which again seems reasonable.
Can you reproduce this?