Dear All,
I´m running a .py script where the relevant part looks like this:
It´s a script that every time a message is received will show it. That works fine from a DOS prompt. So I´m trying to access it from within b4j via jshell:
I was hoping that it´d just sit there and output whenever a message comes through (haven´t found any examples where you´ll have to use a loop in such a situation, so I suppose this is how it works) but all I get is "true" and then the exitcode 1. In other words, I don´t get anything from stdout. As you can see I even added sys.stdout.write - originally there was only print. I´m no python expert at all though, so I don´t know if there´s more in the script which needs to be setup first before it will work, or it´s something I need to amend in b4j.
Any ideas?
Thanks!
PS: I do know about the jpython library, but read that it´s got its limitations and upon trying the example provided resulting in a file not found error, pointed out by another user as well but said to be fixed in a later version, I should I should stick to the above which I know works.
I´m running a .py script where the relevant part looks like this:
B4X:
def callback(update):
print('I received', update)
sys.stdout.write('I received stdout', update)
client.add_event_handler(callback)
client.idle()
It´s a script that every time a message is received will show it. That works fine from a DOS prompt. So I´m trying to access it from within b4j via jshell:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Show
shl.Initialize("shl", "python", Array As String("C:\python\telethon\telethontest.py"))
shl.RunWithOutputEvents(-1)
End Sub
Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
Log (StdOut)
Log (StdErr)
Log (ExitCode)
Log(Success)
End Sub
I was hoping that it´d just sit there and output whenever a message comes through (haven´t found any examples where you´ll have to use a loop in such a situation, so I suppose this is how it works) but all I get is "true" and then the exitcode 1. In other words, I don´t get anything from stdout. As you can see I even added sys.stdout.write - originally there was only print. I´m no python expert at all though, so I don´t know if there´s more in the script which needs to be setup first before it will work, or it´s something I need to amend in b4j.
Any ideas?
Thanks!
PS: I do know about the jpython library, but read that it´s got its limitations and upon trying the example provided resulting in a file not found error, pointed out by another user as well but said to be fixed in a later version, I should I should stick to the above which I know works.