B4J Question Shell - Python output

JanPRO

Well-Known Member
Licensed User
Hi,

currently I am using B4J on my raspberry.
I am using Shell to execute python scripts and get the output, but here is the problem: I didn't get any output ...

Example test.py:
B4X:
import time
while True:
    print("test")
    time.sleep(1)

B4J code:

B4X:
Sub StartTest
    Dim shl As Shell
    shl.Initialize("shl","python",Array("/.../.../test.py"))
    shl.RunWithOutputEvents(-1)
End Sub

Sub shl_StdOut (Buffer() As Byte, Length As Int)
    Dim Output As String = BytesToString(Buffer,0,Length,"UTF-8")
    Log(Output)
End Sub

Sub shl_StdErr (Buffer() As Byte, Length As Int)
    Dim Output As String = BytesToString(Buffer,0,Length,"UTF-8")
    Log(Output)
End Sub

I hope someone can help me :)

Have a nice weekend

Jan
 

walterf25

Expert
Licensed User
Hi,

I have just copy paste the code from here: https://stackoverflow.com/a/107717/5489789 to the top of my code.

Jan
I have this:
JavaScript:
'''  function execute(Kind, ID) {
'''    return gapi.client.datastore.projects.lookup({
'''      "projectId": "snaplab-993",
'''      "resource": {
'''        "readOptions": {
'''          "readConsistency": "EVENTUAL"
'''        },
'''        "keys": [
'''          {
'''            "path": [
'''              {
'''                "kind": Kind,
'''                "id": ID
'''              }
'''            ],
'''            "partitionId": {
'''              "namespaceId": "current_drain_data",
'''              "projectId": "snaplab-993"
'''            }
'''          }
'''        ]
'''      }
'''    })
'''        .then(function(response) {
'''                // Handle the results here (response.result has the parsed body).
'''                console.log("Response", JSON.parse(response.body));
'''                return JSON.parse(response.body);
'''              },
'''              function(err) { console.error("Execute error", err); });
'''       
'''  }
 
Upvote 0
Top