예제 #1
0
def test_flaw_basic():
    app = create_app(_EXAMPLE_TB, [__file__])

    cl = app.get_local_client()

    resp = cl.get('/')
    assert resp.status_code == 200
    assert 'plarp' in resp.get_data(True)
예제 #2
0
파일: server.py 프로젝트: waytai/clastic
def restart_with_reloader():
    to_mon = []
    while 1:
        _log('info', ' * Clastic restarting with reloader')
        args = [sys.executable] + sys.argv
        new_environ = os.environ.copy()
        new_environ['WERKZEUG_RUN_MAIN'] = 'true'
        if os.name == 'nt':
            for key, value in new_environ.iteritems():
                if isinstance(value, unicode):
                    new_environ[key] = value.encode('iso-8859-1')
        stderr_buff = []
        child_proc = subprocess.Popen(args, env=new_environ, stderr=subprocess.PIPE)
        rf = child_proc.stderr
        exit_code, lines = None, []
        while exit_code is None or lines:
            if child_proc.poll() is None:
                lines.append(rf.readline())
            elif exit_code is None:
                lines.extend(rf.readlines())
                exit_code = child_proc.returncode
                if not lines:
                    break
            cur_line = lines.pop(0)
            if cur_line.startswith(_MON_PREFIX):
                to_mon = literal_eval(cur_line[len(_MON_PREFIX):])
            else:
                sys.stderr.write(cur_line)
                stderr_buff.append(cur_line)
                if len(stderr_buff) > _STDERR_BUFF_SIZE:
                    stderr_buff.pop(0)

        if exit_code == 3:
            continue
        elif exit_code == 1 and stderr_buff:
            enable_tty_echo()
            from clastic import flaw
            tb_str = ''.join(stderr_buff)
            err_app = flaw.create_app(tb_str, to_mon)
            # TODO: these values should be passed through
            err_server = make_server('localhost', 5000, err_app)
            thread.start_new_thread(err_server.serve_forever, ())
            try:
                reloader_loop(to_mon, 1)
            except KeyboardInterrupt:
                return 0
            except SystemExit as se:
                if se.code == 3:
                    continue
                return se.code
            finally:
                err_server.shutdown()
                err_server.server_close()
            return 0
        else:
            return exit_code
예제 #3
0
파일: server.py 프로젝트: sshmendez/clastic
 def serve_error_app(tb_str, monitored_files):
     from clastic import flaw
     err_app = flaw.create_app(tb_str, monitored_files)
     err_server = make_server(hostname, port, err_app)
     thread.start_new_thread(err_server.serve_forever, ())
     return err_server
예제 #4
0
 def serve_error_app(tb_str, monitored_files):
     from clastic import flaw
     err_app = flaw.create_app(tb_str, monitored_files)
     err_server = make_server(hostname, port, err_app)
     thread.start_new_thread(err_server.serve_forever, ())
     return err_server