weewx--4.0.0b16: SyntaxError: invalid syntax

116 views
Skip to first unread message

Gert Andersen

unread,
Mar 17, 2020, 1:20:23 AM3/17/20
to weewx-development
Hi
Currently I'm running weewx 3.9.2 and mqtt on a Raspberry system  and I'm trying to setup a test system for weewx 4 with mqtt.

I have followed the weewx 4 installation instructions and used this link https://github.com/weewx/weewx/wiki/mqtt for installing mqtt. I have been searching to see if mqtt should be installed differently using weewx 4(Python 3), but can't find any advises. 

Starting weewx gives this error:

Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__: Caught unrecoverable exception:
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****  invalid syntax (mqtt.py, line 197)
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****  Traceback (most recent call last):
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****    File "/home/weewx/bin/weewxd", line 148, in main
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****      engine = weewx.engine.StdEngine(config_dict)
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/engine.py", line 75, in                      __init__
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****      self.loadServices(config_dict)
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/engine.py", line 136, i                     n loadServices
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****      obj = weeutil.weeutil.get_object(svc)(self,config                     _dict)
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****    File "/home/weewx/bin/weeutil/weeutil.py", line 109                     3, in get_object
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****      mod = __import__(module)
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****    File "/home/weewx/bin/user/mqtt.py", line 197
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****      except KeyError, e:
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****                     ^
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****  SyntaxError: invalid syntax
Mar 16 21:17:45 weewx4Test weewx[2305] CRITICAL __main__:     ****  Exiting.

Gert

Thomas Keffer

unread,
Mar 17, 2020, 8:24:27 AM3/17/20
to Gert Andersen, weewx-development
It looks like the mqtt extension has not been ported to Python 3. 

You'll have to talk to the extension author about that.

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/7435406f-8193-46a6-9f79-af59af70bc02%40googlegroups.com.

Paul McGeorge

unread,
Mar 17, 2020, 8:34:04 AM3/17/20
to weewx-development
There is a newer version on Github, looks like it has been fixed for python 3 https://github.com/matthewwall/weewx-mqtt

Gert Andersen

unread,
Mar 17, 2020, 10:24:05 AM3/17/20
to weewx-development

Hi

Thanks a lot. I'll try the new version

Gert

Gert Andersen

unread,
Mar 17, 2020, 11:48:55 AM3/17/20
to weewx-development
Hi
Downloaded the version as recommended, https://github.com/matthewwall/weewx-mqtt, it is version 0.20

Still problems, so Imight have missed something.

Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__: Caught unrecoverable exception:
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****  invalid syntax (mqtt.py, line 215)
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****  Traceback (most recent call last):
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****    File "/home/weewx/bin/weewxd", line 148, in main
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****      engine = weewx.engine.StdEngine(config_dict)
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/engine.py", line 75, in __init__
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****      self.loadServices(config_dict)
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/engine.py", line 136, in loadServices
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****      obj = weeutil.weeutil.get_object(svc)(self,config_dict)
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****    File "/home/weewx/bin/weeutil/weeutil.py", line 1093, in get_object
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****      mod = __import__(module)
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****    File "/home/weewx/bin/user/mqtt.py", line 215
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****      except KeyError, e:
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****                     ^
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****  SyntaxError: invalid syntax
Mar 17 16:39:05 weewx4Test weewx[6055] CRITICAL __main__:     ****  Exiting.

Vince Skahan

unread,
Mar 17, 2020, 1:16:48 PM3/17/20
to weewx-development
Run the extension through "2to3 -w" and it will convert it to a python3-compatible content.  Worked fine here for me on version 0.18 of that extension.

Gert Andersen

unread,
Mar 17, 2020, 5:10:56 PM3/17/20
to weewx-development
Hi

Thanks for your help. I have just used the online 2to3 converter and just getting a new error:

Mar 17 22:05:25 weewx4Test weewx[7169] INFO user.mqtt: service version is 0.20
Mar 17 22:05:25 weewx4Test weewx[7169] INFO user.mqtt: binding to ['archive', 'loop']
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__: Caught unrecoverable exception:
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****  name 'queue' is not defined
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****  Traceback (most recent call last):
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****    File "/home/weewx/bin/weewxd", line 148, in main
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****      engine = weewx.engine.StdEngine(config_dict)
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/engine.py", line 75, in __init__
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****      self.loadServices(config_dict)
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/engine.py", line 136, in loadServices
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****      obj = weeutil.weeutil.get_object(svc)(self,config_dict)
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****    File "/home/weewx/bin/user/mqtt.py", line 259, in __init__
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****      self.archive_queue = queue.Queue()
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****  NameError: name 'queue' is not defined
Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****  Exiting.

Gert

Vince Skahan

unread,
Mar 17, 2020, 5:50:41 PM3/17/20
to weewx-development

Mar 17 22:05:25 weewx4Test weewx[7169] CRITICAL __main__:     ****  name 'queue' is not defined



You're not working off the latest version on github it seems

The top of the old file has a line saying simply "import queue".
The top of the new version has python3 and python2 supported

Download the current file https://raw.githubusercontent.com/matthewwall/weewx-mqtt/master/bin/user/mqtt.py and install it in place of your messed up one.  It should work.



Gert Andersen

unread,
Mar 18, 2020, 1:45:10 AM3/18/20
to weewx-development
Hi Vince 

Thanks for looking.

I have downloaded mqtt.py from the link you mentioned and installed it. Still syntax error at line 215

If you look at line 215, you have:
except KeyError, e:
and I think it should be
except KeyError as e:
under Python 3

Even if I change that line, I just get another error.

So, I might do something wrong, but I can't see what. If you got this working, you must have done something differently

Gert

Thomas Keffer

unread,
Mar 18, 2020, 7:14:51 AM3/18/20
to Gert Andersen, weewx-development
He's right. The extension has not been completely ported over to Python 3.


--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.

Thomas Keffer

unread,
Mar 18, 2020, 7:49:41 AM3/18/20
to Gert Andersen, weewx-development
Try this version.


mqtt.py

mwall

unread,
Mar 18, 2020, 8:30:53 AM3/18/20
to weewx-development
the weewx-mqtt extension has been updated to version 0.21:


comments in the code illustrate how to use most of the options:


this includes fixes for:

* python3 compatibility
* weewx4 compatibility
* qos option

thanks to tsoodla, Stormwind99, tkeffer, and others.

m

Gert Andersen

unread,
Mar 18, 2020, 9:34:28 AM3/18/20
to weewx-development
Hi

Up and running, everything is fine and working.

Thanks a lot to you all for great support.

Gert
Reply all
Reply to author
Forward
0 new messages