wewa00 / modbus-tk

Automatically exported from code.google.com/p/modbus-tk
Other
0 stars 0 forks source link

Error trying master_webhmi.py #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, I'm from Valencia, Spain.
I'm working on an Efficiency Energy project and I have to publish on the
Internet the data from some modbus energy meters like this one
(http://www.gavazzionline.com/pdf/EM2172DDS.pdf).

I'm trying to test your code. I don't know too much about python but I have
this error when trying the HMI you provide in r106:

$ python master_webhmi.py 
master_webhmi.py:46: Warning: 'with' will become a reserved keyword in
Python 2.6
  File "master_webhmi.py", line 46
    with self._get.db() as conn:
            ^
SyntaxError: invalid syntax

I'm using Debian with Python 2.5.2 and I have sqlite3 and python-sqlite2
installed.

Original issue reported on code.google.com by vicn...@gmail.com on 16 Apr 2010 at 12:56

GoogleCodeExporter commented 8 years ago
Hello Valencia,

I think that the problem comes from the with statement which is a future 
feature of
Python 2.5. Sorry for that. HMI is still a dev in progress and was not fully 
tested
with Python 2.5. (I'm developping with Python 2.6)

Try to add the following line on top of the master_webhmi.py

from __future__ import with_statement

let me know if it fixes the problem.

Best Regards
luc

Original comment by luc.jean@gmail.com on 16 Apr 2010 at 1:10

GoogleCodeExporter commented 8 years ago
hi luc. Yes, it worked.

I think I have to move to python 2.6 to continue testing because now I have 
another
error:

$ python master_webhmi.py Traceback (most recent call last):
  File "master_webhmi.py", line 123, in <module>
    APP = App()
  File "master_webhmi.py", line 108, in __init__
    self._db = Persistence()
  File "master_webhmi.py", line 46, in __init__
    with self._get.db() as conn:
AttributeError: Persistence instance has no attribute '_get'

I'm also very interested in your comment about Django. Maybe very useful to me. 
I
will follow your advances.

Thanks.

Original comment by vicn...@gmail.com on 16 Apr 2010 at 1:43

GoogleCodeExporter commented 8 years ago
Did you try to modify the code because it should be:

with self._get_db() as conn: and not _get.db()

It may be the cause of the error.

I am working a lot with Django and I like it very much. Unfortunately, this 
part of
the project is still in my head and I shouldn't be able to work on it in the 
coming
weeks.

What kind of projects do tou want to do? Push some data into a database on the 
internet?

Best Regards

Original comment by luc.jean@gmail.com on 16 Apr 2010 at 2:02

GoogleCodeExporter commented 8 years ago
I've committed the fix on rev 108
Can you please update your code and tell me if it works ok now?
Best Regards

Original comment by luc.jean@gmail.com on 16 Apr 2010 at 2:09

GoogleCodeExporter commented 8 years ago
Oups! forgot to change the status of this issue :)

Original comment by luc.jean@gmail.com on 16 Apr 2010 at 2:10

GoogleCodeExporter commented 8 years ago
Hi luc.

Testing r108 in my 2.5.2 Python system now I have this AttributeError:

$ python master_webhmi.py 
Traceback (most recent call last):
  File "master_webhmi.py", line 123, in <module>
    APP = App()
  File "master_webhmi.py", line 108, in __init__
    self._db = Persistence()
  File "master_webhmi.py", line 46, in __init__
    with self._get_db() as conn:
AttributeError: 'sqlite3.Connection' object has no attribute '__exit__'

(It works fine in Ubuntu 9.10 with Python 2.6)

Original comment by vicn...@gmail.com on 17 Apr 2010 at 6:49