@@ -39,7 +39,7 @@ def get_proxy_settings(url: str | None = None) -> dict:
39
39
"""Retrieves network proxy settings from operating system configuration or
40
40
environment variables.
41
41
Args:
42
- url (str): url for request in case of PAC file use
42
+ url (str, optional ): url for request in case of PAC file use
43
43
Returns:
44
44
dict: proxy settings with protocl as key and URL as value
45
45
"""
@@ -54,6 +54,23 @@ def get_proxy_settings(url: str | None = None) -> dict:
54
54
"Proxies settings from custom QDT in environment vars (QDT_PROXY_HTTP): "
55
55
f"{ proxy_settings } "
56
56
)
57
+ elif qdt_pac_file := environ .get ("QDT_PAC_FILE" ):
58
+ if pac := load_pac_file_from_environment_variable (qdt_pac_file = qdt_pac_file ):
59
+ proxy_settings = get_proxy_settings_from_pac_file (url = url , pac = pac )
60
+ logger .info (
61
+ f"Proxies settings from environment vars PAC file: { environ .get ('QDT_PAC_FILE' )} "
62
+ f"{ proxy_settings } "
63
+ )
64
+ else :
65
+ logger .warning (
66
+ f"Invalid PAC file from environment vars PAC file : { environ .get ('QDT_PAC_FILE' )} . No proxy use."
67
+ )
68
+ elif pac := get_pac ():
69
+ proxy_settings = get_proxy_settings_from_pac_file (url = url , pac = pac )
70
+ logger .info ("Proxies settings from system PAC file: " f"{ proxy_settings } " )
71
+ elif getproxies ():
72
+ proxy_settings = getproxies ()
73
+ logger .debug (f"Proxies settings found in the OS: { proxy_settings } " )
57
74
elif environ .get ("HTTP_PROXY" ) or environ .get ("HTTPS_PROXY" ):
58
75
if environ .get ("HTTP_PROXY" ) and environ .get ("HTTPS_PROXY" ):
59
76
proxy_settings = {
@@ -80,23 +97,6 @@ def get_proxy_settings(url: str | None = None) -> dict:
80
97
"Proxies settings from generic environment vars (HTTPS_PROXY only): "
81
98
f"{ proxy_settings } "
82
99
)
83
- elif qdt_pac_file := environ .get ("QDT_PAC_FILE" ):
84
- if pac := load_pac_file_from_environment_variable (qdt_pac_file = qdt_pac_file ):
85
- proxy_settings = get_proxy_settings_from_pac_file (url = url , pac = pac )
86
- logger .info (
87
- f"Proxies settings from environment vars PAC file: { environ .get ('QDT_PAC_FILE' )} "
88
- f"{ proxy_settings } "
89
- )
90
- else :
91
- logger .warning (
92
- f"Invalid PAC file from environment vars PAC file : { environ .get ('QDT_PAC_FILE' )} . No proxy use."
93
- )
94
- elif getproxies ():
95
- proxy_settings = getproxies ()
96
- logger .debug (f"Proxies settings found in the OS: { proxy_settings } " )
97
- elif pac := get_pac ():
98
- proxy_settings = get_proxy_settings_from_pac_file (url = url , pac = pac )
99
- logger .info ("Proxies settings from system PAC file: " f"{ proxy_settings } " )
100
100
else :
101
101
logger .debug (
102
102
"No proxy settings found in environment vars nor OS settings nor PAC File."
0 commit comments