Fix some 2/3 differences and run pylint with confidence=HIGH

Too many false positives otherwise.
This commit is contained in:
Iain Lane 2017-05-30 11:21:52 +01:00
parent d41602ba83
commit 0a3738cfbc
3 changed files with 22 additions and 8 deletions

View File

@ -26,7 +26,7 @@ import sys
import ubuntutools.subprocess import ubuntutools.subprocess
if sys.version_info[0] < 3: if sys.version_info[0] < 3:
input = raw_input # noqa input = raw_input # noqa, pylint: disable=undefined-variable
class Question(object): class Question(object):

View File

@ -199,16 +199,30 @@ Content-Type: text/plain; charset=UTF-8
mailserver_port) mailserver_port)
s = smtplib.SMTP(mailserver_host, mailserver_port) s = smtplib.SMTP(mailserver_host, mailserver_port)
break break
except socket.error as s:
Logger.error('Could not connect to %s:%s: %s (%i)',
mailserver_host, mailserver_port, s[1], s[0])
return
except smtplib.SMTPConnectError as s: except smtplib.SMTPConnectError as s:
Logger.error('Could not connect to %s:%s: %s (%i)', try:
mailserver_host, mailserver_port, s[1], s[0]) # py2 path
# pylint: disable=unsubscriptable-object
Logger.error('Could not connect to %s:%s: %s (%i)',
mailserver_host, mailserver_port, s[1], s[0])
except TypeError:
# pylint: disable=no-member
Logger.error('Could not connect to %s:%s: %s (%i)',
mailserver_host, mailserver_port, s.strerror, s.errno)
if s.smtp_code == 421: if s.smtp_code == 421:
confirmation_prompt(message='This is a temporary error, press [Enter] ' confirmation_prompt(message='This is a temporary error, press [Enter] '
'to retry. Press [Ctrl-C] to abort now.') 'to retry. Press [Ctrl-C] to abort now.')
except socket.error as s:
try:
# py2 path
# pylint: disable=unsubscriptable-object
Logger.error('Could not connect to %s:%s: %s (%i)',
mailserver_host, mailserver_port, s[1], s[0])
except TypeError:
# pylint: disable=no-member
Logger.error('Could not connect to %s:%s: %s (%i)',
mailserver_host, mailserver_port, s.strerror, s.errno)
return
if mailserver_user and mailserver_pass: if mailserver_user and mailserver_pass:
try: try:

View File

@ -38,7 +38,7 @@ class PylintTestCase(unittest.TestCase):
else: else:
pylint_binary = 'pylint' pylint_binary = 'pylint'
cmd = [pylint_binary, '--rcfile=ubuntutools/test/pylint.conf', '-E', cmd = [pylint_binary, '--rcfile=ubuntutools/test/pylint.conf', '-E',
'--reports=n', '--'] + files '--reports=n', '--confidence=HIGH', '--'] + files
sys.stderr.write("Running following command:\n{}\n".format(" ".join(cmd))) sys.stderr.write("Running following command:\n{}\n".format(" ".join(cmd)))
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True) stderr=subprocess.PIPE, close_fds=True)