示例#1
0
def load(info):
    registerAccessFlag(constants.ACCESS_FLAG_EXECUTE_TASK,
                       name='Execute analyses',
                       admin=True)
    TokenScope.describeScope(constants.TOKEN_SCOPE_EXECUTE_TASK,
                             name='Execute tasks',
                             description='Execute item tasks.')
    TokenScope.describeScope(constants.TOKEN_SCOPE_AUTO_CREATE_CLI,
                             'Item task auto-creation',
                             'Create new CLIs via automatic introspection.',
                             admin=True)

    ModelImporter.model('item').ensureIndex(
        ['meta.isItemTask', {
            'sparse': True
        }])
    ModelImporter.model('item').exposeFields(level=AccessType.READ,
                                             fields='createdByJob')
    ModelImporter.model('job', 'jobs').exposeFields(
        level=AccessType.READ, fields={'itemTaskId', 'itemTaskBindings'})

    events.bind('jobs.job.update', info['name'], _onJobSave)
    events.bind('data.process', info['name'], _onUpload)

    info['apiRoot'].item_task = ItemTask()
示例#2
0
def load(info):
    registerAccessFlag(constants.ACCESS_FLAG_EXECUTE_TASK, name='Execute analyses', admin=True)
    TokenScope.describeScope(
        constants.TOKEN_SCOPE_EXECUTE_TASK, name='Execute tasks', description='Execute item tasks.')
    TokenScope.describeScope(
        constants.TOKEN_SCOPE_AUTO_CREATE_CLI, 'Item task auto-creation',
        'Create new CLIs via automatic introspection.', admin=True)

    ModelImporter.model('item').ensureIndex(['meta.isItemTask', {'sparse': True}])
    ModelImporter.model('item').exposeFields(level=AccessType.READ, fields='createdByJob')
    ModelImporter.model('job', 'jobs').exposeFields(level=AccessType.READ, fields={
        'itemTaskId', 'itemTaskBindings'})

    events.bind('jobs.job.update', info['name'], _onJobSave)
    events.bind('data.process', info['name'], _onUpload)

    info['apiRoot'].item_task = ItemTask()

    info['apiRoot'].item.route('POST', (':id', 'item_task_slicer_cli_description'),
                               runSlicerCliTasksDescriptionForItem)
    info['apiRoot'].item.route('PUT', (':id', 'item_task_slicer_cli_xml'),
                               configureItemTaskFromSlicerCliXml)
    info['apiRoot'].item.route('POST', (':id', 'item_task_json_description'),
                               runJsonTasksDescriptionForItem)
    info['apiRoot'].item.route('PUT', (':id', 'item_task_json_specs'),
                               configureItemTaskFromJson)

    info['apiRoot'].folder.route('POST', (':id', 'item_task_slicer_cli_description'),
                                 runSlicerCliTasksDescriptionForFolder)
    info['apiRoot'].folder.route('POST', (':id', 'item_task_slicer_cli_xml'),
                                 createItemTasksFromSlicerCliXml)
    info['apiRoot'].folder.route('POST', (':id', 'item_task_json_description'),
                                 runJsonTasksDescriptionForFolder)
    info['apiRoot'].folder.route('POST', (':id', 'item_task_json_specs'),
                                 createItemTasksFromJson)
示例#3
0
文件: __init__.py 项目: Kitware/SMQTK
    def __init__(self):
        self.resourceName = 'smqtk'
        self.route('GET', ('settings',), self.settings)
        self.route('POST', ('process_images',), self.processImages)

        TokenScope.describeScope(SMQTK_SETTING_READ, 'Read SMQTK settings',
                                 'Allow clients to look up the SMQTK settings, including private '
                                 'fields such as database credentials.')
示例#4
0
    def __init__(self):
        self.resourceName = 'smqtk'
        self.route('GET', ('settings', ), self.settings)
        self.route('POST', ('process_images', ), self.processImages)

        TokenScope.describeScope(
            SMQTK_SETTING_READ, 'Read SMQTK settings',
            'Allow clients to look up the SMQTK settings, including private '
            'fields such as database credentials.')
