UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    How to debug python app?

    Scheduled Pinned Locked Moved Solved App Development
    2 Posts 1 Posters 459 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K Offline
      Kamisori
      last edited by

      Hi.
      Host: Ubuntu 22.04 x86_64
      Device: Pixel 3a, Ubuntu 20.04
      Clickable: 8.0.1

      I'm trying to install an openconnect client on my phone. If I solve the challenge from the shell side, then there is a problem with the interface.
      I installed clickable with the “QML only” profile (according to the documentation at https://docs.innerzaurus.com/en/latest/tools/clickable.html).
      I created a simple interface with a Python call on click.
      Everything works on emulation, but not on the phone.
      The function with a simple print statement works, but with the subshell call it does not, even with a try-except attached.
      How can I display the error? Or should I call the shell differently? (To be honest, I don’t really need Python. I can perform all the logical steps in bash.)

      main.qml

      import QtQuick 2.0
      import io.thp.pyotherside 1.0
      
      Rectangle {
          width: 640; height: 480
          color: "#E95420"
          Text {
              id: label
              font.family: "Ubuntu Mono"
              font.pixelSize: 32
              text: "[Nothing here yet]"
              anchors {
                  top: parent.top
                  left: parent.left
              }
              color: "white"
          }
          MouseArea {
              anchors.fill: parent
              onClicked: {
                  py.addImportPath(Qt.resolvedUrl("."));
                  py.importModule("hello", function(){
                      label.text = py.call_sync("hello.run_netstat_output");
                  });
              }
          }
          Python { id: py }
      }
      

      hello. py

      import subprocess
      
      # hello.py
      
      def hello_world():
          return "Hello from Python!"
      
      
      def return_shell_output(cmd):
          try:
              out = subprocess.check_output(cmd, shell=True)
              return out.decode("utf-8")
          except subprocess.CalledProcessError as e:
              return f"Error executing command: {e}"
      
      def run_netstat_output():
          return return_shell_output("ls -l") # ls is for the test purpose
      
      1 Reply Last reply Reply Quote 0
      • K Offline
        Kamisori
        last edited by

        Here I am with answer to the my own question.
        RTFM!
        clickable log command very useful. 🙂

        1 Reply Last reply Reply Quote 1
        • arubislanderA arubislander marked this topic as a question on
        • arubislanderA arubislander has marked this topic as solved on

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post