Skip to content

Commit c2106ff

Browse files
committed
redirect logging to stdout in examples
1 parent a739ffe commit c2106ff

11 files changed

+31
-21
lines changed

examples/address_validation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
class can handle up to 100 addresses for validation.
55
"""
66
import logging
7+
import sys
8+
79
from example_config import CONFIG_OBJ
810
from fedex.services.address_validation_service import FedexAddressValidationRequest
911

1012
# NOTE: TO USE ADDRESS VALIDATION SERVICES, YOU NEED TO REQUEST FEDEX TO ENABLE THIS SERVICE FOR YOUR ACCOUNT.
1113
# BY DEFAULT, THE SERVICE IS DISABLED AND YOU WILL RECEIVE AUTHENTICATION FAILED, 1000 RESPONSE.
1214

1315
# Set this to the INFO level to see the response from Fedex printed in stdout.
14-
logging.basicConfig(level=logging.INFO)
16+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
1517

1618
# This is the object that will be handling our avs request.
1719
# We're using the FedexConfig object from example_config.py in this dir.
@@ -47,7 +49,6 @@ class can handle up to 100 addresses for validation.
4749
address2.Address.CountryCode = 'US'
4850
avs_request.add_address(address2)
4951

50-
5152
# If you'd like to see some documentation on the ship service WSDL, un-comment
5253
# this line. (Spammy).
5354
# print(avs_request.client)

examples/create_freight_shipment.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@
99
label data that is returned with the reply.
1010
"""
1111
import logging
12+
import sys
1213
import binascii
14+
1315
from example_config import CONFIG_OBJ
1416
from fedex.services.ship_service import FedexProcessShipmentRequest
1517

1618
# What kind of file do you want this example to generate?
1719
# Valid choices for this example are PDF, PNG
1820
GENERATE_IMAGE_TYPE = 'PDF'
1921

20-
2122
# Set this to the INFO level to see the response from Fedex printed in stdout.
2223
# logging.basicConfig(filename="suds.log", level=logging.DEBUG)
23-
logging.basicConfig(level=logging.INFO)
24+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
2425

2526
# NOTE: A VALID 'freight_account_number' REQUIRED IN YOUR 'CONFIB_OBJ' FOR THIS SERVICE TO WORK.
2627
# OTHERWISE YOU WILL GET FEDEX FREIGHT OR ASSOCIATED ADDRESS IS REQUIRED, ERROR 3619.
@@ -87,7 +88,6 @@
8788
shipment.RequestedShipment.FreightShipmentDetail.Role = role.SHIPPER
8889
shipment.RequestedShipment.FreightShipmentDetail.CollectTermsType = 'STANDARD'
8990

90-
9191
# Specifies the label type to be returned.
9292
shipment.RequestedShipment.LabelSpecification.LabelFormatType = 'FEDEX_FREIGHT_STRAIGHT_BILL_OF_LADING'
9393

@@ -160,7 +160,6 @@
160160
amount = shipment.response.CompletedShipmentDetail.ShipmentRating.ShipmentRateDetails[0].TotalNetCharge.Amount
161161
print("Net Shipping Cost (US$): {}".format(amount))
162162

163-
164163
# # Get the label image in ASCII format from the reply. Note the list indices
165164
# we're using. You'll need to adjust or iterate through these if your shipment
166165
# has multiple packages.

examples/create_shipment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import logging
1111
import binascii
1212
import datetime
13+
import sys
1314

1415
from example_config import CONFIG_OBJ
1516
from fedex.services.ship_service import FedexProcessShipmentRequest
@@ -18,9 +19,8 @@
1819
# Valid choices for this example are PDF, PNG
1920
GENERATE_IMAGE_TYPE = 'PDF'
2021

21-
2222
# Set this to the INFO level to see the response from Fedex printed in stdout.
23-
logging.basicConfig(level=logging.INFO)
23+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
2424

2525
# This is the object that will be handling our shipment request.
2626
# We're using the FedexConfig object from example_config.py in this dir.

