How to use the girder.models.setting.Setting function in girder

To help you get started, we’ve selected a few girder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github girder / large_image / girder / test_girder / girder_utilities.py View on Github external
Run an instance of Girder worker, connected to rabbitmq.  The rabbitmq
    service must be running.
    """
    broker = 'amqp://guest@127.0.0.1'
    Setting().set(WorkerSettings.BROKER, broker)
    Setting().set(WorkerSettings.BACKEND, broker)
    env = os.environ.copy()
    env['C_FORCE_ROOT'] = 'true'
    proc = subprocess.Popen([
        'celery', '-A', 'girder_worker.app', 'worker', '--broker', broker, '--concurrency=1'],
        close_fds=True, env=env)
    yield True
    proc.terminate()
    proc.wait()
    Setting().unset(WorkerSettings.BROKER)
    Setting().unset(WorkerSettings.BACKEND)
github girder / girder / test / sentry / test_sentry.py View on Github external
def testSetSentryDSN(server):
    Setting().set(DSN, TEST_DSN)
    assert Setting().get(DSN) == TEST_DSN
github girder / girder / plugins / sentry / plugin_tests / test_sentry.py View on Github external
def testEmptyInitSentryDSN(server):
    assert Setting().get(DSN) == ''
github girder / girder / plugins / sentry / plugin_tests / test_sentry.py View on Github external
def testGetSentryDSN(server):
    Setting().set(DSN, TEST_DSN)

    resp = server.request('/sentry/dsn')
    assertStatusOk(resp)
    assert resp.json['sentry_dsn'] == TEST_DSN

    Setting().set(DSN, '')
github girder / girder / girder / cli / mount.py View on Github external
if sys.platform != 'darwin':
        # Automatically unmount when we try to mount again
        options['auto_unmount'] = True
    if fuseOptions:
        for opt in fuseOptions.split(','):
            if '=' in opt:
                key, value = opt.split('=', 1)
                value = (False if value.lower() == 'false' else
                         True if value.lower() == 'true' else value)
            else:
                key, value = opt, True
            if key in ('use_ino', 'ro', 'rw') and options.get(key) != value:
                logprint.warning('Ignoring the %s=%r option' % (key, value))
                continue
            options[key] = value
    Setting().set(SettingKey.GIRDER_MOUNT_INFORMATION,
                  {'path': path, 'mounttime': time.time()})
    FUSELogError(opClass, path, **options)
github girder / girder / girder / api / rest.py View on Github external
Set CORS headers that should be passed back with either a preflight OPTIONS
    or a simple CORS request. We set these headers anytime there is an Origin
    header present since browsers will simply ignore them if the request is not
    cross-origin.
    """
    origin = cherrypy.request.headers.get('origin')
    if not origin:
        # If there is no origin header, this is not a cross origin request
        return

    allowed = Setting().get(SettingKey.CORS_ALLOW_ORIGIN)

    if allowed:
        setResponseHeader('Access-Control-Allow-Credentials', 'true')
        setResponseHeader(
            'Access-Control-Expose-Headers', Setting().get(SettingKey.CORS_EXPOSE_HEADERS))

        allowedList = {o.strip() for o in allowed.split(',')}

        if origin in allowedList:
            setResponseHeader('Access-Control-Allow-Origin', origin)
        elif '*' in allowedList:
            setResponseHeader('Access-Control-Allow-Origin', '*')
github girder / girder_worker / girder_worker / girder_plugin / utils.py View on Github external
def getWorkerApiUrl():
    """
    Return the API base URL to which the worker should callback to
    write output information back to the server. This is controlled
    via a system setting, and the default is to use the core server
    root setting.
    """
    apiUrl = Setting().get(PluginSettings.API_URL)
    return apiUrl or getApiUrl()
github girder / girder / plugins / oauth / server / providers / girder_provider.py View on Github external
def getUrl(cls, state):
        loginUrl = Setting().get(constants.PluginSettings.GIRDER_LOGIN_URL)
        clientId = Setting().get(constants.PluginSettings.GIRDER_CLIENT_ID)

        if clientId is None:
            raise Exception('No Girder client ID setting is present.')
        if loginUrl is None:
            raise Exception('No Girder login URL setting is present.')

        query = urllib.parse.urlencode({
            'clientId': clientId,
            'redirect': '/'.join((getApiUrl(), 'oauth', 'girder', 'callback')),
            'state': state,
            'scope': ' '.join(cls._AUTH_SCOPES)
        })
        return '%s?%s' % (loginUrl, query)
github girder / girder / plugins / oauth / server / providers / bitbucket.py View on Github external
def getClientIdSetting(self):
        return Setting().get(constants.PluginSettings.BITBUCKET_CLIENT_ID)
github girder / girder / plugins / user_quota / girder_user_quota / quota.py View on Github external
:param model: the type of resource (e.g., user or collection)
        :param resource: the resource document.
        :returns: the fileSizeQuota.  None for no quota (unlimited), otherwise
                 a positive integer.
        """
        useDefault = resource[QUOTA_FIELD].get('useQuotaDefault', True)
        quota = resource[QUOTA_FIELD].get('fileSizeQuota', None)
        if useDefault:
            if model == 'user':
                key = PluginSettings.DEFAULT_USER_QUOTA
            elif model == 'collection':
                key = PluginSettings.DEFAULT_COLLECTION_QUOTA
            else:
                key = None
            if key:
                quota = Setting().get(key)
        if not quota or quota < 0 or not isinstance(quota, six.integer_types):
            return None
        return quota