Exemple #1
0
def _reloader_stat_loop(extra_files=None, interval=1):
    """When this function is run from the main thread, it will force other
    threads to exit when any modules currently loaded change.

    Copyright notice.  This function is based on the autoreload.py from
    the CherryPy trac which originated from WSGIKit which is now dead.

    :param extra_files: a list of additional files it should watch.
    """
    mtimes = {}
    while 1:
        for filename in chain(_iter_module_files(), extra_files or ()):
            try:
                mtime = os.stat(filename).st_mtime
            except OSError:
                continue

            old_time = mtimes.get(filename)
            if old_time is None:
                mtimes[filename] = mtime
                continue
            elif mtime > old_time:
                _log('info', ' * Detected change in %r, reloading' % filename)
                sys.exit(3)
        time.sleep(interval)
Exemple #2
0
def _reloader_stat_loop(extra_files=None, interval=1):
    """When this function is run from the main thread, it will force other
    threads to exit when any modules currently loaded change.

    Copyright notice.  This function is based on the autoreload.py from
    the CherryPy trac which originated from WSGIKit which is now dead.

    :param extra_files: a list of additional files it should watch.
    """
    mtimes = {}
    while 1:
        for filename in chain(_iter_module_files(), extra_files or ()):
            try:
                mtime = os.stat(filename).st_mtime
            except OSError:
                continue

            old_time = mtimes.get(filename)
            if old_time is None:
                mtimes[filename] = mtime
                continue
            elif mtime > old_time:
                _log('info', ' * Detected change in %r, reloading' % filename)
                sys.exit(3)
        time.sleep(interval)
Exemple #3
0
 def validate_layers(self, request):
     query_layers = request.params.query_layers if hasattr(
         request, 'query_layers') else []
     for layer in chain(request.params.layers, query_layers):
         if layer not in self.layers:
             raise RequestError('unknown layer: ' + str(layer),
                                code='LayerNotDefined',
                                request=request)
Exemple #4
0
 def validate_layers(self, request):
     query_layers = request.params.query_layers if hasattr(request, 'query_layers') else []
     for layer in chain(request.params.layers, query_layers):
         if layer not in self.layers:
             raise RequestError('unknown layer: ' + str(layer), code='LayerNotDefined',
                                request=request)