+ 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
+ 17Utilities for making it easier to work with OAuth 2.0
+ 18credentials.
+ 19"""
+ 20
+ 21__author__='jcgregorio@google.com (Joe Gregorio)'
+ 22
+ 23importos
+ 24importstat
+ 25importthreading
+ 26
+ 27fromanyjsonimportsimplejson
+ 28fromclientimportStorageasBaseStorage
+ 29fromclientimportCredentials
+ 30
+ 31
+
46"""Release the Storage lock.
+ 47
+ 48 Trying to release a lock that isn't held will result in a
+ 49 RuntimeError.
+ 50 """
+ 51self._lock.release()
+
76"""Create an empty file if necessary.
+ 77
+ 78 This method will not initialize the file. Instead it implements a
+ 79 simple version of "touch" to ensure the file has been created.
+ 80 """
+ 81ifnotos.path.exists(self._filename):
+ 82old_umask=os.umask(0177)
+ 83try:
+ 84open(self._filename,'a+b').close()
+ 85finally:
+ 86os.umask(old_umask)
+