Coverage for girder/models/assetstore : 86%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/env python # -*- coding: utf-8 -*-
############################################################################### # Copyright 2013 Kitware Inc. # # Licensed under the Apache License, Version 2.0 ( the "License" ); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ###############################################################################
""" This model represents an assetstore, an abstract repository of Files. """
# Ensure no duplicate names 'exists.', 'name')
# Name must not be empty raise ValidationException('Name must not be empty.', 'name')
# Filesystem assetstores must have their directory exist and writeable raise ValidationException('You must provide an absolute path ' 'for the root directory.', 'root') except OSError: raise ValidationException('Could not make directory "%s".' % doc['root'], 'root') raise ValidationException('Unable to write into directory "%s".' % doc['root'], 'root')
raise ValidationException('Database Name must not be empty.', 'db') raise ValidationException('Database Name cannot contain spaces' ' or periods.', 'db')
# If no current assetstore exists yet, set this one as the current.
# If we are setting this as current, we should unmark all other # assetstores that have the current flag.
""" Delete an assetstore. If there are any files within this assetstore, a validation exception is raised.
:param assetstore: The assetstore document to delete. :type assetstore: dict """ # Delete all folders in the community recursively 'assetstoreId': assetstore['_id'] }, limit=1) 'contains files.')
""" List all assetstores.
:param limit: Result limit. :param offset: Result offset. :param sort: The sort structure to pass to pymongo. :returns: List of users. """
'type': AssetstoreType.FILESYSTEM, 'created': datetime.datetime.now(), 'name': name, 'root': root })
'type': AssetstoreType.GRIDFS, 'created': datetime.datetime.now(), 'name': name, 'db': db })
raise Exception('S3 assetstore not implemented yet.')
""" Returns the current assetstore. If none exists, this will raise a 500 exception. """ raise Exception('No current assetstore is set.')
|