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

Side by Side Diff: appengine/chromium_build_logs/third_party/apiclient/ext/file.py

Issue 1260293009: make version of ts_mon compatible with appengine (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: clean up code Created 5 years, 4 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
(Empty)
1 # Copyright (C) 2010 Google Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (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
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 """Utilities for OAuth.
16
17 Utilities for making it easier to work with OAuth 1.0 credentials.
18 """
19
20 __author__ = 'jcgregorio@google.com (Joe Gregorio)'
21
22 import pickle
23 import threading
24
25 from apiclient.oauth import Storage as BaseStorage
26
27
28 class Storage(BaseStorage):
29 """Store and retrieve a single credential to and from a file."""
30
31 def __init__(self, filename):
32 self._filename = filename
33 self._lock = threading.Lock()
34
35 def get(self):
36 """Retrieve Credential from file.
37
38 Returns:
39 apiclient.oauth.Credentials
40 """
41 self._lock.acquire()
42 try:
43 f = open(self._filename, 'r')
44 credentials = pickle.loads(f.read())
45 f.close()
46 credentials.set_store(self.put)
47 except:
48 credentials = None
49 self._lock.release()
50
51 return credentials
52
53 def put(self, credentials):
54 """Write a pickled Credentials to file.
55
56 Args:
57 credentials: Credentials, the credentials to store.
58 """
59 self._lock.acquire()
60 f = open(self._filename, 'w')
61 f.write(pickle.dumps(credentials))
62 f.close()
63 self._lock.release()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698