[Twisted-Python] Getting splitted data with SSHChannel.dataReceived
Hi, I am using twisted conch to execute a remote program (say ProgA) through ssh. In ProgA, I print some datas and catch them in the dataReceived method of SSHChannel. Sometimes, the data comes partially, like this ProgA dataReceived ------------ -------------------------------- prints TWISTED gets TWISTED and appends it to TOTAL . . . prints TWISTED if len(TOTAL) is 1020 gets TWIS (gets at most 1024) => then gets TED (next time) I think there's a buffer of something else, so dataReceived couldn't get the datas as they are printed. They are splitted if TOTAL reaches 1024. I am looking for a solution to prevent getting splitted data. Any help is greatly appreciated. Greetings, Saki
On Thu, 23 Mar 2006 20:06:59 +0200, Mustafa Sakalsiz <mustafa@liqia.com> wrote:
Hi,
I am using twisted conch to execute a remote program (say ProgA) through ssh. In ProgA, I print some datas and catch them in the dataReceived method of SSHChannel.
Sometimes, the data comes partially, like this
ProgA dataReceived ------------ -------------------------------- prints TWISTED gets TWISTED and appends it to TOTAL . . . prints TWISTED if len(TOTAL) is 1020 gets TWIS (gets at most 1024) => then gets TED (next time)
I think there's a buffer of something else, so dataReceived couldn't get the datas as they are printed. They are splitted if TOTAL reaches 1024. I am looking for a solution to prevent getting splitted data.
If you want to treat your data as line-oriented, you should be using LineReceiver and overriding the lineReceived method. The dataReceived method is always subject to this kind of fragmentation. Jean-Paul
Yes, I am using line oriented datas. But, I am subclassing the twisted.consh.ssh.channel.SSHChannel, so how can I use a subclass of basic.LineReceiver to open a channel in SSHConnection. Jean-Paul Calderone wrote:
On Thu, 23 Mar 2006 20:06:59 +0200, Mustafa Sakalsiz <mustafa@liqia.com> wrote:
Hi,
I am using twisted conch to execute a remote program (say ProgA) through ssh. In ProgA, I print some datas and catch them in the dataReceived method of SSHChannel.
Sometimes, the data comes partially, like this
ProgA dataReceived ------------ -------------------------------- prints TWISTED gets TWISTED and appends it to TOTAL . . . prints TWISTED if len(TOTAL) is 1020 gets TWIS (gets at most 1024) => then gets TED (next time)
I think there's a buffer of something else, so dataReceived couldn't get the datas as they are printed. They are splitted if TOTAL reaches 1024. I am looking for a solution to prevent getting splitted data.
If you want to treat your data as line-oriented, you should be using LineReceiver and overriding the lineReceived method. The dataReceived method is always subject to this kind of fragmentation.
Jean-Paul
Mustafa Sakalsiz wrote:
Yes, I am using line oriented datas. But, I am subclassing the twisted.consh.ssh.channel.SSHChannel, so how can I use a subclass of basic.LineReceiver to open a channel in SSHConnection.
When inheritance fails, use ownership. class MyLineReceiver(basic.LineReceiver): def lineReceived(self, line): ... class MySSHChannel(channel.SSHChannel): def __init__(self, ...): ... self.protocol = MyLineReceiver() def dataReceived(self, data): self.protocol.dataReceived(data)
participants (3)
-
Jean-Paul Calderone -
Mustafa Sakalsiz -
Tommi Virtanen