def main(): parser = argparse.ArgumentParser(description='Run the Web Console') parser.add_argument('--fd', help='FD', default=None) parser.add_argument('--host', help='Host', default='0.0.0.0') parser.add_argument('--port', help='port', default=8080) parser.add_argument('--server', help='web server to use', default=SocketIOServer) parser.add_argument('--endpoint', default=None, help='Circus Endpoint. If not specified, Circus will ask you which ' 'system you want to connect to') parser.add_argument('--version', action='store_true', default=False, help='Displays Circus version and exits.') parser.add_argument('--log-level', dest='loglevel', default='info', choices=LOG_LEVELS.keys() + [key.upper() for key in LOG_LEVELS.keys()], help="log level") parser.add_argument('--log-output', dest='logoutput', default='-', help="log output") parser.add_argument('--ssh', default=None, help='SSH Server') args = parser.parse_args() if args.version: print(__version__) sys.exit(0) # configure the logger configure_logger(logger, args.loglevel, args.logoutput) if args.endpoint is not None: connect_to_circus(args.endpoint, args.ssh) run(app, host=args.host, port=args.port, server=args.server, fd=args.fd)
def client_or_redirect(*fargs, **fkwargs): if ensure_client: client = get_client() session = get_session() if client is None: session = get_session() if session.get('endpoint', None) is not None: # XXX we need to pass SSH too here connect_to_circus(session['endpoint']) else: return redirect('/connect') return func(*fargs, **fkwargs)
def connect(): """Connects to the stats client, using the endpoint that's passed in the POST body. """ def _ask_connection(): return render_template('connect.html') if request.method == 'GET': return _ask_connection() elif request.method == 'POST': # if we got an endpoint in the POST body, store it. if request.forms.endpoint is None: return _ask_connection() endpoint = request.forms.endpoint client = connect_to_circus(endpoint) if not client.connected: set_message('Impossible to connect') redirect('/')