Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. exec Rückgabewerte aus Python Script nutzen

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    exec Rückgabewerte aus Python Script nutzen

    This topic has been deleted. Only users with topic management privileges can see it.
    • knallt
      knallt last edited by

      Hallo Zusammen,

      ich versuche über ein einfaches Script den Rückgabewert aus einem Python Script zu nutzen.
      Das Blocky Script sieht wie folgt aus:

      Bildschirmfoto 2020-01-02 um 01.50.30.png

      Das Python Script:

      #!/usr/bin/python3
      # import packages
      import cv2
      from pyzbar import pyzbar
      
      # define path
      path = "free-qr-code-scanner-20340-3.jpg"
      # load image
      image = cv2.imread(path)
      # find QR and barcodes within the image
      barcodes = pyzbar.decode(image)
      
      for barcode in barcodes:
              bc = barcode.data.decode('utf8') 
              print (bc)
      

      In der Konsolte bekomme ich meine Ausgabe:

      pi@raspberrypi:/home/iobroker/qr $ sudo python3 /home/iobroker/qr/qr.py 
      Miau
      

      Die Rechte für Python etc. sind richtig gesetzt. Denn wenn ich den Code im Script bspw. auf eine einfach Print-Ausgabe anpasse:

      print ("Test123")
      

      bekomme ich den Rückgabewert.

      Hier die Ausgaben in der Konsole:

      01:42:04.025	info	javascript.0 (8965) Stop script script.js.standard.Barcode.Test1
      01:42:26.987	info	javascript.0 (8965) Start javascript script.js.standard.Barcode.Test1
      01:42:26.995	info	javascript.0 (8965) script.js.standard.Barcode.Test1: exec: python3 /home/iobroker/qr/qr.py
      01:42:27.019	info	javascript.0 (8965) script.js.standard.Barcode.Test1: registered 0 subscriptions and 0 schedules
      01:42:30.098	info	javascript.0 (8965) script.js.standard.Barcode.Test1: setForeignState(id=owndata.test.qr, state="")
      01:42:37.431	info	javascript.0 (8965) Stop script script.js.standard.Barcode.Test1
      

      Für den einfachen print():

      01:57:20.997	info	javascript.0 (8965) Start javascript script.js.standard.Barcode.Test1
      01:57:21.000	info	javascript.0 (8965) script.js.standard.Barcode.Test1: exec: python3 /home/iobroker/qr/qr2.py
      01:57:21.012	info	javascript.0 (8965) script.js.standard.Barcode.Test1: registered 0 subscriptions and 0 schedules
      01:57:21.075	info	javascript.0 (8965) script.js.standard.Barcode.Test1: setForeignState(id=owndata.test.qr, state="Test123\n")
      

      Habe nun versucht alle möglichen Kodierungen etc. anzupassen. Leider komme ich nicht auf die Lösung.

      Das Script scannt einen Barcode - die Rückgabe in der Konsole dauert ca. 3-4 Sekunden.

      Hat jemand eine Idee wie ich das Python Script und die Ausgabe anpassen muss um die Ergebnisse einlesen zu können?

      knallt 1 Reply Last reply Reply Quote 0
      • knallt
        knallt @knallt last edited by

        Folgende Error-Meldung habe ich:

        javascript.0 (8965) script.js.standard.Barcode.Test1: Error: Command failed: python3 /home/iobroker/qr/qr.py Traceback (most recent call last): File "/home/iobroker/qr/qr.py", line 12, in <module> barcodes = pyzbar.decode(image) File "/usr/local/lib/python3.7/dist-packages/pyzbar/pyzbar.py", line 181, in decode pixels, width, height = _pixel_data(image) File "/usr/local/lib/python3.7/dist-packages/pyzbar/pyzbar.py", line 147, in _pixel_data pixels, width, height = image TypeError: cannot unpack non-iterable NoneType object
        

        Obwohl das Script in der Konsole funktioniert.

        Jemand eine Idee?

        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Support us

        ioBroker
        Community Adapters
        Donate

        971
        Online

        31.9k
        Users

        80.1k
        Topics

        1.3m
        Posts

        blockly
        1
        2
        1146
        Loading More Posts
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes
        Reply
        • Reply as topic
        Log in to reply
        Community
        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
        The ioBroker Community 2014-2023
        logo