webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit 9b38d111f4263267c1922ffcc89c778be98d1e46
parent b69bdefcc9c2d353fec6d1fe1c740b99158a43be
Author: Sheng <webmaster0115@gmail.com>
Date:   Sun, 26 Aug 2018 19:31:45 +0800

Use class attribute formater

Diffstat:
Mwebssh/handler.py | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/webssh/handler.py b/webssh/handler.py @@ -44,6 +44,8 @@ class InvalidException(Exception): class MixinHandler(object): + formater = 'Missing value {}' + def write_error(self, status_code, **kwargs): exc_info = kwargs.get('exc_info') if exc_info and len(exc_info) > 1: @@ -52,10 +54,10 @@ class MixinHandler(object): self._reason = info.split(':', 1)[-1].strip() super(MixinHandler, self).write_error(status_code, **kwargs) - def get_value(self, name, formater='Missing value {}'): + def get_value(self, name): value = self.get_argument(name) if not value: - raise InvalidException(formater.format(name)) + raise InvalidException(self.formater.format(name)) return value def get_real_client_addr(self): @@ -262,7 +264,7 @@ class WsockHandler(MixinHandler, tornado.websocket.WebSocketHandler): self.src_addr = self.get_client_addr() logging.info('Connected from {}:{}'.format(*self.src_addr)) try: - worker_id = self.get_value('id', formater=self.formater) + worker_id = self.get_value('id') except (tornado.web.MissingArgumentError, InvalidException) as exc: self.close(reason=str(exc).split(':', 1)[-1].strip()) else: