src/eric7/DebugClients/Python/DebugClientBase.py

branch
eric7
changeset 11001
ca835b2c0f53
parent 10704
27d21e5163b8
child 11025
7f78b3d0d88f
equal deleted inserted replaced
11000:f8371a2dd08f 11001:ca835b2c0f53
2040 0 2040 0
2041 if version.startswith("i") 2041 if version.startswith("i")
2042 else (socket.AF_INET if version == "v4" else socket.AF_INET6) 2042 else (socket.AF_INET if version == "v4" else socket.AF_INET6)
2043 ) 2043 )
2044 2044
2045 with contextlib.suppress(OSError): 2045 try:
2046 addrinfo = socket.getaddrinfo(host, None, family, socket.SOCK_STREAM) 2046 addrinfo = socket.getaddrinfo(host, None, family, socket.SOCK_STREAM)
2047 return addrinfo[0][4][0] 2047 return addrinfo[0][4][0]
2048 except OSError:
2049 # Did not resolve via this method. Return the host name and let Python3
2050 # try when connecting.
2051 return host
2048 2052
2049 return None 2053 return None
2050 2054
2051 def main(self): 2055 def main(self):
2052 """ 2056 """
2066 codeStr = "" 2070 codeStr = ""
2067 scriptModule = "" 2071 scriptModule = ""
2068 while args[0]: 2072 while args[0]:
2069 if args[0] == "-h": 2073 if args[0] == "-h":
2070 host = args[1] 2074 host = args[1]
2071 del args[0] 2075 del args[:2]
2072 del args[0]
2073 elif args[0] == "-p": 2076 elif args[0] == "-p":
2074 port = int(args[1]) 2077 port = int(args[1])
2075 del args[0] 2078 del args[:2]
2076 del args[0]
2077 elif args[0] == "-w": 2079 elif args[0] == "-w":
2078 wd = args[1] 2080 wd = args[1]
2079 del args[0] 2081 del args[:2]
2080 del args[0]
2081 elif args[0] == "-t": 2082 elif args[0] == "-t":
2082 tracePython = True 2083 tracePython = True
2083 del args[0] 2084 del args[0]
2084 elif args[0] == "-n": 2085 elif args[0] == "-n":
2085 redirect = False 2086 redirect = False
2099 elif args[0] == "--call-trace-optimization": 2100 elif args[0] == "--call-trace-optimization":
2100 callTraceOptimization = True 2101 callTraceOptimization = True
2101 del args[0] 2102 del args[0]
2102 elif args[0] in ("-c", "--code"): 2103 elif args[0] in ("-c", "--code"):
2103 codeStr = args[1] 2104 codeStr = args[1]
2104 del args[0] 2105 del args[:2]
2105 del args[0]
2106 elif args[0] in ("-m", "--module"): 2106 elif args[0] in ("-m", "--module"):
2107 scriptModule = args[1] 2107 scriptModule = args[1]
2108 del args[0] 2108 del args[:2]
2109 del args[0]
2110 elif args[0] == "--": 2109 elif args[0] == "--":
2111 del args[0] 2110 del args[0]
2112 break 2111 break
2113 else: # unknown option 2112 else: # unknown option
2114 del args[0] 2113 del args[0]
2182 if ":" in ipOrHost or ipOrHost[0] in "0123456789": 2181 if ":" in ipOrHost or ipOrHost[0] in "0123456789":
2183 # IPv6 address or IPv4 address 2182 # IPv6 address or IPv4 address
2184 remoteAddress = ipOrHost 2183 remoteAddress = ipOrHost
2185 else: 2184 else:
2186 remoteAddress = self.__resolveHost(ipOrHost) 2185 remoteAddress = self.__resolveHost(ipOrHost)
2186 if remoteAddress is None:
2187 print(f"Remote host '{ipOrHost}' could not be resolved.") # noqa: M801
2188 sys.exit(1)
2187 2189
2188 sys.argv = [""] 2190 sys.argv = [""]
2189 if "" not in sys.path: 2191 if "" not in sys.path:
2190 sys.path.insert(0, "") 2192 sys.path.insert(0, "")
2191 2193
2204 self.__coding = self.defaultCoding 2206 self.__coding = self.defaultCoding
2205 patchNewProcessFunctions(self.multiprocessSupport, self) 2207 patchNewProcessFunctions(self.multiprocessSupport, self)
2206 self.connectDebugger(port, remoteAddress, redirect) 2208 self.connectDebugger(port, remoteAddress, redirect)
2207 self.__interact() 2209 self.__interact()
2208 else: 2210 else:
2209 print("No network port given. Aborting...") 2211 print("No network port given. Aborting...") # noqa: M801
2210 # __IGNORE_WARNING_M801__ 2212 sys.exit(2)
2211 2213
2212 def close(self, fd): 2214 def close(self, fd):
2213 """ 2215 """
2214 Public method implementing a close method as a replacement for 2216 Public method implementing a close method as a replacement for
2215 os.close(). 2217 os.close().

eric ide

mercurial