Skip to content

Commit

Permalink
Modifying vendored packages for App Engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Jan 22, 2015
1 parent 8d130ec commit 14bf5c5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 25 deletions.
2 changes: 1 addition & 1 deletion application/vendor/gcloud/datastore/helpers.py
Expand Up @@ -8,7 +8,7 @@
import datetime

from google.protobuf.internal.type_checkers import Int64ValueChecker
import pytz
from pytz.gae import pytz # Originally import pytz.
import six

from gcloud.datastore.entity import Entity
Expand Down
8 changes: 4 additions & 4 deletions application/vendor/gcloud/datastore/test_helpers.py
Expand Up @@ -128,7 +128,7 @@ def _callFUT(self, val):
def test_datetime_naive(self):
import calendar
import datetime
import pytz
from pytz.gae import pytz # Originally import pytz.

naive = datetime.datetime(2014, 9, 16, 10, 19, 32, 4375) # No zone.
utc = datetime.datetime(2014, 9, 16, 10, 19, 32, 4375, pytz.utc)
Expand All @@ -140,7 +140,7 @@ def test_datetime_naive(self):
def test_datetime_w_zone(self):
import calendar
import datetime
import pytz
from pytz.gae import pytz # Originally import pytz.

utc = datetime.datetime(2014, 9, 16, 10, 19, 32, 4375, pytz.utc)
name, value = self._callFUT(utc)
Expand Down Expand Up @@ -238,7 +238,7 @@ def _makePB(self, attr_name, value):
def test_datetime(self):
import calendar
import datetime
import pytz
from pytz.gae import pytz # Originally import pytz.

utc = datetime.datetime(2014, 9, 16, 10, 19, 32, 4375, pytz.utc)
micros = (calendar.timegm(utc.timetuple()) * 1000000) + 4375
Expand Down Expand Up @@ -341,7 +341,7 @@ def _makePB(self):
def test_datetime(self):
import calendar
import datetime
import pytz
from pytz.gae import pytz # Originally import pytz.

pb = self._makePB()
utc = datetime.datetime(2014, 9, 16, 10, 19, 32, 4375, pytz.utc)
Expand Down
2 changes: 1 addition & 1 deletion application/vendor/gcloud/storage/connection.py
Expand Up @@ -10,7 +10,7 @@
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
from OpenSSL import crypto
import pytz
from pytz.gae import pytz # Originally import pytz.

from gcloud.connection import Connection as _Base
from gcloud.storage import exceptions
Expand Down
4 changes: 2 additions & 2 deletions application/vendor/gcloud/storage/test_connection.py
Expand Up @@ -682,15 +682,15 @@ def test__get_expiration_w_naive_datetime(self):

def test__get_expiration_w_utc_datetime(self):
import datetime
import pytz
from pytz.gae import pytz # Originally import pytz.

expiration_utc = datetime.datetime(2004, 8, 19, 0, 0, 0, 0, pytz.utc)
utc_seconds = self._utc_seconds(expiration_utc)
self.assertEqual(self._callFUT(expiration_utc), utc_seconds)

def test__get_expiration_w_other_zone_datetime(self):
import datetime
import pytz
from pytz.gae import pytz # Originally import pytz.

zone = pytz.timezone('CET')
expiration_other = datetime.datetime(2004, 8, 19, 0, 0, 0, 0, zone)
Expand Down
18 changes: 1 addition & 17 deletions application/vendor/oauth2client/client.py
Expand Up @@ -930,23 +930,7 @@ def _detect_gce_environment(urlopen=None):
Boolean indicating whether or not the current environment is Google
Compute Engine.
"""
urlopen = urlopen or urllib.request.urlopen
# Note: the explicit `timeout` below is a workaround. The underlying
# issue is that resolving an unknown host on some networks will take
# 20-30 seconds; making this timeout short fixes the issue, but
# could lead to false negatives in the event that we are on GCE, but
# the metadata resolution was particularly slow. The latter case is
# "unlikely".
try:
response = urlopen('http://169.254.169.254/', timeout=1)
return response.info().get('Metadata-Flavor', '') == 'Google'
except socket.timeout:
logger.info('Timeout attempting to reach GCE metadata service.')
return False
except urllib.error.URLError as e:
if isinstance(getattr(e, 'reason', None), socket.timeout):
logger.info('Timeout attempting to reach GCE metadata service.')
return False
return False


def _get_environment(urlopen=None):
Expand Down

0 comments on commit 14bf5c5

Please sign in to comment.