examples/delete_shipment.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
This example shows how to delete existing shipments.
44
"""
55
import logging
6+
import sys
7+
68
from example_config import CONFIG_OBJ
79
from fedex.services.ship_service import FedexDeleteShipmentRequest
810

911
# Set this to the INFO level to see the response from Fedex printed in stdout.
10-
logging.basicConfig(level=logging.INFO)
12+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
1113

1214
# This is the object that will be handling our request.
1315
# We're using the FedexConfig object from example_config.py in this dir.

examples/example_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66
import os
77
import sys
8+
89
# Use the fedex directory included in the downloaded package instead of
910
# any globally installed versions.
1011
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

examples/freight_rate_request.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
is Out of Delivery Area (ODA).
1010
"""
1111
import logging
12+
import sys
13+
1214
from example_config import CONFIG_OBJ
1315
from fedex.services.rate_service import FedexRateServiceRequest
1416

1517
# Set this to the INFO level to see the response from Fedex printed in stdout.
16-
logging.basicConfig(level=logging.INFO)
18+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
1719

1820
# This is the object that will be handling our request.
1921
# We're using the FedexConfig object from example_config.py in this dir.
@@ -29,7 +31,6 @@
2931

3032
rate_request.RequestedShipment.FreightShipmentDetail.FedExFreightAccountNumber = CONFIG_OBJ.freight_account_number
3133

32-
3334
# Shipper
3435
rate_request.RequestedShipment.Shipper.AccountNumber = CONFIG_OBJ.freight_account_number
3536
rate_request.RequestedShipment.Shipper.Contact.PersonName = 'Sender Name'

examples/location_request.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
88
"""
99
import logging
10+
import sys
11+
1012
from example_config import CONFIG_OBJ
1113
from fedex.services.location_service import FedexSearchLocationRequest
1214

1315
# Set this to the INFO level to see the response from Fedex printed in stdout.
14-
logging.basicConfig(level=logging.INFO)
15-
16+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
1617

1718
# This is the object that will be handling our request.
1819
# We're using the FedexConfig object from example_config.py in this dir.
@@ -50,4 +51,3 @@
5051

5152
# Here is the overall end result of the query.
5253
print("HighestSeverity:", location_request.response.HighestSeverity)
53-

examples/postal_inquiry.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
information about postal codes.
55
"""
66
import logging
7+
import sys
8+
79
from example_config import CONFIG_OBJ
810
from fedex.services.package_movement import PostalCodeInquiryRequest
911

1012
# Set this to the INFO level to see the response from Fedex printed in stdout.
11-
logging.basicConfig(level=logging.INFO)
13+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
1214

1315
# We're using the FedexConfig object from example_config.py in this dir.
1416
inquiry = PostalCodeInquiryRequest(CONFIG_OBJ)

examples/rate_request.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
is Out of Delivery Area (ODA).
1010
"""
1111
import logging
12+
import sys
13+
1214
from example_config import CONFIG_OBJ
1315
from fedex.services.rate_service import FedexRateServiceRequest
1416

1517
# Set this to the INFO level to see the response from Fedex printed in stdout.
16-
logging.basicConfig(level=logging.INFO)
17-
18+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
1819

1920
# This is the object that will be handling our request.
2021
# We're using the FedexConfig object from example_config.py in this dir.

examples/service_availability_request.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
exception thrown by suds.
88
"""
99
import logging
10+
import sys
1011
import datetime
12+
1113
from example_config import CONFIG_OBJ
1214
from fedex.services.availability_commitment_service import FedexAvailabilityCommitmentRequest
1315

1416
# Set this to the INFO level to see the response from Fedex printed in stdout.
15-
logging.basicConfig(level=logging.INFO)
16-
17+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
1718

1819
# This is the object that will be handling our service availability request.
1920
# We're using the FedexConfig object from example_config.py in this dir.
@@ -32,7 +33,7 @@
3233
# avc_request.Packaging = 'FEDEX_ENVELOPE'
3334

3435
# Can be set to the expected date. Defaults to today if not set.
35-
# avc_request.ShipDate = datetime.date.today().isoformat()
36+
avc_request.ShipDate = datetime.date.today().isoformat()
3637

3738
# Can be set to PRIORITY_OVERNIGHT, FEDEX_2_DAY, STANDARD_OVERNIGHT etc.. Defaults to showing all options if not set.
3839
# avc_request.Service = 'FEDEX_2_DAY'

0 commit comments

Comments
 (0)