Commit 993cb1ff authored by Colomban Wendling's avatar Colomban Wendling

PEP8 fixes

Fix all PEP8 errors but E221 (multiple spaces before operator).
parent 1493903b
......@@ -24,7 +24,8 @@ config.emails.subject_tpl = "[ARN] {state}: {check} on {dest}"
mail = Host(ipv4='127.0.0.1', ipv6='::1', name='LXC mail')
web = Host(ipv4='127.0.0.0', ipv6='::42', name='Bad IPs')
alsace = Host(ipv4='127.0.0.1', ipv6='::1')
recursif = Host(ipv4='89.234.141.66', ipv6='2a00:5881:8100:1000::31', name='DNS récursif')
recursif = Host(ipv4='89.234.141.66', ipv6='2a00:5881:8100:1000::31',
name='DNS récursif')
config.checks.add(CheckDNSZone, ["arn-fai.net", "netlib.re"], ip_version=4)
config.checks.add(CheckPing4, [mail, web], retry=2)
......
......@@ -24,5 +24,7 @@ config.install_attr('emails.smtp_host', 'localhost:25')
# available substitutions:
# - state ("Problem" or "OK")
# - check (check's name, like "CheckDNSRec6")
# - dest (the target of the check ie. an IP or a Host's 'name' parameter)
config.install_attr('emails.subject_tpl', '[DOMAIN] {state}: {check} on {dest}')
# - dest (the target of the check ie. an IP or a Host's 'name'
# parameter)
config.install_attr('emails.subject_tpl',
'[DOMAIN] {state}: {check} on {dest}')
......@@ -38,7 +38,10 @@ class Check(object):
def __repr__(self):
return '{:<15s} N={}/{}, R={}/{}, {}'.format(self.__class__.__name__,
self.every_count, self.every, self.retry_count, self.retry,
self.every_count,
self.every,
self.retry_count,
self.retry,
self._options)
def setup(self):
......@@ -121,13 +124,13 @@ class Check6(CheckIP):
class CheckPing4(Check4):
def check(self):
command = ['/bin/ping', '-c', '1', '-W', str(self.timeout), self.addr]
return self.exec_with_timeout(command, timeout=self.timeout+1)
return self.exec_with_timeout(command, timeout=self.timeout + 1)
class CheckPing6(Check6):
def check(self):
command = ['/bin/ping6', '-c', '1', '-W', str(self.timeout), self.addr]
return self.exec_with_timeout(command, timeout=self.timeout+1)
return self.exec_with_timeout(command, timeout=self.timeout + 1)
class CheckDNSZone(Check):
......@@ -182,13 +185,13 @@ class CheckHTTP(Check):
def check(self):
command = self.build_command()
return self.exec_with_timeout(command, timeout=self.timeout+1)
return self.exec_with_timeout(command, timeout=self.timeout + 1)
class CheckHTTPS(CheckHTTP):
def check(self):
command = self.build_command() + ['--ssl']
return self.exec_with_timeout(command, timeout=self.timeout+1)
return self.exec_with_timeout(command, timeout=self.timeout + 1)
class CheckHTTP4(CheckHTTP, Check4):
......@@ -222,7 +225,7 @@ class CheckSMTP(Check):
def check(self):
command = self.build_command()
return self.exec_with_timeout(command, timeout=self.timeout+1)
return self.exec_with_timeout(command, timeout=self.timeout + 1)
class CheckSMTP4(CheckSMTP, Check4):
......@@ -243,7 +246,7 @@ class CheckOpenVPN(Check):
'-s', "\x38\x01\x01\x01\x01\x01\x01\x01\x42",
'-e', "@",
'-t', str(self.timeout)]
return self.exec_with_timeout(command, timeout=self.timeout+1)
return self.exec_with_timeout(command, timeout=self.timeout + 1)
class CheckOpenVPN4(CheckOpenVPN, Check4):
......
......@@ -8,6 +8,7 @@ import email.charset
# unreadable for non-ASCII chars if we have to look at raw email
email.charset.add_charset('utf-8', email.charset.QP, email.charset.QP, 'utf-8')
def send_email_for_check(check):
from . import config
# ensure we do not traceback with unknown substitutions
......@@ -32,7 +33,8 @@ def send_email_for_check(check):
try:
server = smtplib.SMTP(config.emails.smtp_host)
# server.set_debuglevel(1)
server.sendmail(config.emails.addr_from, config.emails.to, msg.as_string())
server.sendmail(config.emails.addr_from, config.emails.to,
msg.as_string())
server.quit()
except Exception as e:
print("Couldn't send email: %s" % str(e), file=stderr)
......@@ -31,7 +31,8 @@ if __name__ == '__main__':
# Parse command line
parser = argparse.ArgumentParser()
parser.add_argument("-1", "--one",
help="single run with immediate output of check results (test/debug)",
help="single run with immediate output of " +
"check results (test/debug)",
action="store_true")
args = parser.parse_args()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment