summaryrefslogtreecommitdiff
blob: 15f6fc373779cb9a3289a849193c27bc14cf9f4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
https://github.com/GoogleCloudPlatform/gcs-oauth2-boto-plugin/pull/18

--- a/gcs_oauth2_boto_plugin/oauth2_client.py
+++ b/gcs_oauth2_boto_plugin/oauth2_client.py
@@ -122,7 +122,7 @@ except ImportError:
           retval.token_expiry = datetime.datetime.strptime(
               data['token_expiry'], EXPIRY_FORMAT)
         return retval
-      except KeyError, e:
+      except KeyError as e:
         raise Exception('Your JSON credentials are invalid; '
                         'missing required entry %s.' % e[0])
   # pylint: enable=protected-access
@@ -274,7 +274,7 @@ class FileSystemTokenCache(TokenCache):
       flags |= os.O_BINARY
 
     try:
-      fd = os.open(cache_file, flags, 0600)
+      fd = os.open(cache_file, flags, 0o0600)
     except (OSError, IOError) as e:
       LOG.warning('FileSystemTokenCache.PutToken: '
                   'Failed to create cache file %s: %s', cache_file, e)
@@ -633,7 +633,7 @@ class OAuth2UserAccountClient(OAuth2Client):
       return AccessToken(
           credentials.access_token, credentials.token_expiry,
           datetime_strategy=self.datetime_strategy)
-    except AccessTokenRefreshError, e:
+    except AccessTokenRefreshError as e:
       if 'Invalid response 403' in e.message:
         # This is the most we can do at the moment to accurately detect rate
         # limiting errors since they come back as 403s with no further
@@ -669,7 +669,7 @@ class OAuth2GCEClient(OAuth2Client):
       http = httplib2.Http()
       response, content = http.request(META_TOKEN_URI, method='GET',
                                        body=None, headers=META_HEADERS)
-    except Exception, e:
+    except Exception as e:
       raise GsAccessTokenRefreshError(e)
 
     if response.status == 200:
@@ -695,7 +695,7 @@ def _IsGCE():
     # this approach, we'll avoid having to enumerate all possible non-transient
     # socket errors.
     return False
-  except Exception, e:  # pylint: disable=broad-except
+  except Exception as e:  # pylint: disable=broad-except
     LOG.warning("Failed to determine whether we're running on GCE, so we'll"
                 "assume that we aren't: %s", e)
     return False
--- a/gcs_oauth2_boto_plugin/test_oauth2_client.py
+++ b/gcs_oauth2_boto_plugin/test_oauth2_client.py
@@ -248,7 +248,7 @@ class FileSystemTokenCacheTest(unittest.TestCase):
     # Assert that the cache file exists and has correct permissions.
     if not IS_WINDOWS:
       self.assertEquals(
-          0600,
+          0o0600,
           stat.S_IMODE(os.stat(self.cache.CacheFileName(self.key)).st_mode))
 
   def testPutGet(self):