Mercurial > hg
comparison hgext/zeroconf/Zeroconf.py @ 7874:d812029cda85
cleanup: drop variables for unused return values
They are unnecessary. I did leave them in localrepo.py where there is
something like:
_junk = foo()
_junk = None
to free memory early. I don't know if just `foo()` will free the return
value as early.
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Mon, 23 Mar 2009 13:13:02 +0100 |
parents | 643c751e60b2 |
children | eba7f12b0c51 |
comparison
equal
deleted
inserted
replaced
7873:4a4c7f6a5912 | 7874:d812029cda85 |
---|---|
864 traceback.print_exc() | 864 traceback.print_exc() |
865 except: | 865 except: |
866 pass | 866 pass |
867 | 867 |
868 def getReaders(self): | 868 def getReaders(self): |
869 result = [] | |
870 self.condition.acquire() | 869 self.condition.acquire() |
871 result = self.readers.keys() | 870 result = self.readers.keys() |
872 self.condition.release() | 871 self.condition.release() |
873 return result | 872 return result |
874 | 873 |
1484 # | 1483 # |
1485 if port != _MDNS_PORT: | 1484 if port != _MDNS_PORT: |
1486 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA, 0) | 1485 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA, 0) |
1487 for question in msg.questions: | 1486 for question in msg.questions: |
1488 out.addQuestion(question) | 1487 out.addQuestion(question) |
1489 | 1488 |
1490 for question in msg.questions: | 1489 for question in msg.questions: |
1491 if question.type == _TYPE_PTR: | 1490 if question.type == _TYPE_PTR: |
1492 if question.name == "_services._dns-sd._udp.local.": | 1491 if question.name == "_services._dns-sd._udp.local.": |
1493 for stype in self.servicetypes.keys(): | 1492 for stype in self.servicetypes.keys(): |
1494 if out is None: | 1493 if out is None: |
1495 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA) | 1494 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA) |
1496 out.addAnswer(msg, DNSPointer("_services._dns-sd._udp.local.", _TYPE_PTR, _CLASS_IN, _DNS_TTL, stype)) | 1495 out.addAnswer(msg, DNSPointer("_services._dns-sd._udp.local.", _TYPE_PTR, _CLASS_IN, _DNS_TTL, stype)) |
1497 for service in self.services.values(): | 1496 for service in self.services.values(): |
1498 if question.name == service.type: | 1497 if question.name == service.type: |
1499 if out is None: | 1498 if out is None: |
1500 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA) | 1499 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA) |
1501 out.addAnswer(msg, DNSPointer(service.type, _TYPE_PTR, _CLASS_IN, _DNS_TTL, service.name)) | 1500 out.addAnswer(msg, DNSPointer(service.type, _TYPE_PTR, _CLASS_IN, _DNS_TTL, service.name)) |
1502 else: | 1501 else: |
1503 try: | 1502 try: |
1504 if out is None: | 1503 if out is None: |
1505 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA) | 1504 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA) |
1506 | 1505 |
1507 # Answer A record queries for any service addresses we know | 1506 # Answer A record queries for any service addresses we know |
1508 if question.type == _TYPE_A or question.type == _TYPE_ANY: | 1507 if question.type == _TYPE_A or question.type == _TYPE_ANY: |
1509 for service in self.services.values(): | 1508 for service in self.services.values(): |
1510 if service.server == question.name.lower(): | 1509 if service.server == question.name.lower(): |
1511 out.addAnswer(msg, DNSAddress(question.name, _TYPE_A, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.address)) | 1510 out.addAnswer(msg, DNSAddress(question.name, _TYPE_A, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.address)) |
1512 | 1511 |
1513 service = self.services.get(question.name.lower(), None) | 1512 service = self.services.get(question.name.lower(), None) |
1514 if not service: continue | 1513 if not service: continue |
1515 | 1514 |
1516 if question.type == _TYPE_SRV or question.type == _TYPE_ANY: | 1515 if question.type == _TYPE_SRV or question.type == _TYPE_ANY: |
1517 out.addAnswer(msg, DNSService(question.name, _TYPE_SRV, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.priority, service.weight, service.port, service.server)) | 1516 out.addAnswer(msg, DNSService(question.name, _TYPE_SRV, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.priority, service.weight, service.port, service.server)) |
1518 if question.type == _TYPE_TXT or question.type == _TYPE_ANY: | 1517 if question.type == _TYPE_TXT or question.type == _TYPE_ANY: |
1519 out.addAnswer(msg, DNSText(question.name, _TYPE_TXT, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.text)) | 1518 out.addAnswer(msg, DNSText(question.name, _TYPE_TXT, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.text)) |
1520 if question.type == _TYPE_SRV: | 1519 if question.type == _TYPE_SRV: |
1521 out.addAdditionalAnswer(DNSAddress(service.server, _TYPE_A, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.address)) | 1520 out.addAdditionalAnswer(DNSAddress(service.server, _TYPE_A, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.address)) |
1522 except: | 1521 except: |
1523 traceback.print_exc() | 1522 traceback.print_exc() |
1524 | 1523 |
1525 if out is not None and out.answers: | 1524 if out is not None and out.answers: |
1526 out.id = msg.id | 1525 out.id = msg.id |
1527 self.send(out, addr, port) | 1526 self.send(out, addr, port) |
1528 | 1527 |
1529 def send(self, out, addr = _MDNS_ADDR, port = _MDNS_PORT): | 1528 def send(self, out, addr = _MDNS_ADDR, port = _MDNS_PORT): |
1530 """Sends an outgoing packet.""" | 1529 """Sends an outgoing packet.""" |
1531 # This is a quick test to see if we can parse the packets we generate | 1530 # This is a quick test to see if we can parse the packets we generate |
1532 #temp = DNSIncoming(out.packet()) | 1531 #temp = DNSIncoming(out.packet()) |
1533 try: | 1532 try: |
1534 bytes_sent = self.socket.sendto(out.packet(), 0, (addr, port)) | 1533 self.socket.sendto(out.packet(), 0, (addr, port)) |
1535 except: | 1534 except: |
1536 # Ignore this, it may be a temporary loss of network connection | 1535 # Ignore this, it may be a temporary loss of network connection |
1537 pass | 1536 pass |
1538 | 1537 |
1539 def close(self): | 1538 def close(self): |