This commit is contained in:
yumoqing 2023-06-28 15:21:24 +08:00
parent 1066e2250f
commit 4e04ec9745
2 changed files with 7 additions and 2 deletions

View File

@ -68,10 +68,12 @@ def findAllDrives():
## list all folder name under folder named by path ## list all folder name under folder named by path
# #
def folderList(path) : def listFolder(path, rescursive=False) :
for name in os.listdir(path) : for name in os.listdir(path) :
full_name = os.path.join(path,name) full_name = os.path.join(path,name)
if os.path.isdir(full_name): if os.path.isdir(full_name):
for f in listFolder(full_name, rescursive=rescursive):
yield f
yield full_name yield full_name
def listFile(folder,suffixs=[],rescursive=False): def listFile(folder,suffixs=[],rescursive=False):

View File

@ -14,11 +14,14 @@ def pmp_get_external_ip():
def upnp_get_external_ip(): def upnp_get_external_ip():
try: try:
igd = upnpclient.discover()[0] igd = upnpclient.discover()[0]
print(igd.service_map)
s_names = [ n for n in igd.service_map.keys() if 'WAN' in n and 'Conn' in n] s_names = [ n for n in igd.service_map.keys() if 'WAN' in n and 'Conn' in n]
upnp = igd.service_map[s_names[0]] upnp = igd.service_map[s_names[0]]
x = upnp.GetExternalIPAddress() x = upnp.GetExternalIPAddress()
return x.get('NewExternalIPAddress', None) return x.get('NewExternalIPAddress', None)
except: except Exception as e:
print(f'e={e}')
return None return None
def ipgetter_get_external_ip(): def ipgetter_get_external_ip():