##// END OF EJS Templates
zeroconf: remove camelcase in identifiers
timeless -
r28419:eb9d0e82 default
parent child Browse files
Show More
@@ -477,10 +477,10 b' class DNSIncoming(object):'
477 self.data = data
477 self.data = data
478 self.questions = []
478 self.questions = []
479 self.answers = []
479 self.answers = []
480 self.numQuestions = 0
480 self.numquestions = 0
481 self.numAnswers = 0
481 self.numanswers = 0
482 self.numAuthorities = 0
482 self.numauthorities = 0
483 self.numAdditionals = 0
483 self.numadditionals = 0
484
484
485 self.readHeader()
485 self.readHeader()
486 self.readQuestions()
486 self.readQuestions()
@@ -496,16 +496,16 b' class DNSIncoming(object):'
496
496
497 self.id = info[0]
497 self.id = info[0]
498 self.flags = info[1]
498 self.flags = info[1]
499 self.numQuestions = info[2]
499 self.numquestions = info[2]
500 self.numAnswers = info[3]
500 self.numanswers = info[3]
501 self.numAuthorities = info[4]
501 self.numauthorities = info[4]
502 self.numAdditionals = info[5]
502 self.numadditionals = info[5]
503
503
504 def readQuestions(self):
504 def readQuestions(self):
505 """Reads questions section of packet"""
505 """Reads questions section of packet"""
506 format = '!HH'
506 format = '!HH'
507 length = struct.calcsize(format)
507 length = struct.calcsize(format)
508 for i in range(0, self.numQuestions):
508 for i in range(0, self.numquestions):
509 name = self.readName()
509 name = self.readName()
510 info = struct.unpack(format,
510 info = struct.unpack(format,
511 self.data[self.offset:self.offset + length])
511 self.data[self.offset:self.offset + length])
@@ -554,7 +554,7 b' class DNSIncoming(object):'
554 """Reads answers, authorities and additionals section of the packet"""
554 """Reads answers, authorities and additionals section of the packet"""
555 format = '!HHiH'
555 format = '!HHiH'
556 length = struct.calcsize(format)
556 length = struct.calcsize(format)
557 n = self.numAnswers + self.numAuthorities + self.numAdditionals
557 n = self.numanswers + self.numAuthorities + self.numadditionals
558 for i in range(0, n):
558 for i in range(0, n):
559 domain = self.readName()
559 domain = self.readName()
560 info = struct.unpack(format,
560 info = struct.unpack(format,
@@ -990,7 +990,7 b' class ServiceBrowser(threading.Thread):'
990 self.type = type
990 self.type = type
991 self.listener = listener
991 self.listener = listener
992 self.services = {}
992 self.services = {}
993 self.nextTime = currentTimeMillis()
993 self.nexttime = currentTimeMillis()
994 self.delay = _BROWSER_TIME
994 self.delay = _BROWSER_TIME
995 self.list = []
995 self.list = []
996
996
@@ -1024,8 +1024,8 b' class ServiceBrowser(threading.Thread):'
1024 self.list.append(callback)
1024 self.list.append(callback)
1025
1025
1026 expires = record.getExpirationTime(75)
1026 expires = record.getExpirationTime(75)
1027 if expires < self.nextTime:
1027 if expires < self.nexttime:
1028 self.nextTime = expires
1028 self.nexttime = expires
1029
1029
1030 def cancel(self):
1030 def cancel(self):
1031 self.done = 1
1031 self.done = 1
@@ -1035,20 +1035,20 b' class ServiceBrowser(threading.Thread):'
1035 while True:
1035 while True:
1036 event = None
1036 event = None
1037 now = currentTimeMillis()
1037 now = currentTimeMillis()
1038 if len(self.list) == 0 and self.nextTime > now:
1038 if len(self.list) == 0 and self.nexttime > now:
1039 self.zeroconf.wait(self.nextTime - now)
1039 self.zeroconf.wait(self.nexttime - now)
1040 if globals()['_GLOBAL_DONE'] or self.done:
1040 if globals()['_GLOBAL_DONE'] or self.done:
1041 return
1041 return
1042 now = currentTimeMillis()
1042 now = currentTimeMillis()
1043
1043
1044 if self.nextTime <= now:
1044 if self.nexttime <= now:
1045 out = DNSOutgoing(_FLAGS_QR_QUERY)
1045 out = DNSOutgoing(_FLAGS_QR_QUERY)
1046 out.addQuestion(DNSQuestion(self.type, _TYPE_PTR, _CLASS_IN))
1046 out.addQuestion(DNSQuestion(self.type, _TYPE_PTR, _CLASS_IN))
1047 for record in self.services.values():
1047 for record in self.services.values():
1048 if not record.isExpired(now):
1048 if not record.isExpired(now):
1049 out.addAnswerAtTime(record, now)
1049 out.addAnswerAtTime(record, now)
1050 self.zeroconf.send(out)
1050 self.zeroconf.send(out)
1051 self.nextTime = now + self.delay
1051 self.nexttime = now + self.delay
1052 self.delay = min(20 * 1000, self.delay * 2)
1052 self.delay = min(20 * 1000, self.delay * 2)
1053
1053
1054 if len(self.list) > 0:
1054 if len(self.list) > 0:
@@ -1394,11 +1394,11 b' class Zeroconf(object):'
1394 else:
1394 else:
1395 self.servicetypes[info.type] = 1
1395 self.servicetypes[info.type] = 1
1396 now = currentTimeMillis()
1396 now = currentTimeMillis()
1397 nextTime = now
1397 nexttime = now
1398 i = 0
1398 i = 0
1399 while i < 3:
1399 while i < 3:
1400 if now < nextTime:
1400 if now < nexttime:
1401 self.wait(nextTime - now)
1401 self.wait(nexttime - now)
1402 now = currentTimeMillis()
1402 now = currentTimeMillis()
1403 continue
1403 continue
1404 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
1404 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
@@ -1418,7 +1418,7 b' class Zeroconf(object):'
1418 _CLASS_IN, ttl, info.address), 0)
1418 _CLASS_IN, ttl, info.address), 0)
1419 self.send(out)
1419 self.send(out)
1420 i += 1
1420 i += 1
1421 nextTime += _REGISTER_TIME
1421 nexttime += _REGISTER_TIME
1422
1422
1423 def unregisterService(self, info):
1423 def unregisterService(self, info):
1424 """Unregister a service."""
1424 """Unregister a service."""
@@ -1431,11 +1431,11 b' class Zeroconf(object):'
1431 except KeyError:
1431 except KeyError:
1432 pass
1432 pass
1433 now = currentTimeMillis()
1433 now = currentTimeMillis()
1434 nextTime = now
1434 nexttime = now
1435 i = 0
1435 i = 0
1436 while i < 3:
1436 while i < 3:
1437 if now < nextTime:
1437 if now < nexttime:
1438 self.wait(nextTime - now)
1438 self.wait(nexttime - now)
1439 now = currentTimeMillis()
1439 now = currentTimeMillis()
1440 continue
1440 continue
1441 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
1441 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
@@ -1453,17 +1453,17 b' class Zeroconf(object):'
1453 _CLASS_IN, 0, info.address), 0)
1453 _CLASS_IN, 0, info.address), 0)
1454 self.send(out)
1454 self.send(out)
1455 i += 1
1455 i += 1
1456 nextTime += _UNREGISTER_TIME
1456 nexttime += _UNREGISTER_TIME
1457
1457
1458 def unregisterAllServices(self):
1458 def unregisterAllServices(self):
1459 """Unregister all registered services."""
1459 """Unregister all registered services."""
1460 if len(self.services) > 0:
1460 if len(self.services) > 0:
1461 now = currentTimeMillis()
1461 now = currentTimeMillis()
1462 nextTime = now
1462 nexttime = now
1463 i = 0
1463 i = 0
1464 while i < 3:
1464 while i < 3:
1465 if now < nextTime:
1465 if now < nexttime:
1466 self.wait(nextTime - now)
1466 self.wait(nexttime - now)
1467 now = currentTimeMillis()
1467 now = currentTimeMillis()
1468 continue
1468 continue
1469 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
1469 out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
@@ -1482,13 +1482,13 b' class Zeroconf(object):'
1482 _CLASS_IN, 0, info.address), 0)
1482 _CLASS_IN, 0, info.address), 0)
1483 self.send(out)
1483 self.send(out)
1484 i += 1
1484 i += 1
1485 nextTime += _UNREGISTER_TIME
1485 nexttime += _UNREGISTER_TIME
1486
1486
1487 def checkService(self, info):
1487 def checkService(self, info):
1488 """Checks the network for a unique service name, modifying the
1488 """Checks the network for a unique service name, modifying the
1489 ServiceInfo passed in if it is not unique."""
1489 ServiceInfo passed in if it is not unique."""
1490 now = currentTimeMillis()
1490 now = currentTimeMillis()
1491 nextTime = now
1491 nexttime = now
1492 i = 0
1492 i = 0
1493 while i < 3:
1493 while i < 3:
1494 for record in self.cache.entriesWithName(info.type):
1494 for record in self.cache.entriesWithName(info.type):
@@ -1500,8 +1500,8 b' class Zeroconf(object):'
1500 self.checkService(info)
1500 self.checkService(info)
1501 return
1501 return
1502 raise NonUniqueNameException
1502 raise NonUniqueNameException
1503 if now < nextTime:
1503 if now < nexttime:
1504 self.wait(nextTime - now)
1504 self.wait(nexttime - now)
1505 now = currentTimeMillis()
1505 now = currentTimeMillis()
1506 continue
1506 continue
1507 out = DNSOutgoing(_FLAGS_QR_QUERY | _FLAGS_AA)
1507 out = DNSOutgoing(_FLAGS_QR_QUERY | _FLAGS_AA)
@@ -1511,7 +1511,7 b' class Zeroconf(object):'
1511 _CLASS_IN, _DNS_TTL, info.name))
1511 _CLASS_IN, _DNS_TTL, info.name))
1512 self.send(out)
1512 self.send(out)
1513 i += 1
1513 i += 1
1514 nextTime += _CHECK_TIME
1514 nexttime += _CHECK_TIME
1515
1515
1516 def addListener(self, listener, question):
1516 def addListener(self, listener, question):
1517 """Adds a listener for a given question. The listener will have
1517 """Adds a listener for a given question. The listener will have
General Comments 0
You need to be logged in to leave comments. Login now