8000 added environ var FUELSDK_WSDL_FILE_LOCAL_LOC to specify path/file to… · yurib/FuelSDK-Python@8601135 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8601135

Browse files
author
Randy Shults
committed
added environ var FUELSDK_WSDL_FILE_LOCAL_LOC to specify path/file to use in place of default ExactTargetWSDL.xml location. Needed when running multiple instances on same server that connect to different wsdl endpoints (s4 vs s6 vs etc).
1 parent 54fe66c commit 8601135

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

FuelSDK/client.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,24 @@ def __init__(self, get_server_wsdl = False, debug = False, params = None):
8181

8282
if params is not None and 'authenticationurl' in params:
8383
self.auth_url = params['authenticationurl']
84-
if config.has_option('Web Services', 'authenticationurl'):
84+
elif config.has_option('Web Services', 'authenticationurl'):
8585
self.auth_url = config.get('Web Services', 'authenticationurl')
8686
elif 'FUELSDK_AUTH_URL' in os.environ:
8787
self.auth_url = os.environ['FUELSDK_AUTH_URL']
8888
else:
8989
self.auth_url = 'https://auth.exacttargetapis.com/v1/requestToken?legacy=1'
9090

91-
self.wsdl_file_url = self.load_wsdl(wsdl_server_url, get_server_wsdl)
92-
91+
if params is not None and "wsdl_file_local_loc" in params:
92+
wsdl_file_local_location = params["wsdl_file_local_loc"]
93+
elif config.has_option("Web Services", "wsdl_file_local_loc"):
94+
wsdl_file_local_location = config.get("Web Services", "wsdl_file_local_loc")
95+
elif "FUELSDK_WSDL_FILE_LOCAL_LOC" in os.environ:
96+
wsdl_file_local_location = os.environ["FUELSDK_WSDL_FILE_LOCAL_LOC"]
97+
else:
98+
wsdl_file_local_location = None
99+
100+
self.wsdl_file_url = self.load_wsdl(wsdl_server_url, wsdl_file_local_location, get_server_wsdl)
101+
93102
## get the JWT from the params if passed in...or go to the server to get it
94103
if(params is not None and 'jwt' in params):
95104
decodedJWT = jwt.decode(params['jwt'], self.appsignature)
@@ -104,17 +113,20 @@ def __init__(self, get_server_wsdl = False, debug = False, params = None):
104113
self.refresh_token()
105114

106115

107-
def load_wsdl(self, wsdl_url, get_server_wsdl = False):
116+
def load_wsdl(self, wsdl_url, wsdl_file_local_location, get_server_wsdl = False):
108117
"""
109118
retrieve the url of the ExactTarget wsdl...either file: or http:
110119
depending on if it already exists locally or server flag is set and
111120
server has a newer copy
112121
"""
113-
path = os.path.dirname(os.path.abspath(__file__))
114-
file_location = os.path.join(path, 'ExactTargetWSDL.xml')
122+
if wsdl_file_local_location is not None:
123+
file_location = wsdl_file_local_location
124+
else:
125+
path = os.path.dirname(os.path.abspath(__file__))
126+
file_location = os.path.join(path, 'ExactTargetWSDL.xml')
115127
file_url = 'file:///' + file_location
116128

117-
if not os.path.exists(file_location): #if there is no local copy then go get it...
129+
if not os.path.exists(file_location) or os.path.getsize(file_location) == 0: #if there is no local copy or local copy is empty then go get it...
118130
self.retrieve_server_wsdl(wsdl_url, file_location)
119131
elif get_server_wsdl:
120132
r = requests.head(wsdl_url)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ You must configure your access tokens and details for the Fuel SDK in one of the
2727
* `FUELSDK_APP_SIGNATURE`
2828
* `FUELSDK_DEFAULT_WSDL`
2929
* `FUELSDK_AUTH_URL`
30+
* `FUELSDK_WSDL_FILE_LOCAL_LOC`
3031

3132
Edit `config.python` or declare environment variables so you can input the ClientID and Client Secret values provided when you registered your application. If you are building a HubExchange application for the Interactive Marketing Hub then, you must also provide the Application Signature (`appsignature` / `FUELSDK_APP_SIGNATURE`).
3233
The `defaultwsdl` / `FUELSDK_DEFAULT_WSDL` configuration must be [changed depending on the ExactTarget service](https://code.exacttarget.com/question/there-any-cetificrate-install-our-server-access-et-api "ExactTarget Forum").
3334
The `authenticationurl` / `FUELSDK_AUTH_URL` must also be [changed depending on service](https://code.exacttarget.com/question/not-able-create-accesstoken-when-clientidsecret-associated-preproduction-account "ExactTarget Forum").
35+
The `wsdl_file_local_loc` / `FUELSDK_WSDL_FILE_LOCAL_LOC` allows you to specify the full path/filename where the WSDL file will be located on disk, if for instance you are connecting to different endpoints from the same server.
3436

3537
If you have not registered your application or you need to lookup your Application Key or Application Signature values, please go to App Center at [Code@: ExactTarget's Developer Community](http://code.exacttarget.com/appcenter "Code@ App Center").
3638

config.python.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ appsignature: none
33
clientid: XXXXXXXXXXXXXXXXXXXXXXXX
44
clientsecret: XXXXXXXXXXXXXXXXXXXXXXXX
55
defaultwsdl: https://webservice.exacttarget.com/etframework.wsdl
6-
authenticationurl: https://auth.exacttargetapis.com/v1/requestToken?legacy=1
6+
authenticationurl: https://auth.exacttargetapis.com/v1/requestToken?legacy=1
7+
wsdl_file_local_loc: /tmp/ExactTargetWSDL.s6.xml

0 commit comments

Comments
 (0)
0