14
14
# KIND, either express or implied. See the License for the
15
15
# specific language governing permissions and limitations
16
16
# under the License.
17
+
17
18
"""The Proxy implementation."""
18
19
20
+ import warnings
21
+
19
22
20
23
class ProxyTypeFactory :
21
24
"""Factory for proxy types."""
@@ -28,8 +31,8 @@ def make(ff_value, string):
28
31
class ProxyType :
29
32
"""Set of possible types of proxy.
30
33
31
- Each proxy type has 2 properties: 'ff_value' is value of Firefox
32
- profile preference, 'string' is id of proxy type.
34
+ Each proxy type has 2 properties: 'ff_value' is value of Firefox
35
+ profile preference, 'string' is id of proxy type.
33
36
"""
34
37
35
38
DIRECT = ProxyTypeFactory .make (0 , "DIRECT" ) # Direct connection, no proxy (default on Windows).
@@ -63,6 +66,14 @@ def __get__(self, obj, cls):
63
66
def __set__ (self , obj , value ):
64
67
if self .name == "autodetect" and not isinstance (value , bool ):
65
68
raise ValueError ("Autodetect proxy value needs to be a boolean" )
69
+ if self .name == "ftpProxy" :
70
+ # TODO: Remove ftpProxy in future version and remove deprecation warning
71
+ # https://github.com/SeleniumHQ/selenium/issues/15905
72
+ warnings .warn (
73
+ "ftpProxy is deprecated and will be removed in the future" ,
74
+ DeprecationWarning ,
75
+ stacklevel = 2 ,
76
+ )
66
77
getattr (obj , "_verify_proxy_type_compatibility" )(self .p_type )
67
78
setattr (obj , "proxyType" , self .p_type )
68
79
setattr (obj , self .name , value )
@@ -74,7 +85,7 @@ class Proxy:
74
85
75
86
proxyType = ProxyType .UNSPECIFIED
76
87
autodetect = False
77
- ftpProxy = ""
88
+ ftpProxy = "" # TODO: Remove ftpProxy in future version and remove deprecation warning
78
89
httpProxy = ""
79
90
noProxy = ""
80
91
proxyAutoconfigUrl = ""
@@ -100,6 +111,7 @@ class Proxy:
100
111
`value`: `str`
101
112
"""
102
113
114
+ # TODO: Remove ftpProxy in future version and remove deprecation warning
103
115
ftp_proxy = _ProxyTypeDescriptor ("ftpProxy" , ProxyType .MANUAL )
104
116
"""Gets and Sets `ftp_proxy`
105
117
@@ -244,7 +256,14 @@ def __init__(self, raw=None):
244
256
if raw :
245
257
if "proxyType" in raw and raw ["proxyType" ]:
246
258
self .proxy_type = ProxyType .load (raw ["proxyType" ])
259
+ # TODO: Remove ftpProxy in future version and remove deprecation warning
260
+ # https://github.com/SeleniumHQ/selenium/issues/15905
247
261
if "ftpProxy" in raw and raw ["ftpProxy" ]:
262
+ warnings .warn (
263
+ "ftpProxy is deprecated and will be removed in the future" ,
264
+ DeprecationWarning ,
265
+ stacklevel = 2 ,
266
+ )
248
267
self .ftp_proxy = raw ["ftpProxy" ]
249
268
if "httpProxy" in raw and raw ["httpProxy" ]:
250
269
self .http_proxy = raw ["httpProxy" ]
@@ -288,6 +307,7 @@ def _verify_proxy_type_compatibility(self, compatible_proxy):
288
307
289
308
def to_capabilities (self ):
290
309
proxy_caps = {"proxyType" : self .proxyType ["string" ].lower ()}
310
+ # TODO: Remove ftpProxy in future version and remove deprecation warning
291
311
proxies = [
292
312
"autodetect" ,
293
313
"ftpProxy" ,
0 commit comments