MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / autodetect

Method autodetect

service/settings.py:214–238  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

212
213 @staticmethod
214 def autodetect():
215
216 proxy = None
217 proxydict = urllib.request.ProxyHandler().proxies
218
219 validPrefixes = ("http", "https")
220
221 for prefix in validPrefixes:
222 if prefix not in proxydict:
223 continue
224 proxyline = proxydict[prefix]
225 proto_pos = proxyline.find('://')
226 if proto_pos != -1:
227 proxyline = proxyline[proto_pos+3:]
228 # sometimes proxyline contains "user:password@" section before proxy address
229 # remove it if present, so later split by ":" works
230 if '@' in proxyline:
231 userPass, proxyline = proxyline.split("@")
232 # TODO: do something with user/password?
233 proxAddr, proxPort = proxyline.split(":")
234 proxPort = int(proxPort.rstrip("/"))
235 proxy = (proxAddr, proxPort)
236 break
237
238 return proxy
239
240 def getProxySettings(self):
241

Callers 2

getProxySettingsMethod · 0.95
populatePanelMethod · 0.80

Calls 1

findMethod · 0.80

Tested by

no test coverage detected