Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions python/src/cloudstorage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@



from .api_utils import RetryParams
from .api_utils import set_default_retry_params
from cloudstorage_api import *
from .cloudstorage_api import *
from .api_utils import *
from .common import CSFileStat
from .common import GCSFileStat
from .common import validate_bucket_name
from .common import validate_bucket_path
from .common import validate_file_path
from errors import *
from storage_api import *
from .errors import *
from .storage_api import *
7 changes: 5 additions & 2 deletions python/src/cloudstorage/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
]

import copy
import httplib
try:
import httplib
except ImportError:
import http.client as httplib
import logging
import math
import os
Expand Down Expand Up @@ -170,7 +173,7 @@ def run(self, tasklet, **kwds):
'Tasklet has exceeded request deadline after %s seconds total',
time.time() - start_time)
raise
except self.retriable_exceptions as e:
except self.retriable_exceptions:
pass

if n == 1:
Expand Down
5 changes: 4 additions & 1 deletion python/src/cloudstorage/cloudstorage_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
]

import logging
import StringIO
try:
import StringIO
except:
from io import StringIO
import urllib
import os
import itertools
Expand Down
5 changes: 4 additions & 1 deletion python/src/cloudstorage/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
'TransientError',
]

import httplib
try:
import httplib
except ImportError:
import http.client as httplib


class Error(Exception):
Expand Down
15 changes: 5 additions & 10 deletions python/src/cloudstorage/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@

from . import api_utils

try:
from google.appengine.api import app_identity
from google.appengine.api import lib_config
from google.appengine.ext import ndb
except ImportError:
from google.appengine.api import app_identity
from google.appengine.api import lib_config
from google.appengine.ext import ndb
from google.appengine.api import app_identity
from google.appengine.api import lib_config
from google.appengine.ext import ndb



Expand Down Expand Up @@ -97,7 +92,7 @@ def add_sync_methods(cls):
Returns:
The same class, modified in place.
"""
for name in cls.__dict__.keys():
for name in list(cls.__dict__.keys()):
if name.endswith('_async'):
sync_name = name[:-6]
if not hasattr(cls, sync_name):
Expand Down Expand Up @@ -257,7 +252,7 @@ def urlfetch_async(self, url, method='GET', headers=None,
headers.update(self.user_agent)
try:
self.token = yield self.get_token_async()
except app_identity.InternalError, e:
except app_identity.InternalError:
if os.environ.get('DATACENTER', '').endswith('sandman'):
self.token = None
logging.warning('Could not fetch an authentication token in sandman '
Expand Down
18 changes: 8 additions & 10 deletions python/src/cloudstorage/storage_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,18 @@

import collections
import os
import urlparse
try:
import urlparse
except ImportError:
import urllib.parse as urlparse

from . import api_utils
from . import common
from . import errors
from . import rest_api

try:
from google.appengine.api import urlfetch
from google.appengine.ext import ndb
except ImportError:
from google.appengine.api import urlfetch
from google.appengine.ext import ndb

from google.appengine.api import urlfetch
from google.appengine.ext import ndb
from google.appengine.api import app_identity


Expand Down Expand Up @@ -135,9 +133,9 @@ def do_request_async(self, url, method='GET', headers=None, payload=None,
resp_tuple = yield super(_StorageApi, self).do_request_async(
url, method=method, headers=headers, payload=payload,
deadline=deadline, callback=callback)
except urlfetch.DownloadError as e:
except urlfetch.DownloadError:
raise errors.TimeoutError(
'Request to Google Cloud Storage timed out.', e)
'Request to Google Cloud Storage timed out.')

raise ndb.Return(resp_tuple)

Expand Down