diff --git a/examples/create_shipment.py b/examples/create_shipment.py index 99f17d0..5e18817 100755 --- a/examples/create_shipment.py +++ b/examples/create_shipment.py @@ -88,13 +88,12 @@ # See documentation for paper types, there quite a few. shipment.RequestedShipment.LabelSpecification.LabelStockType = 'PAPER_7X4.75' -# This indicates if the top or bottom of the label comes out of the -# printer first. -# BOTTOM_EDGE_OF_TEXT_FIRST or TOP_EDGE_OF_TEXT_FIRST # Timestamp in YYYY-MM-DDThh:mm:ss format, e.g. 2002-05-30T09:00:00 shipment.RequestedShipment.ShipTimestamp = datetime.datetime.now().replace(microsecond=0).isoformat() -# BOTTOM_EDGE_OF_TEXT_FIRST, TOP_EDGE_OF_TEXT_FIRST +# This indicates if the top or bottom of the label comes out of the +# printer first. +# BOTTOM_EDGE_OF_TEXT_FIRST or TOP_EDGE_OF_TEXT_FIRST shipment.RequestedShipment.LabelSpecification.LabelPrintingOrientation = 'TOP_EDGE_OF_TEXT_FIRST' # Delete the flags we don't want. diff --git a/examples/track_shipment.py b/examples/track_shipment.py index c393050..1fc4b7d 100755 --- a/examples/track_shipment.py +++ b/examples/track_shipment.py @@ -57,7 +57,7 @@ # This will dump the response data dict to json. # from fedex.tools.conversion import sobject_to_json -# print(basic_sobject_to_dict(track.response)) +# print(sobject_to_json(track.response)) # Look through the matches (there should only be one for a tracking number # query), and show a few details about each shipment. @@ -66,12 +66,13 @@ print("Tracking #: {}".format(match.TrackingNumber)) if hasattr(match, 'TrackingNumberUniqueIdentifier'): print("Tracking # UniqueID: {}".format(match.TrackingNumberUniqueIdentifier)) - if hasattr(match, 'StatusDetail.Description'): - print("Status Description: {}".format(match.StatusDetail.Description)) - if hasattr(match, 'StatusDetail.AncillaryDetails'): - print("Status AncillaryDetails Reason: {}".format(match.StatusDetail.AncillaryDetails[-1].Reason)) - print("Status AncillaryDetails Description: {}" - "".format(match.StatusDetail.AncillaryDetails[-1].ReasonDescription)) + if hasattr(match, 'StatusDetail'): + if hasattr(getattr(match, 'StatusDetail'), 'Description'): + print("Status Description: {}".format(match.StatusDetail.Description)) + if hasattr(getattr(match, 'StatusDetail'), 'AncillaryDetails'): + print("Status AncillaryDetails Reason: {}".format(match.StatusDetail.AncillaryDetails[-1].Reason)) + print("Status AncillaryDetails Description: {}" + "".format(match.StatusDetail.AncillaryDetails[-1].ReasonDescription)) if hasattr(match, 'ServiceCommitMessage'): print("Commit Message: {}".format(match.ServiceCommitMessage)) if hasattr(match, 'Notification'):