コード例 #1
0
ファイル: mount.py プロジェクト: manthey/girder
def mountServer(path, database=None, fuseOptions=None, quiet=False, plugins=None):
    """
    Perform the mount.

    :param path: the mount location.
    :param database: a database connection URI, if it contains '://'.
        Otherwise, the default database is used.
    :param fuseOptions: a comma-separated string of options to pass to the FUSE
        mount.  A key without a value is taken as True.  Boolean values are
        case insensitive.  For instance, 'foreground' or 'foreground=True' will
        keep this program running until the SIGTERM or unmounted.
    :param quiet: if True, suppress Girder logs.
    :param plugins: an optional list of plugins to enable.  If None, use the
        plugins that are configured.
    """
    if quiet:
        curConfig = config.getConfig()
        curConfig.setdefault('logging', {})['log_quiet'] = True
        curConfig.setdefault('logging', {})['log_level'] = 'FATAL'
        girder._setupLogger()
    if database and '://' in database:
        cherrypy.config['database']['uri'] = database
    if plugins is not None:
        plugins = plugins.split(',')
    webroot, appconf = configureServer(plugins=plugins)
    girder._setupCache()

    opClass = ServerFuse(stat=os.stat(path))
    options = {
        # By default, we run in the background so the mount command returns
        # immediately.  If we run in the foreground, a SIGTERM will shut it
        # down
        'foreground': False,
        # Cache files if their size and timestamp haven't changed.
        # This lets the OS buffer files efficiently.
        'auto_cache': True,
        # We aren't specifying our own inos
        'use_ino': False,
        # read-only file system
        'ro': True,
    }
    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)
コード例 #2
0
 def configureLogging(self, logConfig={}, oneFile=False):
     cfg = config.getConfig()
     if oneFile:
         cfg['logging']['error_log_file'] = cfg['logging']['info_log_file']
     else:
         cfg['logging']['error_log_file'] = cfg['logging']['original_error_log_file']
     self.infoFile = cfg['logging']['info_log_file']
     self.errorFile = cfg['logging']['error_log_file']
     if os.path.exists(self.infoFile):
         os.unlink(self.infoFile)
     if os.path.exists(self.errorFile):
         os.unlink(self.errorFile)
     cfg['logging'].update(logConfig)
     cfg = config.getConfig()
     girder.logger = girder._setupLogger()
コード例 #3
0
def configureLogging(logConfig={}, oneFile=False):
    cfg = config.getConfig()
    if oneFile:
        cfg['logging']['error_log_file'] = cfg['logging']['info_log_file']
    else:
        cfg['logging']['error_log_file'] = cfg['logging']['original_error_log_file']
    if os.path.exists(cfg['logging']['info_log_file']):
        os.unlink(cfg['logging']['info_log_file'])
    if os.path.exists(cfg['logging']['error_log_file']):
        os.unlink(cfg['logging']['error_log_file'])
    cfg['logging'].update(logConfig)

    girder.logger = girder._setupLogger()

    return cfg['logging']
コード例 #4
0
 def configureLogging(self, logConfig={}, oneFile=False):
     cfg = config.getConfig()
     if oneFile:
         cfg['logging']['error_log_file'] = cfg['logging']['info_log_file']
     else:
         cfg['logging']['error_log_file'] = cfg['logging'][
             'original_error_log_file']
     self.infoFile = cfg['logging']['info_log_file']
     self.errorFile = cfg['logging']['error_log_file']
     if os.path.exists(self.infoFile):
         os.unlink(self.infoFile)
     if os.path.exists(self.errorFile):
         os.unlink(self.errorFile)
     cfg['logging'].update(logConfig)
     cfg = config.getConfig()
     girder.logger = girder._setupLogger()
コード例 #5
0
def configureLogging(logConfig={}, oneFile=False):
    cfg = config.getConfig()
    if oneFile:
        cfg['logging']['error_log_file'] = cfg['logging']['info_log_file']
    else:
        cfg['logging']['error_log_file'] = cfg['logging'][
            'original_error_log_file']
    if os.path.exists(cfg['logging']['info_log_file']):
        os.unlink(cfg['logging']['info_log_file'])
    if os.path.exists(cfg['logging']['error_log_file']):
        os.unlink(cfg['logging']['error_log_file'])
    cfg['logging'].update(logConfig)

    girder.logger = girder._setupLogger()

    return cfg['logging']
コード例 #6
0
ファイル: logging_config_test.py プロジェクト: nagyist/girder
    def setUp(self):
        cfg = config.getConfig()
        cfg['logging'].update({
            'log_access': ['screen', 'info'],
            'log_quiet': True,
            'log_max_size': '1 kb',
            'log_backup_count': 2,
            'log_level': 'DEBUG',
        })
        self.infoFile = cfg['logging']['info_log_file']
        self.errorFile = cfg['logging']['error_log_file']
        girder.logger = girder._setupLogger()
        base.startServer()
        base.TestCase.setUp(self)

        user = {
            'email': '*****@*****.**',
            'login': '******',
            'firstName': 'First',
            'lastName': 'Last',
            'password': '******'
        }
        self.admin = self.model('user').createUser(**user)
コード例 #7
0
def mountServer(path,
                database=None,
                fuseOptions=None,
                quiet=False,
                plugins=None):
    """
    Perform the mount.

    :param path: the mount location.
    :param database: a database connection URI, if it contains '://'.
        Otherwise, the default database is used.
    :param fuseOptions: a comma-separated string of options to pass to the FUSE
        mount.  A key without a value is taken as True.  Boolean values are
        case insensitive.  For instance, 'foreground' or 'foreground=True' will
        keep this program running until the SIGTERM or unmounted.
    :param quiet: if True, suppress Girder logs.
    :param plugins: an optional list of plugins to enable.  If None, use the
        plugins that are configured.
    """
    if quiet:
        curConfig = config.getConfig()
        curConfig.setdefault('logging', {})['log_quiet'] = True
        curConfig.setdefault('logging', {})['log_level'] = 'FATAL'
        girder._setupLogger()
    if database and '://' in database:
        cherrypy.config['database']['uri'] = database
    if plugins is not None:
        plugins = plugins.split(',')
    webroot, appconf = configureServer(plugins=plugins)
    girder._setupCache()

    opClass = ServerFuse(stat=os.stat(path))
    options = {
        # By default, we run in the background so the mount command returns
        # immediately.  If we run in the foreground, a SIGTERM will shut it
        # down
        'foreground': False,
        # Cache files if their size and timestamp haven't changed.
        # This lets the OS buffer files efficiently.
        'auto_cache': True,
        # We aren't specifying our own inos
        'use_ino': False,
        # read-only file system
        'ro': True,
    }
    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)