mirror of
https://github.com/xcat2/confluent.git
synced 2025-01-12 18:59:06 +00:00
Fix python3 problem with backspace
In python3, a single element reference of a bytes is an int, not equal to a b'' of the same length and value. Change to use slices to have python2 and python3 act the same.
This commit is contained in:
parent
4722c3ec92
commit
5b1e144d32
@ -169,11 +169,11 @@ class SshShell(conapi.Console):
|
||||
self.datacallback(conapi.ConsoleEvent.Disconnect)
|
||||
return
|
||||
elif self.inputmode == -1:
|
||||
while len(data) and data[0] == b'\x7f' and len(self.keyaction):
|
||||
while len(data) and data[0:1] == b'\x7f' and len(self.keyaction):
|
||||
self.datacallback('\b \b') # erase previously echoed value
|
||||
self.keyaction = self.keyaction[:-1]
|
||||
data = data[1:]
|
||||
while len(data) and data[0] == b'\x7f':
|
||||
while len(data) and data[0:1] == b'\x7f':
|
||||
data = data[1:]
|
||||
while b'\x7f' in data:
|
||||
delidx = data.index(b'\x7f')
|
||||
@ -195,11 +195,11 @@ class SshShell(conapi.Console):
|
||||
elif len(data) > 0:
|
||||
self.datacallback(data)
|
||||
elif self.inputmode == 0:
|
||||
while len(data) and data[0] == b'\x7f' and len(self.username):
|
||||
while len(data) and data[0:1] == b'\x7f' and len(self.username):
|
||||
self.datacallback('\b \b') # erase previously echoed value
|
||||
self.username = self.username[:-1]
|
||||
data = data[1:]
|
||||
while len(data) and data[0] == b'\x7f':
|
||||
while len(data) and data[0:1] == b'\x7f':
|
||||
data = data[1:]
|
||||
while b'\x7f' in data:
|
||||
delidx = data.index(b'\x7f')
|
||||
@ -216,7 +216,7 @@ class SshShell(conapi.Console):
|
||||
# echo back typed data
|
||||
self.datacallback(data)
|
||||
elif self.inputmode == 1:
|
||||
while len(data) > 0 and data[0] == b'\x7f':
|
||||
while len(data) > 0 and data[0:1] == b'\x7f':
|
||||
self.password = self.password[:-1]
|
||||
data = data[1:]
|
||||
while b'\x7f' in data:
|
||||
@ -237,4 +237,4 @@ class SshShell(conapi.Console):
|
||||
|
||||
def create(nodes, element, configmanager, inputdata):
|
||||
if len(nodes) == 1:
|
||||
return SshShell(nodes[0], configmanager)
|
||||
return SshShell(nodes[0], configmanager)
|
||||
|
Loading…
x
Reference in New Issue
Block a user