error: Python argument types in

Posted on
Wed Feb 28, 2024 7:55 pm
dking4 offline
Posts: 27
Joined: Jan 24, 2018

error: Python argument types in

I'm having trouble with a script I'm writing to parse HTML values from an Arduino. It seems to work fine until I try to do write the values back to indigo variables. I am using multiple older python scripts that seem to use the same line of code (except for the variable number) with good results. Here is the code:

Code: Select all
import requests
from bs4 import BeautifulSoup

def extract_results_from_html(url):
   # Fetch the HTML content
   response = requests.get(url)

   # Check if request was successful
   if response.status_code == 200:
      # Parse HTML content
      soup = BeautifulSoup(response.text, 'html.parser')

      results = []
      # Iterate through each line
      for line in soup.get_text().splitlines():
         # Strip HTML tags from line
         line_text = BeautifulSoup(line, 'html.parser').get_text()
         # Split line into words
         words = line_text.split()
            # Iterate through each word
         for word in words:
            # Check if word is an integer
            if word.isdigit():
               results.append(int(word))
            else:
               results.append(word)

      return results
   else:
      print("Failed to retrieve page:", response.status_code)


# Example usage:
url = "http://172.25.26.66"
results = extract_results_from_html(url)

# Store results in variables A0 to A5

A0 = results[0]
A1 = results[1]
A2 = results[2]
A3 = results[3]
A4 = results[4]
A5 = results[5]

# Convert into string format for indigo
A0s = str(A0)
A1s = str(A1)
A2s = str(A2)
A3s = str(A3)
A4s = str(A4)
A5s = str(A5)

# Report to Indigo variables
indigo.variable.updateValue(1816959159, Value = A0s)
indigo.variable.updateValue(289908613, Value = A1s)
indigo.variable.updateValue(1985523585, Value = A2s)
indigo.variable.updateValue(1181240715, Value = A3s)
indigo.variable.updateValue(1619332420, Value = A4s)
indigo.variable.updateValue(1752480555, Value = A5s)

# Print to log
indigo.server.log(f"A0 = {A0s}")
indigo.server.log(f"A1 = {A1s}")
indigo.server.log(f"A2 = {A2s}")
indigo.server.log(f"A3 = {A3s}")
indigo.server.log(f"A4 = {A4s}")
indigo.server.log(f"A5 = {A5s}")


This returns this error in the log:
Code: Select all
   Script Error                    embedded script error:
   Script Error                    Python argument types in
    VariableCmds.updateValue(VariableCmds, int)
did not match C++ signature:
    updateValue(_VariableCmds {lvalue}, boost::python::api::object elem, CCString value)
   Script Error                    Exception Traceback (most recent call shown last):

     embedded script, line 56, at top level
ArgumentError: Python argument types in
    VariableCmds.updateValue(VariableCmds, int)
did not match C++ signature:
    updateValue(_VariableCmds {lvalue}, boost::python::api::object elem, CCString value)

When I comment out the "indigo.variable.updateValue(xxx, Value=xx) lines, The script executes and reports the following correct values.
Code: Select all
   Script                          A0 = 763
   Script                          A1 = 764
   Script                          A2 = 763
   Script                          A3 = 762
   Script                          A4 = 763
   Script                          A5 = 761

I'm sure it is something simple since I'm still pretty green with Python but I have stared at it for a long time now but can't seem to spot the problem. Any help is appreciated!

David

Posted on
Wed Feb 28, 2024 8:21 pm
dking4 offline
Posts: 27
Joined: Jan 24, 2018

Re: error: Python argument types in

Well, I found that I inadvertently capitalized the "value = xx" argument. When I fixed all of those, the script works as expected.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests