Don't raise error on file not existing

This commit is contained in:
Joey Payne 2016-05-25 14:41:02 -06:00
commit c82dc7ec36
2 changed files with 6 additions and 3 deletions

View file

@ -9,6 +9,9 @@ ALL_SINGLE_FILE_FIELDS = 'appProperties,capabilities,contentHints,createdTime,de
ALL_PERMISSION_FIELDS = 'allowFileDiscovery,displayName,domain,emailAddress,id,kind,photoLink,role,type'
class GoogleDriveParameterError(Exception):
pass
class PermissionRole(object):
Reader = 'reader'
Writer = 'writer'

View file

@ -48,7 +48,7 @@ class GoogleDrive(object):
A list of the newly created file and it's directories
Raises:
A GoogleFileException if the permissions object is specified and
A GoogleDriveParameterError if the permissions object is specified and
there is no 'email' key
"""
file_sections = path.split('/')
@ -89,7 +89,7 @@ class GoogleDrive(object):
for permission in permissions:
email = permission.pop('email', '')
if not email:
raise Exception('There must be an email key in the permissions object!')
raise config.GoogleDriveParameterError('There must be an email key in the permissions object!')
for google_file in result:
google_file.give_permission(email, **permission)
@ -125,7 +125,7 @@ class GoogleDrive(object):
fold = folds[0]
parent_id = fold['id']
else:
raise Exception('File {} does not exist!'.format(path))
return []
files = self.list_files(q='name = "{}" and "{}" in parents'.format(file_name, parent_id))