Skip to content

Commit 63271d9

Browse files
authored
Merge pull request #115 from emleen/add-proxy-support
Add proxy support
2 parents cd1e5c7 + 06266d0 commit 63271d9

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

fedex/base_service.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import suds
1414
from suds.client import Client
15-
from suds.plugin import MessagePlugin
15+
from suds.plugin import MessagePlugin
1616

1717

1818
class GeneralSudsPlugin(MessagePlugin):
@@ -132,7 +132,7 @@ def __init__(self, config_obj, wsdl_name, *args, **kwargs):
132132
self.logger.info("Using production server.")
133133
self.wsdl_path = os.path.join(config_obj.wsdl_path, wsdl_name)
134134

135-
self.client = Client('file:///%s' % self.wsdl_path.lstrip('/'), plugins=[GeneralSudsPlugin()])
135+
self.client = Client('file:///%s' % self.wsdl_path.lstrip('/'), plugins=[GeneralSudsPlugin()], proxy=config_obj.proxy)
136136
# self.client.options.cache.clear() # Clear the cache, then re-init client when changing wsdl file.
137137

138138
self.VersionId = None

fedex/config.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class FedexConfig(object):
2121
"""
2222

2323
def __init__(self, key, password, account_number=None, meter_number=None, freight_account_number=None,
24-
integrator_id=None, wsdl_path=None, express_region_code=None, use_test_server=False):
24+
integrator_id=None, wsdl_path=None, express_region_code=None, use_test_server=False, proxy=None):
2525
"""
2626
@type key: L{str}
2727
@param key: Developer test key.
@@ -48,6 +48,10 @@ def __init__(self, key, password, account_number=None, meter_number=None, freigh
4848
instead of the production server. You will also need to make sure
4949
that your L{FedexConfig} object has a production account number,
5050
meter number, authentication key, and password.
51+
@type proxy: L{str}
52+
@keyword proxy: Enter your list of proxy servers int the format
53+
proxy = {'http': "http://......:8080", 'https': "http://.......:8080", }
54+
if needed.
5155
"""
5256
self.key = key
5357
"""@ivar: Developer test key."""
@@ -65,6 +69,8 @@ def __init__(self, key, password, account_number=None, meter_number=None, freigh
6569
"""@ivar: Web services ExpressRegionCode"""
6670
self.use_test_server = use_test_server
6771
"""@ivar: When True, point to the test server."""
72+
self.proxy = proxy
73+
"""@ivar: A list of proxy servers."""
6874

6975
# Allow overriding of the WDSL path.
7076
if wsdl_path is None:

tests/common.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def get_fedex_config():
1111
"""
1212
# Test server (Enter your credentials here)
1313
return FedexConfig(key='',
14-
password='',
15-
account_number='',
16-
meter_number='',
17-
use_test_server=True)
14+
password='',
15+
account_number='',
16+
meter_number='',
17+
use_test_server=True,
18+
proxy = None)

0 commit comments

Comments
 (0)