This commit is contained in:
yumoqing 2023-09-18 13:50:11 +08:00
parent 1dda35ee37
commit 277d442acc

View File

@ -98,7 +98,7 @@ class SSHNode:
async def _cmd(self, cmd, input=None, stdin=None, stdout=None): async def _cmd(self, cmd, input=None, stdin=None, stdout=None):
return await self.conn.run(cmd, input=input, stdin=stdin, stdout=stdout) return await self.conn.run(cmd, input=input, stdin=stdin, stdout=stdout)
async def _xcmd(self, cmd, xmsgs=[]): async def _xcmd(self, cmd, xmsgs=[], ns={}):
proc = await self._process(cmd, term_type='xterm', proc = await self._process(cmd, term_type='xterm',
term_size=(80,24), term_size=(80,24),
encoding='utf-8' encoding='utf-8'
@ -109,7 +109,8 @@ class SSHNode:
for i in range(msglen): for i in range(msglen):
if xmsgs[i][0]: if xmsgs[i][0]:
break break
proc.stdin.write(xmsgs[i][1]) s = xmsgs[i][1].format(**ns)
proc.stdin.write(s)
while True: while True:
if proc.stdout.at_eof(): if proc.stdout.at_eof():
@ -119,10 +120,11 @@ class SSHNode:
if i >= msglen: if i >= msglen:
continue continue
k = xmsgs[i][0] k = xmsgs[i][0].format(**ns)
kin = buffer.split(xmsgs[i][0], 1) kin = buffer.split(k, 1)
if len(kin) > 1: if len(kin) > 1:
proc.stdin.write(xmsgs[i][1]) s = xmsgs[i][1].format(**ns)
proc.stdin.write(s)
await proc.stdin.drain() await proc.stdin.drain()
buffer = kin[1] buffer = kin[1]
i += 1 i += 1