diff --git a/appPublic/across_nat.py b/appPublic/across_nat.py index 5d83da2..2de6cbf 100644 --- a/appPublic/across_nat.py +++ b/appPublic/across_nat.py @@ -1,7 +1,7 @@ from traceback import print_exc from natpmp import NATPMP as pmp -import upnpy +import upnpclient from requests import get from .background import Background @@ -16,10 +16,9 @@ class AcrossNat(object): def init_upnp(self): try: - upnp = upnpy.UPnP() - igd = upnp.discover()[0] - s_names = [ n for n in igd.services.keys() if n.startswith('WANPPPConn') ] - self.upnp = igd.services[s_names[0]] + igd = upnpclient.discover()[0] + s_names = [ n for n in igd.service_map.keys() if 'WAN' in n and 'Conn' in n] + self.upnp = igd.service_map[s_names[0]] except Exception as e: print(e) print_exc() diff --git a/appPublic/jsonConfig.py b/appPublic/jsonConfig.py index 8e2eb82..c3e80b6 100644 --- a/appPublic/jsonConfig.py +++ b/appPublic/jsonConfig.py @@ -1,5 +1,6 @@ import os,sys import json +from pathlib import Path from appPublic.dictObject import DictObject from appPublic.Singleton import SingletonDecorator from appPublic.folderUtils import ProgramPath @@ -46,12 +47,21 @@ class JsonObject(DictObject): @SingletonDecorator class JsonConfig(JsonObject): pass + def getConfig(path=None,NS=None): + pp = ProgramPath() if path==None: - path = ProgramPath() + path = pp cfname = os.path.abspath(os.path.join(path,"conf","config.json")) # print __name__,cfname - a = JsonConfig(cfname,NS=NS) + ns = { + 'home':str(Path.home()), + 'workdir':path, + 'ProgramPath':pp + } + if NS is not None: + ns.update(NS) + a = JsonConfig(cfname,NS=ns) return a if __name__ == '__main__': diff --git a/requirements.txt b/requirements.txt index 073d368..00ae10c 100755 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ numpy cryptography brotli aiohttp -aioupnp +upnpclient py-natpmp asyncio requests