Skip to content

Add proxy support #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fedex/base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import suds
from suds.client import Client
from suds.plugin import MessagePlugin
from suds.plugin import MessagePlugin


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

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

self.VersionId = None
Expand Down
8 changes: 7 additions & 1 deletion fedex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FedexConfig(object):
"""

def __init__(self, key, password, account_number=None, meter_number=None, freight_account_number=None,
integrator_id=None, wsdl_path=None, express_region_code=None, use_test_server=False):
integrator_id=None, wsdl_path=None, express_region_code=None, use_test_server=False, proxy=None):
"""
@type key: L{str}
@param key: Developer test key.
Expand All @@ -48,6 +48,10 @@ def __init__(self, key, password, account_number=None, meter_number=None, freigh
instead of the production server. You will also need to make sure
that your L{FedexConfig} object has a production account number,
meter number, authentication key, and password.
@type proxy: L{str}
@keyword proxy: Enter your list of proxy servers int the format
proxy = {'http': "http://......:8080", 'https': "http://.......:8080", }
if needed.
"""
self.key = key
"""@ivar: Developer test key."""
Expand All @@ -65,6 +69,8 @@ def __init__(self, key, password, account_number=None, meter_number=None, freigh
"""@ivar: Web services ExpressRegionCode"""
self.use_test_server = use_test_server
"""@ivar: When True, point to the test server."""
self.proxy = proxy
"""@ivar: A list of proxy servers."""

# Allow overriding of the WDSL path.
if wsdl_path is None:
Expand Down
9 changes: 5 additions & 4 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def get_fedex_config():
"""
# Test server (Enter your credentials here)
return FedexConfig(key='',
password='',
account_number='',
meter_number='',
use_test_server=True)
password='',
account_number='',
meter_number='',
use_test_server=True,
proxy = None)