示例#1
0
def load(info):

    AssetstoreType.ESSDIVE = 'essdive'
    setAssetstoreAdapter(AssetstoreType.ESSDIVE, EssDiveAssetstoreAdapter)
    events.bind('assetstore.update', 'essdive', updateAssetstore)

    info['apiRoot'].essdive_assetstores = EssDiveAssetstore()
示例#2
0
def load(info):
    AssetstoreType.HDFS = 'hdfs'
    events.bind('assetstore.update', 'hdfs_assetstore', updateAssetstore)
    events.bind('rest.post.assetstore.before', 'hdfs_assetstore',
                createAssetstore)

    assetstore_utilities.setAssetstoreAdapter(AssetstoreType.HDFS,
                                              HdfsAssetstoreAdapter)

    (Assetstore.createAssetstore.description.param(
        'host', 'The namenode host (for HDFS type).', required=False).param(
            'port', 'The namenode RPC port (for HDFS type).',
            required=False).param(
                'path', 'Absolute path under which new files will be stored ('
                'for HDFS type).',
                required=False).
     param('user', 'The effective user to use when calling HDFS RPCs (for '
           'HDFS type). This defaults to whatever system username the '
           'Girder server process is running under.',
           required=False).param(
               'webHdfsPort', 'WebHDFS port for the namenode. You must enable '
               'WebHDFS on your Hadoop cluster if you want to write new files '
               'to the assetstore (for HDFS type).',
               required=False))

    info['apiRoot'].hdfs_assetstore = HdfsAssetstoreResource()
示例#3
0
    def load(self, info):
        AssetstoreType.NEWT = 'newt'
        setAssetstoreAdapter(AssetstoreType.NEWT, NewtAssetstoreAdapter)
        events.bind('assetstore.update', 'newt', updateAssetstore)

        info['apiRoot'].newt = Newt()
        info['apiRoot'].newt_assetstores = NewtAssetstore()

        if hasattr(girder, '__version__') and girder.__version__[0] == '3':
            # Replace User._validateLogin to accept 3-letter user names
            def _validateNewtLogin(login):
                if '@' in login:
                    # Hard-code this constraint so we can always easily distinguish
                    # an email address from a login
                    raise ValidationException('Login may not contain "@".',
                                              'login')

                # For reference, girder's regex is r'^[a-z][\da-z\-\.]{3,}$'
                if not re.match(r'^[a-z][\da-z_\-\.]{2,}$', login):
                    raise ValidationException(
                        'Login must be at least 3 characters, start with a letter, and may only contain '
                        'letters, numbers, underscores, dashes, and periods.',
                        'login')

            User()._validateLogin = _validateNewtLogin
def load(info):
    """
    Load the plugin into Girder.

    :param info: a dictionary of plugin information.  The name key contains the
                 name of the plugin according to Girder.
    """
    plugin_name = info['name']
    AssetstoreType.DATABASE = 'database'
    setAssetstoreAdapter(AssetstoreType.DATABASE,
                         assetstore.DatabaseAssetstoreAdapter)
    events.bind('assetstore.update', 'database_assetstore', updateAssetstore)
    events.bind('rest.post.assetstore.before', 'database_assetstore',
                createAssetstore)
    events.bind('model.file.validate', 'database_assetstore', validateFile)
    events.bind(
        'model.setting.validate', 'database_assetstore',
        functools.partial(base.validateSettings, plugin_name=plugin_name))

    (AssetstoreResource.createAssetstore.description.param(
        'dbtype', 'The database type (for Database type).',
        required=False).param('dburi',
                              'The database URI (for Database type).',
                              required=False))

    info['apiRoot'].database_assetstore = DatabaseAssetstoreResource()

    fileResourceRoutes(info['apiRoot'].file)

    File().exposeFields(level=AccessType.ADMIN, fields=base.DB_INFO_KEY)
    File().exposeFields(level=AccessType.SITE_ADMIN, fields=base.DB_INFO_KEY)

    # Make sure the user assetstore exists.
    base._createUserAssetstore()
示例#5
0
    def load(self, info):
        AssetstoreType.NEWT = 'newt'
        setAssetstoreAdapter(AssetstoreType.NEWT, NewtAssetstoreAdapter)
        events.bind('assetstore.update', 'newt', updateAssetstore)

        info['apiRoot'].newt = Newt()
        info['apiRoot'].newt_assetstores = NewtAssetstore()
