From 2a8d945470ff5128d44b08b78b0c4f8ef1b8b8fb Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 14 Jul 2024 20:35:06 +0800 Subject: [PATCH] bugfix --- ahserver/globalEnv.py | 2 ++ ahserver/websocketProcessor.py | 17 +++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ahserver/globalEnv.py b/ahserver/globalEnv.py index 3b08bba..f1b4561 100755 --- a/ahserver/globalEnv.py +++ b/ahserver/globalEnv.py @@ -18,6 +18,7 @@ from appPublic.dictObject import DictObject from appPublic.Singleton import GlobalEnv from appPublic.argsConvert import ArgsConvert from appPublic.timeUtils import str2Date,str2Datetime,curDatetime,getCurrentTimeStamp,curDateString, curTimeString +from appPublic.dataencoder import quotedstr from appPublic.folderUtils import folderInfo from appPublic.uniqueID import setNode,getID from appPublic.unicoding import unicoding,uDict,uObject @@ -191,6 +192,7 @@ def initEnv(): g.get_definition = get_definition g.DictObject = DictObject g.async_sleep = asyncio.sleep + g.quotedstr = quotedstr def set_builtins(): all_builtins = [ i for i in dir(builtins) if not i.startswith('_')] diff --git a/ahserver/websocketProcessor.py b/ahserver/websocketProcessor.py index c753568..f474e8b 100755 --- a/ahserver/websocketProcessor.py +++ b/ahserver/websocketProcessor.py @@ -9,7 +9,7 @@ from traceback import print_exc from appPublic.sshx import SSHNode from .baseProcessor import BaseProcessor, PythonScriptProcessor -class XtermProcessor(BaseProcessor): +class XtermProcessor(PythonScriptProcessor): @classmethod def isMe(self,name): return name=='xterm' @@ -31,13 +31,15 @@ class XtermProcessor(BaseProcessor): await self.path_call(request) async def path_call(self, request, params={}): - await self.set_run_env(request) - lenv = self.run_ns.copy() - lenv.update(params) - del lenv['request'] + # + # xterm file is a python script as dspy file + # it must return a DictObject with sshnode information + # parameters: nodeid + # + login_info = super().path_call(request, params=params) ws = web.WebSocketResponse() await ws.prepare(request) - await self.create_process() + await self.create_process(login_info) self.ws_sendstr(ws, 'Welcom to sshclient') r1 = self.ws_2_process(ws) r2 = self.process_2_ws(ws) @@ -51,9 +53,8 @@ class XtermProcessor(BaseProcessor): self.login_info = json.loads(txt) # print(f'{self.login_info=}') - async def create_process(self): + async def create_process(self, lgoin_info): # id = lenv['params_kw'].get('termid') - await self.get_login_info() host = self.login_info['host'] port = self.login_info.get('port', 22) username = self.login_info.get('username', 'root')