aboutsummaryrefslogtreecommitdiff
path: root/oauth2client/file.py
diff options
context:
space:
mode:
Diffstat (limited to 'oauth2client/file.py')
-rw-r--r--oauth2client/file.py21
1 files changed, 5 insertions, 16 deletions
diff --git a/oauth2client/file.py b/oauth2client/file.py
index feede11..3551c80 100644
--- a/oauth2client/file.py
+++ b/oauth2client/file.py
@@ -21,16 +21,10 @@ credentials.
import os
import threading
+from oauth2client import _helpers
from oauth2client import client
-__author__ = 'jcgregorio@google.com (Joe Gregorio)'
-
-
-class CredentialsFileSymbolicLinkError(Exception):
- """Credentials files must not be symbolic links."""
-
-
class Storage(client.Storage):
"""Store and retrieve a single credential to and from a file."""
@@ -38,11 +32,6 @@ class Storage(client.Storage):
super(Storage, self).__init__(lock=threading.Lock())
self._filename = filename
- def _validate_file(self):
- if os.path.islink(self._filename):
- raise CredentialsFileSymbolicLinkError(
- 'File: {0} is a symbolic link.'.format(self._filename))
-
def locked_get(self):
"""Retrieve Credential from file.
@@ -50,10 +39,10 @@ class Storage(client.Storage):
oauth2client.client.Credentials
Raises:
- CredentialsFileSymbolicLinkError if the file is a symbolic link.
+ IOError if the file is a symbolic link.
"""
credentials = None
- self._validate_file()
+ _helpers.validate_file(self._filename)
try:
f = open(self._filename, 'rb')
content = f.read()
@@ -89,10 +78,10 @@ class Storage(client.Storage):
credentials: Credentials, the credentials to store.
Raises:
- CredentialsFileSymbolicLinkError if the file is a symbolic link.
+ IOError if the file is a symbolic link.
"""
self._create_file_if_needed()
- self._validate_file()
+ _helpers.validate_file(self._filename)
f = open(self._filename, 'w')
f.write(credentials.to_json())
f.close()