Skip to content

Commit d539fa9

Browse files
committed
added logging, trigger warning log on WARNING and NOTE
1 parent 660cb47 commit d539fa9

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

fedex/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@
5252
our U{Github project<http://github.com/gtaylor/python-fedex/>} and enter
5353
an issue in the U{Issue Tracker<http://github.com/gtaylor/python-fedex/issues>}.
5454
"""
55-
VERSION = __version__ = '2.3.0'
55+
VERSION = __version__ = '2.3.1'

fedex/base_service.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,27 @@
1616

1717

1818
class GeneralSudsPlugin(MessagePlugin):
19+
"""
20+
General Suds Plugin: Adds logging request and response functionality
21+
and prunes empty WSDL objects before sending.
22+
"""
23+
1924
def __init__(self, **kwargs):
25+
"""Initializes the request and response loggers."""
2026
self.request_logger = logging.getLogger('fedex.request')
2127
self.response_logger = logging.getLogger('fedex.response')
2228
self.kwargs = kwargs
2329

2430
def marshalled(self, context):
25-
# Removes the WSDL objects that do not have a value before sending.
31+
"""Removes the WSDL objects that do not have a value before sending."""
2632
context.envelope = context.envelope.prune()
2733

2834
def sending(self, context):
35+
"""Logs the sent request."""
2936
self.request_logger.info("FedEx Request {}".format(context.envelope))
3037

3138
def received(self, context):
39+
"""Logs the received response."""
3240
self.response_logger.info("FedEx Response {}".format(context.reply))
3341

3442

@@ -263,9 +271,9 @@ def _check_response_for_request_warnings(self):
263271
on postal code in a Rate Service request.
264272
"""
265273

266-
if self.response.HighestSeverity == "NOTE":
274+
if self.response.HighestSeverity in ("NOTE", "WARNING"):
267275
for notification in self.response.Notifications:
268-
if notification.Severity == "NOTE":
276+
if notification.Severity in ("NOTE", "WARNING"):
269277
self.logger.warning(FedexFailure(notification.Code,
270278
notification.Message))
271279

@@ -326,6 +334,6 @@ def send_request(self, send_function=None):
326334
# This method can be overridden by a method on the child class object.
327335
self._check_response_for_request_warnings()
328336

329-
# Debug output.
337+
# Debug output. (See Request and Response output)
330338
self.logger.debug("== FEDEX QUERY RESULT ==")
331339
self.logger.debug(self.response)

fedex/services/availability_commitment_service.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self, config_obj, *args, **kwargs):
3232
}
3333

3434
self.CarrierCode = None
35-
"""ivar: Carrier Code Default to Fedex (FDXE), or can bbe FDXG."""
35+
"""@ivar: Carrier Code Default to Fedex (FDXE), or can bbe FDXG."""
3636

3737
self.Origin = None
3838
"""@ivar: Holds Origin Address WSDL object."""
@@ -65,7 +65,8 @@ def _prepare_wsdl_objects(self):
6565
Create the data structure and get it ready for the WSDL request.
6666
"""
6767
self.CarrierCode = 'FDXE'
68-
self.Origin = self.Destination = self.client.factory.create('Address')
68+
self.Origin = self.client.factory.create('Address')
69+
self.Destination = self.client.factory.create('Address')
6970
self.ShipDate = datetime.date.today().isoformat()
7071
self.Service = None
7172
self.Packaging = 'YOUR_PACKAGING'

fedex/services/country_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def __init__(self, config_obj, *args, **kwargs):
3333
}
3434

3535
self.CarrierCode = None
36-
"""ivar: Carrier Code Default to Fedex (FDXE), or can bbe FDXG."""
36+
"""@ivar: Carrier Code Default to Fedex (FDXE), or can bbe FDXG."""
3737

3838
self.RoutingCode = None
39-
"""ivar: Routing Code Default to FDSD."""
39+
"""@ivar: Routing Code Default to FDSD."""
4040

4141
self.Address = None
4242
"""@ivar: Holds Address WSDL objects."""

fedex/tools/conversion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def basic_sobject_to_dict(obj):
5353

5454
def sobject_to_dict(obj, key_to_lower=False, json_serialize=False):
5555
"""
56-
Converts a suds object to a dict.
56+
Converts a suds object to a dict. Includes advanced features.
5757
:param json_serialize: If set, changes date and time types to iso string.
5858
:param key_to_lower: If set, changes index key name to lower case.
5959
:param obj: suds object
@@ -83,7 +83,7 @@ def sobject_to_dict(obj, key_to_lower=False, json_serialize=False):
8383

8484
def sobject_to_json(obj, key_to_lower=False):
8585
"""
86-
Converts a suds object to json.
86+
Converts a suds object to a JSON string.
8787
:param obj: suds object
8888
:param key_to_lower: If set, changes index key name to lower case.
8989
:return: json object

0 commit comments

Comments
 (0)