Error Python : Return name Error Topic is solved

Python and python framework

Moderator: leecollings

Post Reply
St7ven
Posts: 22
Joined: Friday 10 March 2017 9:27
Target OS: Windows
Domoticz version:
Contact:

Error Python : Return name Error

Post by St7ven »

Hi,

I get this error : Error: (Controler) 'onMessage' failed 'NameError'. But I can retrieve the name that make this error.

In a python, the name usually follow the error. How could I bring up the faulty name ?
Last edited by St7ven on Wednesday 29 March 2017 16:55, edited 1 time in total.
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Error Python : Return name Error

Post by Dnpwwo »

@St7ven,

The Python framework will return all the information it can but sometimes Python does not make a traceback or the details available.

I would suggest added an error handler something like this around your onMessage function:

Code: Select all

    def onMessage(self, Data, Status, Extra):
        strData = Data.decode("utf-8", "ignore")
        try:
        
...your code here...

        except Exception as inst:
            Domoticz.Error("Exception in onMessage, called with Data: '"+str(strData)+"'")
            Domoticz.Error("Exception detail: '"+str(inst)+"'")
            raise
a construct like that has given me more detail and may help you out.

The 'raise' at the end will pass the error back to Domoticz.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
St7ven
Posts: 22
Joined: Friday 10 March 2017 9:27
Target OS: Windows
Domoticz version:
Contact:

Re: Error Python : Return name Error

Post by St7ven »

Thank you Dnpwwo,

It helps a lot !
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest