Commit 6019754f authored by Petr Špaček's avatar Petr Špaček

PEP8 fixes

parent 36377a24
Pipeline #2003 failed with stage
in 45 seconds
...@@ -79,6 +79,7 @@ def compare_rrs(expected, got): ...@@ -79,6 +79,7 @@ def compare_rrs(expected, got):
% (len(expected), len(got))) % (len(expected), len(got)))
return True return True
def compare_val(expected, got): def compare_val(expected, got):
""" Compare values, throw exception if different. """ """ Compare values, throw exception if different. """
if expected != got: if expected != got:
...@@ -258,7 +259,7 @@ class Entry: ...@@ -258,7 +259,7 @@ class Entry:
answer = dns.message.from_wire(self.message.to_wire(), answer = dns.message.from_wire(self.message.to_wire(),
xfr=self.message.xfr, xfr=self.message.xfr,
one_rr_per_rrset=True) one_rr_per_rrset=True)
answer.use_edns(query.edns, query.ednsflags, options = self.message.options) answer.use_edns(query.edns, query.ednsflags, options=self.message.options)
if 'copy_id' in self.adjust_fields: if 'copy_id' in self.adjust_fields:
answer.id = query.id answer.id = query.id
# Copy letter-case if the template has QD # Copy letter-case if the template has QD
...@@ -362,14 +363,14 @@ class Entry: ...@@ -362,14 +363,14 @@ class Entry:
else: else:
raise Exception('bad section %s' % self.section) raise Exception('bad section %s' % self.section)
def use_tsig(self,fields): def use_tsig(self, fields):
tsig_keyname = fields[0] tsig_keyname = fields[0]
tsig_secret = fields[1] tsig_secret = fields[1]
keyring = dns.tsigkeyring.from_text({tsig_keyname : tsig_secret}) keyring = dns.tsigkeyring.from_text({tsig_keyname: tsig_secret})
self.message.use_tsig(keyring=keyring,keyname=tsig_keyname) self.message.use_tsig(keyring=keyring, keyname=tsig_keyname)
def __rr_add(self, section, rr): def __rr_add(self, section, rr):
""" Merge record to existing RRSet, or append to given section. """ """ Merge record to existing RRSet, or append to given section. """
section.append(rr) section.append(rr)
def set_mandatory(self): def set_mandatory(self):
...@@ -606,8 +607,8 @@ class Step: ...@@ -606,8 +607,8 @@ class Step:
self.raw_answer = answer self.raw_answer = answer
ctx.last_raw_answer = answer ctx.last_raw_answer = answer
if self.raw_answer is not None: if self.raw_answer is not None:
self.answer = dns.message.from_wire(self.raw_answer,one_rr_per_rrset=True) self.answer = dns.message.from_wire(self.raw_answer, one_rr_per_rrset=True)
log_packet(sock, answer, query = False) log_packet(sock, answer, query=False)
else: else:
self.answer = None self.answer = None
ctx.last_answer = self.answer ctx.last_answer = self.answer
......
...@@ -32,15 +32,16 @@ def recvfrom_msg(stream, raw = False): ...@@ -32,15 +32,16 @@ def recvfrom_msg(stream, raw = False):
if len(next_chunk) == 0: if len(next_chunk) == 0:
return None, None return None, None
data += next_chunk data += next_chunk
received += len (next_chunk) received += len(next_chunk)
addr = stream.getpeername()[0] addr = stream.getpeername()[0]
else: else:
raise Exception ("[recvfrom_msg]: unknown socket type '%i'" % stream.type) raise Exception("[recvfrom_msg]: unknown socket type '%i'" % stream.type)
if not raw: if not raw:
data = dns.message.from_wire(data, one_rr_per_rrset=True) data = dns.message.from_wire(data, one_rr_per_rrset=True)
return data, addr return data, addr
def sendto_msg(stream, message, addr = None):
def sendto_msg(stream, message, addr=None):
""" Send DNS/UDP/TCP message. """ """ Send DNS/UDP/TCP message. """
try: try:
if stream.type == socket.SOCK_DGRAM: if stream.type == socket.SOCK_DGRAM:
......
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