From a8d0ec4c3c9081e766174fc5f0e7bf5e57189b24 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 2 Nov 2013 13:25:56 -0400 Subject: [PATCH] Renome current console to consoleserver and refactor --- confluent/{console.py => consoleserver.py} | 15 --------------- confluent/httpapi.py | 4 ++-- confluent/interface/console.py | 15 +++++++++++++++ confluent/pluginapi.py | 4 ++-- confluent/sockapi.py | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) rename confluent/{console.py => consoleserver.py} (93%) create mode 100644 confluent/interface/console.py diff --git a/confluent/console.py b/confluent/consoleserver.py similarity index 93% rename from confluent/console.py rename to confluent/consoleserver.py index a7edab7d..b0d53a6e 100644 --- a/confluent/console.py +++ b/confluent/consoleserver.py @@ -14,21 +14,6 @@ import random _handled_consoles = {} -class Console(object): - """This is the class defining the interface a console plugin must return - for the _console/session element""" - def __init__(self, node, config): - raise NotImplementedException("Subclassing required") - - def connect(self, callback): - raise NotImplementedException("Subclassing required") - - def write(self, data): - raise NotImplementedException("Subclassing required") - - def wait_for_data(self, timeout=600): - raise NotImplementedException("Subclassing required") - class _ConsoleHandler(object): def __init__(self, node, configmanager): self._console = plugin.handle_path("/node/%s/_console/session" % node, diff --git a/confluent/httpapi.py b/confluent/httpapi.py index 9a146016..58bc28dc 100644 --- a/confluent/httpapi.py +++ b/confluent/httpapi.py @@ -6,7 +6,7 @@ import base64 import Cookie import confluent.auth as auth -import confluent.console as console +import confluent.consoleserver as consoleserver import confluent.pluginapi as pluginapi import confluent.util as util import eventlet @@ -159,7 +159,7 @@ def resourcehandler(env, start_response): _, _, nodename = prefix.rpartition('/') if 'session' not in querydict.keys() or not querydict['session']: # Request for new session - consession = console.ConsoleSession(node=nodename, + consession = consoleserver.ConsoleSession(node=nodename, configmanager=cfgmgr) if not consession: start_response("500 Internal Server Error", headers) diff --git a/confluent/interface/console.py b/confluent/interface/console.py new file mode 100644 index 00000000..36eeac1e --- /dev/null +++ b/confluent/interface/console.py @@ -0,0 +1,15 @@ +class Console(object): + """This is the class defining the interface a console plugin must return + for the _console/session element""" + def __init__(self, node, config): + raise NotImplementedException("Subclassing required") + + def connect(self, callback): + raise NotImplementedException("Subclassing required") + + def write(self, data): + raise NotImplementedException("Subclassing required") + + def wait_for_data(self, timeout=600): + raise NotImplementedException("Subclassing required") + diff --git a/confluent/pluginapi.py b/confluent/pluginapi.py index 50d9fd55..9666f7da 100644 --- a/confluent/pluginapi.py +++ b/confluent/pluginapi.py @@ -17,7 +17,7 @@ # functions. Console is special and just get's passed through # see API.txt -import confluent.console as console +import confluent.interface.console as console import os import sys @@ -99,7 +99,7 @@ def handle_path(path, operation, configmanager): nodes=(node,), element=element, configmanager=configmanager) if plugroute['default']: - passvalue pluginmap[plugroute['default']].__dict__[operation]( + passvalue = pluginmap[plugroute['default']].__dict__[operation]( nodes=(node,), element=element, configmanager=configmanager) if isinstance(passvalue, console.Console): return passvalue diff --git a/confluent/sockapi.py b/confluent/sockapi.py index 5b3d37c1..afc29ee4 100644 --- a/confluent/sockapi.py +++ b/confluent/sockapi.py @@ -5,7 +5,7 @@ # It implement unix and tls sockets # # TODO: SO_PEERCRED for unix socket -import confluent.console as console +import confluent.consoleserver as consoleserver import confluent.config as config import eventlet.green.socket as socket import eventlet.green.ssl as ssl @@ -44,7 +44,7 @@ def sessionhdl(connection, authname): print passphrase connection.sendall("Confluent -- v0 -- Session Granted\r\n/->") cfm = config.ConfigManager(tenant=0) - consession = console.ConsoleSession(node='n1', configmanager=cfm, + consession = consoleserver.ConsoleSession(node='n1', configmanager=cfm, datacallback=connection.sendall) while (1): data = connection.recv(4096)