Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: client/third_party/oauth2client/file.py

Issue 1768993002: Update oauth2client to v2.0.1 and googleapiclient to v1.5.0. Base URL: git@github.com:luci/luci-py.git@master
Patch Set: . Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 Google Inc. All rights reserved. 1 # Copyright 2014 Google Inc. All rights reserved.
2 # 2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 5 # You may obtain a copy of the License at
6 # 6 #
7 # http://www.apache.org/licenses/LICENSE-2.0 7 # http://www.apache.org/licenses/LICENSE-2.0
8 # 8 #
9 # Unless required by applicable law or agreed to in writing, software 9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 10 # distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 18 matching lines...) Expand all
29 29
30 30
31 class CredentialsFileSymbolicLinkError(Exception): 31 class CredentialsFileSymbolicLinkError(Exception):
32 """Credentials files must not be symbolic links.""" 32 """Credentials files must not be symbolic links."""
33 33
34 34
35 class Storage(BaseStorage): 35 class Storage(BaseStorage):
36 """Store and retrieve a single credential to and from a file.""" 36 """Store and retrieve a single credential to and from a file."""
37 37
38 def __init__(self, filename): 38 def __init__(self, filename):
39 super(Storage, self).__init__(lock=threading.Lock())
39 self._filename = filename 40 self._filename = filename
40 self._lock = threading.Lock()
41 41
42 def _validate_file(self): 42 def _validate_file(self):
43 if os.path.islink(self._filename): 43 if os.path.islink(self._filename):
44 raise CredentialsFileSymbolicLinkError( 44 raise CredentialsFileSymbolicLinkError(
45 'File: %s is a symbolic link.' % self._filename) 45 'File: %s is a symbolic link.' % self._filename)
46 46
47 def acquire_lock(self):
48 """Acquires any lock necessary to access this Storage.
49
50 This lock is not reentrant.
51 """
52 self._lock.acquire()
53
54 def release_lock(self):
55 """Release the Storage lock.
56
57 Trying to release a lock that isn't held will result in a
58 RuntimeError.
59 """
60 self._lock.release()
61
62 def locked_get(self): 47 def locked_get(self):
63 """Retrieve Credential from file. 48 """Retrieve Credential from file.
64 49
65 Returns: 50 Returns:
66 oauth2client.client.Credentials 51 oauth2client.client.Credentials
67 52
68 Raises: 53 Raises:
69 CredentialsFileSymbolicLinkError if the file is a symbolic link. 54 CredentialsFileSymbolicLinkError if the file is a symbolic link.
70 """ 55 """
71 credentials = None 56 credentials = None
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 f.write(credentials.to_json()) 98 f.write(credentials.to_json())
114 f.close() 99 f.close()
115 100
116 def locked_delete(self): 101 def locked_delete(self):
117 """Delete Credentials file. 102 """Delete Credentials file.
118 103
119 Args: 104 Args:
120 credentials: Credentials, the credentials to store. 105 credentials: Credentials, the credentials to store.
121 """ 106 """
122 os.unlink(self._filename) 107 os.unlink(self._filename)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698