summaryrefslogtreecommitdiff
path: root/boto/compat.py
diff options
context:
space:
mode:
Diffstat (limited to 'boto/compat.py')
-rw-r--r--boto/compat.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/boto/compat.py b/boto/compat.py
index 44fbc3b3..a13f58b4 100644
--- a/boto/compat.py
+++ b/boto/compat.py
@@ -19,6 +19,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
+import os
+
# This allows boto modules to say "from boto.compat import json". This is
# preferred so that all modules don't have to repeat this idiom.
@@ -26,3 +28,14 @@ try:
import simplejson as json
except ImportError:
import json
+
+
+# If running in Google App Engine there is no "user" and
+# os.path.expanduser() will fail. Attempt to detect this case and use a
+# no-op expanduser function in this case.
+try:
+ os.path.expanduser('~')
+ expanduser = os.path.expanduser
+except (AttributeError, ImportError):
+ # This is probably running on App Engine.
+ expanduser = (lambda x: x)