This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
openplotterCan.py UnboundLocalError: local variable 'data' referenced before assignme
#1
Hi

I've just installed openplotter-settings on ubuntu 22.04
I then installed CAN Bus 4.1.0-stable

when I press "open" to run it, I get the following dump on the console:

Traceback (most recent call last):
  File "/usr/bin/openplotter-can", line 11, in <module>
    load_entry_point('openplotterCan==4.1.0', 'console_scripts', 'openplotter-can')()
  File "/usr/lib/python3/dist-packages/openplotterCan/openplotterCan.py", line 1552, in main
    MyFrame().Show()
  File "/usr/lib/python3/dist-packages/openplotterCan/openplotterCan.py", line 94, in __init__
    self.pageSk()
  File "/usr/lib/python3/dist-packages/openplotterCan/openplotterCan.py", line 180, in pageSk
    self.readSk()
  File "/usr/lib/python3/dist-packages/openplotterCan/openplotterCan.py", line 190, in readSk
    if 'pipedProviders' in data:
UnboundLocalError: local variable 'data' referenced before assignment
Terminated


I am not really a Python expert, but I belive that a patch like the following could fix the problem (at least it looks like it fixed for me)

Code:
--- /usr/lib/python3/dist-packages/openplotterCan/openplotterCan.py-orig    2024-11-04 16:27:50.523849784 +0100
+++ /usr/lib/python3/dist-packages/openplotterCan/openplotterCan.py    2024-11-04 16:29:34.789978732 +0100
@@ -181,9 +181,9 @@

    def readSk(self):
        self.sklist = []
+        data = ''
        try:
            setting_file = self.platform.skDir+'/settings.json'
-            data = ''
            with open(setting_file) as data_file:
                data = ujson.load(data_file)
        except:pass

Thank you for your work

Bye
Reply
#2
Is Signal k installed from openplotter-signalk-installer app?
Reply
#3
Thank you for your reply

I deleted all the openplotter packages and reinstalled everything

As a matter of fact if I run openplotter-signalk-installer before installing and running "CAN bus", I don't get the error

Perhaps I did not understand this in the documentation but, if that is a pre-required step, maybe it could be enforced in the setup procedure

Thank you again
Reply
#4
You can not set any CAN device without Signal k server installed.

when you install openplotter-can, openplotter-signalk-installer gets also installed as dependency. Signal k server gets installed the first time you open openplotter-signalk-installer.

We may need some code to check if SK server is installed and generate an error message.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)