MCPcopy
hub / github.com/mvdctop/Movie_Data_Capture / IniProxy

Class IniProxy

config.py:585–620  ·  view source on GitHub ↗

Proxy Config from .ini

Source from the content-addressed store, hash-verified

583
584
585class IniProxy():
586 """ Proxy Config from .ini
587 """
588 SUPPORT_PROXY_TYPE = ("http", "socks5", "socks5h")
589
590 enable = False
591 address = ""
592 timeout = 5
593 retry = 3
594 proxytype = "socks5"
595
596 def __init__(self, switch, address, timeout, retry, proxytype) -> None:
597 """ Initial Proxy from .ini
598 """
599 if switch == '1' or switch == 1:
600 self.enable = True
601 self.address = address
602 self.timeout = timeout
603 self.retry = retry
604 self.proxytype = proxytype
605
606 def proxies(self):
607 """
608 获得代理参数,默认http代理
609 get proxy params, use http proxy for default
610 """
611 if self.address:
612 if self.proxytype in self.SUPPORT_PROXY_TYPE:
613 proxies = {"http": self.proxytype + "://" + self.address,
614 "https": self.proxytype + "://" + self.address}
615 else:
616 proxies = {"http": "http://" + self.address, "https": "https://" + self.address}
617 else:
618 proxies = {}
619
620 return proxies
621
622
623if __name__ == "__main__":

Callers 1

proxyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected