This commit is contained in:
yumoqing 2024-07-14 20:35:06 +08:00
parent 4e66ec52c3
commit 2a8d945470
2 changed files with 11 additions and 8 deletions

View File

@ -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('_')]

View File

@ -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')