示例#5
0
文件: api_key.py 项目: wphicks/girder
    def validate(self, doc):
        from .token import Token
        from .user import User

        if doc['tokenDuration']:
            doc['tokenDuration'] = float(doc['tokenDuration'])
        else:
            doc['tokenDuration'] = None

        doc['name'] = doc['name'].strip()
        doc['active'] = bool(doc.get('active', True))

        if doc['scope'] is not None:
            if not isinstance(doc['scope'], (list, tuple)):
                raise ValidationException('Scope must be a list, or None.')
            if not doc['scope']:
                raise ValidationException(
                    'Custom scope list must not be empty.')

            # Ensure only registered scopes are being set
            admin = User().load(doc['userId'], force=True)['admin']
            scopes = TokenScope.scopeIds(admin)
            unknownScopes = set(doc['scope']) - scopes
            if unknownScopes:
                raise ValidationException('Invalid scopes: %s.' %
                                          ','.join(unknownScopes))

        # Deactivating an already existing token
        if '_id' in doc and not doc['active']:
            Token().clearForApiKey(doc)

        return doc
示例#6
0
文件: api_key.py 项目: girder/girder
    def validate(self, doc):
        from .token import Token
        from .user import User

        if doc['tokenDuration']:
            doc['tokenDuration'] = float(doc['tokenDuration'])
        else:
            doc['tokenDuration'] = None

        doc['name'] = doc['name'].strip()
        doc['active'] = bool(doc.get('active', True))

        if doc['scope'] is not None:
            if not isinstance(doc['scope'], (list, tuple)):
                raise ValidationException('Scope must be a list, or None.')
            if not doc['scope']:
                raise ValidationException('Custom scope list must not be empty.')

            # Ensure only registered scopes are being set
            admin = User().load(doc['userId'], force=True)['admin']
            scopes = TokenScope.scopeIds(admin)
            unknownScopes = set(doc['scope']) - scopes
            if unknownScopes:
                raise ValidationException('Invalid scopes: %s.' % ','.join(unknownScopes))

        # Deactivating an already existing token
        if '_id' in doc and not doc['active']:
            Token().clearForApiKey(doc)

        return doc
示例#7
0
def load(info):
    registerAccessFlag(constants.ACCESS_FLAG_EXECUTE_TASK,
                       name='Execute analyses',
                       admin=True)
    TokenScope.describeScope(constants.TOKEN_SCOPE_EXECUTE_TASK,
                             name='Execute tasks',
                             description='Execute item tasks.')
    TokenScope.describeScope(constants.TOKEN_SCOPE_AUTO_CREATE_CLI,
                             'Item task auto-creation',
                             'Create new CLIs via automatic introspection.',
                             admin=True)

    ModelImporter.model('item').ensureIndex(
        ['meta.isItemTask', {
            'sparse': True
        }])
    ModelImporter.model('item').exposeFields(level=AccessType.READ,
                                             fields='createdByJob')
    ModelImporter.model('job', 'jobs').exposeFields(
        level=AccessType.READ, fields={'itemTaskId', 'itemTaskBindings'})

    events.bind('jobs.job.update', info['name'], _onJobSave)
    events.bind('data.process', info['name'], _onUpload)

    info['apiRoot'].item_task = ItemTask()

    info['apiRoot'].item.route('POST',
                               (':id', 'item_task_slicer_cli_description'),
                               runSlicerCliTasksDescriptionForItem)
    info['apiRoot'].item.route('PUT', (':id', 'item_task_slicer_cli_xml'),
                               configureItemTaskFromSlicerCliXml)
    info['apiRoot'].item.route('POST', (':id', 'item_task_json_description'),
                               runJsonTasksDescriptionForItem)
    info['apiRoot'].item.route('PUT', (':id', 'item_task_json_specs'),
                               configureItemTaskFromJson)

    info['apiRoot'].folder.route('POST',
                                 (':id', 'item_task_slicer_cli_description'),
                                 runSlicerCliTasksDescriptionForFolder)
    info['apiRoot'].folder.route('POST', (':id', 'item_task_slicer_cli_xml'),
                                 createItemTasksFromSlicerCliXml)
    info['apiRoot'].folder.route('POST', (':id', 'item_task_json_description'),
                                 runJsonTasksDescriptionForFolder)
    info['apiRoot'].folder.route('POST', (':id', 'item_task_json_specs'),
                                 createItemTasksFromJson)
示例#8
0
def testListScopes(server):
    resp = server.request('/token/scopes')
    assertStatusOk(resp)
    assert resp.json == TokenScope.listScopes()

    assert 'custom' in resp.json
    assert isinstance(resp.json['custom'], list)
    assert 'adminCustom' in resp.json
    assert isinstance(resp.json['adminCustom'], list)

    for scope in resp.json['custom'] + resp.json['adminCustom']:
        assert 'id' in scope
        assert 'name' in scope
        assert 'description' in scope
示例#9
0
def testListScopes(server):
    resp = server.request('/token/scopes')
    assertStatusOk(resp)
    assert resp.json == TokenScope.listScopes()

    assert 'custom' in resp.json
    assert isinstance(resp.json['custom'], list)
    assert 'adminCustom' in resp.json
    assert isinstance(resp.json['adminCustom'], list)

    for scope in resp.json['custom'] + resp.json['adminCustom']:
        assert 'id' in scope
        assert 'name' in scope
        assert 'description' in scope
示例#10
0
    def testListScopes(self):
        resp = self.request('/token/scopes')
        self.assertStatusOk(resp)
        self.assertEqual(resp.json, TokenScope.listScopes())

        self.assertIn('custom', resp.json)
        self.assertIsInstance(resp.json['custom'], list)
        self.assertIn('adminCustom', resp.json)
        self.assertIsInstance(resp.json['adminCustom'], list)

        for scope in resp.json['custom'] + resp.json['adminCustom']:
            self.assertIn('id', scope)
            self.assertIn('name', scope)
            self.assertIn('description', scope)
示例#11
0
    def testListScopes(self):
        resp = self.request('/token/scopes')
        self.assertStatusOk(resp)
        self.assertEqual(resp.json, TokenScope.listScopes())

        self.assertIn('custom', resp.json)
        self.assertIsInstance(resp.json['custom'], list)
        self.assertIn('adminCustom', resp.json)
        self.assertIsInstance(resp.json['adminCustom'], list)

        for scope in resp.json['custom'] + resp.json['adminCustom']:
            self.assertIn('id', scope)
            self.assertIn('name', scope)
            self.assertIn('description', scope)
示例#12
0
 def listScopes(self):
     return TokenScope.listScopes()
示例#13
0
from girder_worker.docker.tasks import docker_run
from girder_worker.docker.transforms import VolumePath
from girder_worker.docker.transforms.girder import (
    GirderFolderIdToVolume, GirderUploadVolumePathToFolder,
    GirderFileIdToVolume, ProgressPipe)
from PIL import Image

CLEANUP_TOKEN_SCOPE = 'stroke_ct.cleanup'
DATE_FMT = '%A %B %-d, %Y'
DAYS_UNTIL_EMAIL = 7
DAYS_UNTIL_DELETION = 14
DELETE_SUBJECT = 'Warning: your timelapse data will be deleted soon!'

TokenScope.describeScope(
    CLEANUP_TOKEN_SCOPE,
    'Delete expired timelapse data',
    description='Delete expired timelapses and send emails for pending ones.',
    admin=True)

# [[x1, y2], [x2, y2]] in pixel coordinates
_MASK_RECT_SCHEMA = {
    'type': 'array',
    'maxItems': 2,
    'minItems': 2,
    'items': {
        'type': 'array',
        'maxItems': 2,
        'minItems': 2,
        'items': {
            'type': 'integer',
            'minimum': 0
示例#14
0
 def listScopes(self, params):
     return TokenScope.listScopes()