Ejemplo n.º 1
0
def reset():
    """ Restart the application.

    Note that this endpoint will never send a response, clients should take
    this into account and set a low timeout value.
    """
    import tornado.autoreload as autoreload
    autoreload._reload()
Ejemplo n.º 2
0
def update_default_config():
    current = app.config['default_config']
    new_values = json.loads(request.data)
    current._config.set(new_values)
    current.dump(current.cfg_path)
    if "core" in new_values or "web" in new_values:
        import tornado.autoreload as autoreload
        autoreload._reload()
    return ""
Ejemplo n.º 3
0
def _check_file(modify_times, path):
  try:
    modified = os.stat(path).st_mtime
  except Exception:
    return

  if path not in modify_times:
    modify_times[path] = modified
  elif modify_times[path] != modified:
    logging.info("%s modified; restarting server", path)
    reload(path, modify_times, modified)
    type = path.split('.')[-1] or 'py'
    if type in ['py', 'html', 'js']:  # restart with python,templete,javascript change only
      autoreload._reload()
    elif type == 'less':
      css_path = path.replace('.less', '.css')
      subprocess.call(['lessc', '-x', path, css_path], shell=False)
Ejemplo n.º 4
0
def update_default_config():
    """ Update global default configuration.

    If `core` or `web` settings were modified, the application will be
    restarted.

    :reqheader Content-Type: :mimetype:`application/json`

    :resheader Content-Type: :mimetype:`application/json`
    """
    # TODO: Validate input against option templates.
    current = app.config['default_config']
    new_values = json.loads(request.data)
    current._config.set(new_values)
    current.dump(current.cfg_path)
    if "core" in new_values or "web" in new_values:
        import tornado.autoreload as autoreload
        autoreload._reload()
    default_config = current.flatten()
    cache.set('default-config', default_config)
    return jsonify(default_config)