From 0877e8545179b074a486f7f287fce4064370adb3 Mon Sep 17 00:00:00 2001 From: "Miguel G. Flores" Date: Wed, 16 Dec 2020 17:10:32 +0100 Subject: [PATCH 1/5] Catch Exception from JSONDecodeError --- FuelSDK/client.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/FuelSDK/client.py b/FuelSDK/client.py index 1ebbfb8..4211427 100644 --- a/FuelSDK/client.py +++ b/FuelSDK/client.py @@ -380,16 +380,17 @@ def update_cache_file(self, url): def get_soap_endpoint(self): default_endpoint = 'https://webservice.exacttarget.com/Service.asmx' - cache_file_data = self.get_soap_cache_file() + try: + cache_file_data = self.get_soap_cache_file() - if 'url' in cache_file_data and 'timestamp' in cache_file_data \ - and cache_file_data['timestamp'] > time.time(): - return cache_file_data['url'] + if 'url' in cache_file_data and 'timestamp' in cache_file_data \ + and cache_file_data['timestamp'] > time.time(): + return cache_file_data['url'] - """ - find the correct url that data request web calls should go against for the token we have. - """ - try: + """ + find the correct url that data request web calls should go against for the token we have. + """ + r = requests.get(self.base_api_url + '/platform/v1/endpoints/soap', headers={ 'user-agent': 'FuelSDK-Python-v1.3.0', 'authorization': 'Bearer ' + self.authToken From c812a3468657f791f0ea13799650c396df8f20ee Mon Sep 17 00:00:00 2001 From: "Miguel G. Flores" Date: Wed, 16 Dec 2020 17:18:39 +0100 Subject: [PATCH 2/5] Move try except to soap call --- FuelSDK/client.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/FuelSDK/client.py b/FuelSDK/client.py index 4211427..e70f8d0 100644 --- a/FuelSDK/client.py +++ b/FuelSDK/client.py @@ -361,10 +361,14 @@ def create_payload(self): def get_soap_cache_file(self): json_data = {} - if os.path.isfile(self.soap_cache_file): - file = open(self.soap_cache_file, "r") - json_data = json.load(file) - file.close() + + try: + if os.path.isfile(self.soap_cache_file): + file = open(self.soap_cache_file, "r") + json_data = json.load(file) + file.close() + except Exception: + return json_data return json_data @@ -380,17 +384,16 @@ def update_cache_file(self, url): def get_soap_endpoint(self): default_endpoint = 'https://webservice.exacttarget.com/Service.asmx' - try: - cache_file_data = self.get_soap_cache_file() + cache_file_data = self.get_soap_cache_file() - if 'url' in cache_file_data and 'timestamp' in cache_file_data \ - and cache_file_data['timestamp'] > time.time(): - return cache_file_data['url'] + if 'url' in cache_file_data and 'timestamp' in cache_file_data \ + and cache_file_data['timestamp'] > time.time(): + return cache_file_data['url'] - """ - find the correct url that data request web calls should go against for the token we have. - """ - + """ + find the correct url that data request web calls should go against for the token we have. + """ + try: r = requests.get(self.base_api_url + '/platform/v1/endpoints/soap', headers={ 'user-agent': 'FuelSDK-Python-v1.3.0', 'authorization': 'Bearer ' + self.authToken From 0b99854719a56bea5368286e24b574f34db1652f Mon Sep 17 00:00:00 2001 From: jmartinezbernet Date: Wed, 16 Dec 2020 18:34:00 +0100 Subject: [PATCH 3/5] "Fixed indent, version increased" --- FuelSDK/client.py | 12 ++++++------ setup.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/FuelSDK/client.py b/FuelSDK/client.py index e70f8d0..f1d34ee 100644 --- a/FuelSDK/client.py +++ b/FuelSDK/client.py @@ -363,12 +363,12 @@ def get_soap_cache_file(self): json_data = {} try: - if os.path.isfile(self.soap_cache_file): - file = open(self.soap_cache_file, "r") - json_data = json.load(file) - file.close() - except Exception: - return json_data + if os.path.isfile(self.soap_cache_file): + file = open(self.soap_cache_file, "r") + json_data = json.load(file) + file.close() + except Exception: + return json_data return json_data diff --git a/setup.py b/setup.py index 8fd47cd..c36c79d 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ readme = f.read() setup( - version='1.3.0', + version='1.3.1', name='Salesforce-FuelSDK', description='Salesforce Marketing Cloud Fuel SDK for Python', long_description=readme, From 8f83adbcfe843f5a27810dce26c302bbec4a678a Mon Sep 17 00:00:00 2001 From: jmartinezbernet Date: Wed, 16 Dec 2020 18:38:51 +0100 Subject: [PATCH 4/5] Changed setup to allow use the repo as requirement for other fever projects --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index c36c79d..732303b 100644 --- a/setup.py +++ b/setup.py @@ -5,14 +5,14 @@ setup( version='1.3.1', - name='Salesforce-FuelSDK', - description='Salesforce Marketing Cloud Fuel SDK for Python', + name='Fever-FuelSDK', + description='Fever Salesforce Marketing Cloud Fuel SDK for Python', long_description=readme, long_description_content_type="text/markdown", author='ExactTarget', py_modules=['ET_Client'], packages=['FuelSDK'], - url='https://github.com/salesforce-marketingcloud/FuelSDK-Python', + url='https://github.com/Feverup/FuelSDK-Python', license='MIT', install_requires=[ 'pyjwt>=1.5.3', From 7aeeef3c850719812d8cc75387332e7067a3de64 Mon Sep 17 00:00:00 2001 From: Miguel Gamallo Date: Mon, 1 Feb 2021 11:59:39 +0100 Subject: [PATCH 5/5] Change author and first lines of README (for PyPi) --- README.md | 2 +- setup.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b4e61a0..38c3295 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # FuelSDK-Python v1.3.0 -Salesforce Marketing Cloud Fuel SDK for Python +Feverup's fork of Salesforce Marketing Cloud Fuel SDK for Python ## Overview diff --git a/setup.py b/setup.py index 732303b..79c3d08 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ description='Fever Salesforce Marketing Cloud Fuel SDK for Python', long_description=readme, long_description_content_type="text/markdown", - author='ExactTarget', + author='Feverup', py_modules=['ET_Client'], packages=['FuelSDK'], url='https://github.com/Feverup/FuelSDK-Python', @@ -27,4 +27,4 @@ 'Topic :: Software Development :: Libraries', 'Programming Language :: Python :: 3.3', ], -) \ No newline at end of file +)