UPnP formatting
This commit is contained in:
parent
86e607c403
commit
35bd5e8595
1 changed files with 9 additions and 8 deletions
|
@ -154,7 +154,9 @@ def _get_local_ips():
|
||||||
|
|
||||||
# Delete duplicates
|
# Delete duplicates
|
||||||
local_ips = list(set(local_ips))
|
local_ips = list(set(local_ips))
|
||||||
local_ips = sorted(local_ips, key=lambda a: a.startswith("192"), reverse=True) # Probably we looking for an ip starting with 192
|
|
||||||
|
# Probably we looking for an ip starting with 192
|
||||||
|
local_ips = sorted(local_ips, key=lambda a: a.startswith("192"), reverse=True)
|
||||||
|
|
||||||
logging.debug("Found local ips: %s" % local_ips)
|
logging.debug("Found local ips: %s" % local_ips)
|
||||||
return local_ips
|
return local_ips
|
||||||
|
@ -312,8 +314,8 @@ def _communicate_with_igd(port=15441,
|
||||||
threads = []
|
threads = []
|
||||||
|
|
||||||
for local_ip in local_ips:
|
for local_ip in local_ips:
|
||||||
thread = gevent.spawn(job, local_ip)
|
job_thread = gevent.spawn(job, local_ip)
|
||||||
threads.append(thread)
|
threads.append(job_thread)
|
||||||
gevent.sleep(0.1)
|
gevent.sleep(0.1)
|
||||||
if any([thread.value for thread in threads]):
|
if any([thread.value for thread in threads]):
|
||||||
success = True
|
success = True
|
||||||
|
@ -321,7 +323,7 @@ def _communicate_with_igd(port=15441,
|
||||||
|
|
||||||
# Wait another 10sec for competition or any positibe result
|
# Wait another 10sec for competition or any positibe result
|
||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
all_done = all([thread.value != None for thread in threads])
|
all_done = all([thread.value is not None for thread in threads])
|
||||||
any_succeed = any([thread.value for thread in threads])
|
any_succeed = any([thread.value for thread in threads])
|
||||||
if all_done or any_succeed:
|
if all_done or any_succeed:
|
||||||
break
|
break
|
||||||
|
@ -355,7 +357,6 @@ def ask_to_close_port(port=15441, desc="UpnpPunch", retries=3, protos=("TCP", "U
|
||||||
protos=protos)
|
protos=protos)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from gevent import monkey
|
from gevent import monkey
|
||||||
monkey.patch_all()
|
monkey.patch_all()
|
||||||
|
|
Loading…
Reference in a new issue