14
14
__author__ = 'EasyPost <oss@easypost.com>'
15
15
__version__ = VERSION
16
16
version_info = VERSION_INFO
17
+ SUPPORT_EMAIL = 'support@easypost.com'
17
18
18
19
19
20
# use urlfetch as request_lib on google app engine, otherwise use requests
35
36
except ImportError :
36
37
raise ImportError ('EasyPost requires an up to date requests library. '
37
38
'Update requests via "pip install -U requests" or '
38
- 'contact us at support@easypost.com.' )
39
+ 'contact us at {}.' . format ( SUPPORT_EMAIL ) )
39
40
40
41
try :
41
42
version = requests .__version__
42
43
major , minor , patch = [int (i ) for i in version .split ('.' )]
43
44
except Exception :
44
45
raise ImportError ('EasyPost requires an up to date requests library. '
45
46
'Update requests via "pip install -U requests" or contact '
46
- 'us at support@easypost.com.' )
47
+ 'us at {}.' . format ( SUPPORT_EMAIL ) )
47
48
else :
48
49
if major < 1 :
49
50
raise ImportError ('EasyPost requires an up to date requests library. Update '
50
51
'requests via "pip install -U requests" or contact us '
51
- 'at support@easypost.com.' )
52
+ 'at {}.' . format ( SUPPORT_EMAIL ) )
52
53
53
54
# config
54
55
api_key = None
@@ -276,7 +277,7 @@ def request_raw(self, method, url, params=None, apiKeyRequired=True):
276
277
raise Error (
277
278
'No API key provided. Set an API key via "easypost.api_key = \' APIKEY\' . '
278
279
'Your API keys can be found in your EasyPost dashboard, or you can email us '
279
- 'at support@easypost.com for assistance.' )
280
+ 'at {} for assistance.' . format ( SUPPORT_EMAIL ) )
280
281
281
282
abs_url = self .api_url (url )
282
283
params = self ._objects_to_ids (params )
@@ -314,8 +315,8 @@ def request_raw(self, method, url, params=None, apiKeyRequired=True):
314
315
elif request_lib == 'requests' :
315
316
http_body , http_status = self .requests_request (method , abs_url , headers , params )
316
317
else :
317
- raise Error ("Bug discovered: invalid request_lib: %s . "
318
- "Please report to support@easypost.com." % request_lib )
318
+ raise Error ("Bug discovered: invalid request_lib: {} . "
319
+ "Please report to {}." . format ( request_lib , SUPPORT_EMAIL ) )
319
320
320
321
return http_body , http_status , my_api_key
321
322
@@ -337,8 +338,8 @@ def requests_request(self, method, abs_url, headers, params):
337
338
elif method == 'post' or method == 'put' :
338
339
data = self .encode (params )
339
340
else :
340
- raise Error ("Bug discovered: invalid request method: %s . "
341
- "Please report to support@easypost.com." % method )
341
+ raise Error ("Bug discovered: invalid request method: {} . "
342
+ "Please report to {}." . format ( method , SUPPORT_EMAIL ) )
342
343
343
344
try :
344
345
result = requests_session .request (
@@ -353,7 +354,7 @@ def requests_request(self, method, abs_url, headers, params):
353
354
http_status = result .status_code
354
355
except Exception as e :
355
356
raise Error ("Unexpected error communicating with EasyPost. If this "
356
- "problem persists please let us know at support@easypost.com." ,
357
+ "problem persists please let us know at {}." . format ( SUPPORT_EMAIL ) ,
357
358
original_exception = e )
358
359
return http_body , http_status
359
360
@@ -364,8 +365,8 @@ def urlfetch_request(self, method, abs_url, headers, params):
364
365
elif method == 'get' or method == 'delete' :
365
366
abs_url = self .build_url (abs_url , params )
366
367
else :
367
- raise Error ("Bug discovered: invalid request method: %s . Please report "
368
- "to support@easypost.com." % method )
368
+ raise Error ("Bug discovered: invalid request method: {} . Please report "
369
+ "to {}." . format ( method , SUPPORT_EMAIL ) )
369
370
370
371
args ['url' ] = abs_url
371
372
args ['method' ] = method
@@ -377,7 +378,7 @@ def urlfetch_request(self, method, abs_url, headers, params):
377
378
result = urlfetch .fetch (** args )
378
379
except Exception as e :
379
380
raise Error ("Unexpected error communicating with EasyPost. "
380
- "If this problem persists, let us know at support@easypost.com." ,
381
+ "If this problem persists, let us know at {}." . format ( SUPPORT_EMAIL ) ,
381
382
original_exception = e )
382
383
383
384
return result .content , result .status_code
0 commit comments