def load(info):
    """
    Load the plugin into Girder.

    :param info: a dictionary of plugin information.  The name key contains the
                 name of the plugin according to Girder.
    """
    plugin_name = info['name']
    AssetstoreType.DATABASE = 'database'
    setAssetstoreAdapter(AssetstoreType.DATABASE,
                         assetstore.DatabaseAssetstoreAdapter)
    events.bind('assetstore.update', 'database_assetstore', updateAssetstore)
    events.bind('rest.post.assetstore.before', 'database_assetstore',
                createAssetstore)
    events.bind('model.file.validate', 'database_assetstore', validateFile)
    events.bind('model.setting.validate', 'database_assetstore',
                functools.partial(base.validateSettings, plugin_name=plugin_name))

    (AssetstoreResource.createAssetstore.description
        .param('dbtype', 'The database type (for Database type).',
               required=False)
        .param('dburi', 'The database URI (for Database type).',
               required=False))

    info['apiRoot'].database_assetstore = DatabaseAssetstoreResource()

    fileResourceRoutes(info['apiRoot'].file)

    File().exposeFields(level=AccessType.ADMIN, fields=base.DB_INFO_KEY)
    File().exposeFields(level=AccessType.SITE_ADMIN, fields=base.DB_INFO_KEY)

    # Make sure the user assetstore exists.
    base._createUserAssetstore()
示例#7
0
def load(info):

    AssetstoreType.SFTP = 'sftp'
    setAssetstoreAdapter(AssetstoreType.SFTP, SftpAssetstoreAdapter)
    events.bind('assetstore.update', 'sftp', updateAssetstore)
    events.bind('assetstore.sftp.credentials.get', 'sftp', retrieve_credentials)

    info['apiRoot'].sftp_assetstores = SftpAssetstoreResource()
示例#8
0
    def load(self, info):
        AssetstoreType.SFTP = 'sftp'
        setAssetstoreAdapter(AssetstoreType.SFTP, SftpAssetstoreAdapter)
        events.bind('assetstore.update', 'sftp', updateAssetstore)
        events.bind('assetstore.sftp.credentials.get', 'sftp',
                    retrieve_credentials)

        info['apiRoot'].sftp_assetstores = SftpAssetstoreResource()
示例#9
0
def load(info):

    AssetstoreType.NEWT = 'newt'
    setAssetstoreAdapter(AssetstoreType.NEWT, NewtAssetstoreAdapter)
    events.bind('assetstore.update', 'newt', updateAssetstore)

    (Assetstore.createAssetstore.description
        .param('machine', 'The NERSC machine name.', required=False)
        .param('baseUrl', 'The NEWT API base URL.', required=False))

    info['apiRoot'].newt = Newt()
    info['apiRoot'].newt_assetstores = NewtAssetstore()
示例#10
0
    def load(self, info):
        AssetstoreType.HDFS = 'hdfs'
        events.bind('assetstore.update', 'hdfs_assetstore', updateAssetstore)
        events.bind('rest.post.assetstore.before', 'hdfs_assetstore', createAssetstore)

        assetstore_utilities.setAssetstoreAdapter(AssetstoreType.HDFS, HdfsAssetstoreAdapter)

        (Assetstore.createAssetstore.description
            .param('host', 'The namenode host (for HDFS type).', required=False)
            .param('port', 'The namenode RPC port (for HDFS type).', required=False)
            .param('path', 'Absolute path under which new files will be stored ('
                   'for HDFS type).', required=False)
            .param('user', 'The effective user to use when calling HDFS RPCs (for '
                   'HDFS type). This defaults to whatever system username the '
                   'Girder server process is running under.', required=False)
            .param('webHdfsPort', 'WebHDFS port for the namenode. You must enable '
                   'WebHDFS on your Hadoop cluster if you want to write new files '
                   'to the assetstore (for HDFS type).', required=False))

        info['apiRoot'].hdfs_assetstore = HdfsAssetstoreResource()
示例#11
0
文件: __init__.py 项目: hafen/candela
def load(info):
    ResonantLaboratory._cp_config['tools.staticdir.dir'] = os.path.join(
        os.path.relpath(info['pluginRootDir'],
                        info['config']['/']['tools.staticdir.root']),
        'web_client')

    # Move girder app to /girder, serve sumo app from /
    app = info['apiRoot'].resonantLaboratoryapp = ResonantLaboratory(info)

    (
        info['serverRoot'],
        info['serverRoot'].girder
    ) = (
        info['apiRoot'].resonantLaboratoryapp,
        info['serverRoot']
    )

    info['serverRoot'].api = info['serverRoot'].girder.api

    # Expose versioning endpoint
    info['apiRoot'].system.route('GET', ('resonantLaboratoryVersion', ),
                                 app.versioning.versionNumber)

    # Expose anonymous access endpoints
    info['apiRoot'].item.route('POST', ('anonymousAccess', 'privateItem'),
                               app.anonymousAccess.getOrMakePrivateItem)
    info['apiRoot'].item.route('POST', ('anonymousAccess', 'scratchItem'),
                               app.anonymousAccess.makeScratchItem)
    info['apiRoot'].folder.route('GET', ('anonymousAccess', 'privateFolder'),
                                 app.anonymousAccess.getOrMakePrivateFolder)
    info['apiRoot'].folder.route('GET', ('anonymousAccess', 'publicFolder'),
                                 app.anonymousAccess.getOrMakePublicFolder)
    info['apiRoot'].item.route('POST', (':id', 'anonymousAccess', 'togglePublic'),
                               app.anonymousAccess.togglePublic)
    info['apiRoot'].item.route('POST', (':id', 'anonymousAccess', 'updateScratch'),
                               app.anonymousAccess.updateScratchItem)
    info['apiRoot'].item.route('GET', (':id', 'anonymousAccess', 'info'),
                               app.anonymousAccess.itemInfo)
    info['apiRoot'].item.route('GET', ('anonymousAccess', 'validateScratchItems'),
                               app.anonymousAccess.validateScratchItems)
    info['apiRoot'].item.route('PUT', ('anonymousAccess', 'adoptScratchItems'),
                               app.anonymousAccess.adoptScratchItems)

    # Expose dataset endpoints
    info['apiRoot'].item.route('POST', (':id', 'dataset'),
                               app.datasetItem.setupDataset)
    info['apiRoot'].item.route('POST', (':id', 'dataset', 'inferSchema'),
                               app.datasetItem.inferSchema)
    info['apiRoot'].item.route('POST', (':id', 'dataset', 'getHistograms'),
                               app.datasetItem.getHistograms)

    # Expose project endpoint
    info['apiRoot'].item.route('POST', (':id', 'project'),
                               app.projectItem.setupProject)

    # Install "semantic" download adapters into Girder's table of adapters.
    setAssetstoreAdapter(AssetstoreType.FILESYSTEM, semantic_access(FilesystemAssetstoreAdapter))
    setAssetstoreAdapter(AssetstoreType.GRIDFS, semantic_access(GridFsAssetstoreAdapter))
    setAssetstoreAdapter(AssetstoreType.DATABASE, semantic_access(DatabaseAssetstoreAdapter))
def fakeAdapter(db):
    assetstore_utilities.setAssetstoreAdapter('fake', FakeAdapter)

    yield

    assetstore_utilities.removeAssetstoreAdapter('fake')
def fakeAdapter(db):
    assetstore_utilities.setAssetstoreAdapter('fake', FakeAdapter)

    yield

    assetstore_utilities.removeAssetstoreAdapter('fake')
示例#14
0
    def load(self, info):
        # TODO allow a file to be stored in multiple tape archive assetstores
        setAssetstoreAdapter(AssetstoreType.FILESYSTEM, TarSupportAdapter)

        info['apiRoot'].assetstore.route('POST', (':id', 'tar_export'), _exportTar)
        info['apiRoot'].folder.route('POST', (':id', 'tar_import'), _importTar)
示例#15
0
def _importHdf5(self, assetstore, folder, path, progress):
    user = self.getCurrentUser()
    setAssetstoreAdapter(AssetstoreType.FILESYSTEM, Hdf5SupportAdapter)
    adapter = getAssetstoreAdapter(assetstore)
    with ProgressContext(progress, user=user, title="Importing data") as ctx:
        adapter._importHdf5(path, folder, ctx, user)