1# Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved 2# 3# Permission is hereby granted, free of charge, to any person obtaining a 4# copy of this software and associated documentation files (the 5# "Software"), to deal in the Software without restriction, including 6# without limitation the rights to use, copy, modify, merge, publish, dis- 7# tribute, sublicense, and/or sell copies of the Software, and to permit 8# persons to whom the Software is furnished to do so, subject to the fol- 9# lowing conditions: 10# 11# The above copyright notice and this permission notice shall be included 12# in all copies or substantial portions of the Software. 13# 14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20# IN THE SOFTWARE. 21# 22import os 23 24# This allows boto modules to say "from boto.compat import json". This is 25# preferred so that all modules don't have to repeat this idiom. 26try: 27 import simplejson as json 28except ImportError: 29 import json 30 31 32# Switch to use encodebytes, which deprecates encodestring in Python 3 33try: 34 from base64 import encodebytes 35except ImportError: 36 from base64 import encodestring as encodebytes 37 38 39# If running in Google App Engine there is no "user" and 40# os.path.expanduser() will fail. Attempt to detect this case and use a 41# no-op expanduser function in this case. 42try: 43 os.path.expanduser('~') 44 expanduser = os.path.expanduser 45except (AttributeError, ImportError): 46 # This is probably running on App Engine. 47 expanduser = (lambda x: x) 48 49from boto.vendored import six 50 51from boto.vendored.six import BytesIO, StringIO 52from boto.vendored.six.moves import filter, http_client, map, _thread, \ 53 urllib, zip 54from boto.vendored.six.moves.queue import Queue 55from boto.vendored.six.moves.urllib.parse import parse_qs, quote, unquote, \ 56 urlparse, urlsplit 57from boto.vendored.six.moves.urllib.request import urlopen 58 59if six.PY3: 60 # StandardError was removed, so use the base exception type instead 61 StandardError = Exception 62 long_type = int 63 from configparser import ConfigParser 64else: 65 StandardError = StandardError 66 long_type = long 67 from ConfigParser import SafeConfigParser as ConfigParser 68