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 """ |
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(). |