New setup script for pyswap

89 views
Skip to first unread message

Daniel Berenguer

unread,
Feb 21, 2012, 6:20:55 PM2/21/12
to pans...@googlegroups.com
I've just changed the internal package structure of pyswap in order to
work with the new install script. No more need to manually alter
PYTHONPATH. Now all we have to do is enter the pyswap directory and
run the following command:

python setup.py install

Under Linux you'll probably have to run the command as superuser.

So pyswap is now at version 0.1.3
As result, SWAPdmt and lagarto switch to 0.1.3 and 0.0.2 respectively.

Iulian-Marius

unread,
Feb 24, 2012, 1:31:19 PM2/24/12
to panstamp
After updating both pyswap and pyswapdmtgui I get the following error
when try to run pyswapdmtgui.py .
Of course is a windows system :).

Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\pyswapdmtgui\src
\pyswapdmtgui.py", line 34, in <module>
settings = os.path.join(os.path.dirname(__file__), "config",
"settings.xml")
NameError: name '__file__' is not defined

No luck running it from command line either.
Does __file__ needs to be defined for windows environment?

Daniel Berenguer

unread,
Feb 24, 2012, 4:45:29 PM2/24/12
to pans...@googlegroups.com
Mmmm... are you running pyswapdmtgui.py with py2exe? Anyway, I've
replaced "__file__" by "sys.argv[0]" in the main script. That should
solve the problem.

Iulian-Marius

unread,
Feb 24, 2012, 5:20:23 PM2/24/12
to panstamp
I'm running it from command line.
After updating the files via svn i'm getting the following error:

Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\pyswapdmtgui\src
\pyswapdmtgui.py", line 38, in <module>
manager = SwapManager(settings)
File "C:\Python27\Lib\site-packages\pyswapdmtgui\src
\SwapManager.py", line 175, in __init__
self.dmtframe = MainFrame("SWAP Device Management Tool", self,
server=self.server)
File "C:\Python27\Lib\site-packages\pyswapdmtgui\src\MainFrame.py",
line 126, in __init__
self.browser_panel = BrowserPanel(self, self.server.network.motes)
AttributeError: 'NoneType' object has no attribute 'network'

This is strange as the first version worked just fine. Is windows
related or python related (maybe need version 3+ or something...).

Daniel Berenguer

unread,
Feb 24, 2012, 6:20:21 PM2/24/12
to pans...@googlegroups.com
Well, I have not obviously done many tests on Windows :-(
I need to trace the problem on my Windows machine...

Iulian-Marius

unread,
Feb 25, 2012, 8:41:25 AM2/25/12
to panstamp
Is there any way to go back to a previous version ?
I can only find revision 496 on svn.

Daniel Berenguer

unread,
Feb 25, 2012, 10:02:49 AM2/25/12
to pans...@googlegroups.com
The easiest way is to checkout a new copy (after renaming or deleting
your currernt one) as follows:

svn checkout -r 485
http://panstamp.googlecode.com/svn/trunk/python/pyswap
/path/in/your/computer

where 485 is the revision number before applying the latest changes.

Otherwise, I'm currently trying to debug the problem on a Windows XP
PC so I hope to come back with results soon.

Daniel Berenguer

unread,
Feb 25, 2012, 5:01:13 PM2/25/12
to pans...@googlegroups.com
OK, found the problem. I don't know why but the tarfile module is
unable to uncompress devices.tar.gz under Windows. This tar.gz
contains all device definition files and is automatically downloaded
from the Web. Until I find a valid workaround, I recommend all Windows
users to set <devices><update> to false in config\settings.xml. Then,
copy your local copy of the "devices"folder to config\ or set
<devices><local> accordingly.

Daniel Berenguer

unread,
Feb 27, 2012, 9:50:52 AM2/27/12
to pans...@googlegroups.com
Solution found!

Windows seems to manage tar.gz files incorrectly, maybe for the double
compression format. Switched to single tar compression.

"svn update" pyswap and then do the same with pyswapdmtgui or change
"devices.tar.gz" to "devices.tar" in <settings><devices><remote>

Iulian-Marius

unread,
Mar 5, 2012, 3:30:49 PM3/5/12
to panstamp
Pyswap workin great now !!
And the fun begins... When i try to launch Lagarto I get the same
error in regards to _file_ nod defined:

Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\lagarto\lagarto-swap\lagarto-
swap.py", line 42, in <module>
settings = os.path.join(os.path.dirname(__file__), "config",
"settings.xml")
NameError: name '__file__' is not defined

I've replaced "__file__" by "sys.argv[0]" - necessary for windows by
the looks of it.
That seemed to solve it.

Now I get the following error:
SWAP server starting...
Downloading Device Definition Files
Unable to update Device Definition Files
SWAP server is now running...
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Python27\lib\threading.py", line 552, in __bootstrap_inner
self.run()
File "C:\Python27\Lib\site-packages\pyswap\src\swap\SwapServer.py",
line 68, in run
self.modem = SerialModem(self._xmlserial.port,
self._xmlserial.speed, self.verbose)
File "C:\Python27\Lib\site-packages\pyswap\src\swap\modem
\SerialModem.py", line 292, in __init__
self._serport = SerialPort(self.portname, self.portspeed, verbose)
File "C:\Python27\Lib\site-packages\pyswap\src\swap\modem
\SerialPort.py", line 173, in __init__
raise SwapException(str(ex))
SwapException: 'SwapException occurred: could not open port /dev/
ttyUSB0: [Error 3] The system cannot find the path specified.'


Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\lagarto\lagarto-swap\lagarto-
swap.py", line 46, in <module>
swap_manager = SwapManager(settings)
File "C:\Python27\Lib\site-packages\lagarto\lagarto-swap
\swapmanager.py", line 253, in __init__
LagartoServer.__init__(self, working_dir)
File "C:\Python27\Lib\site-packages\lagarto\lagarto
\lagartocomms.py", line 129, in __init__
self.config.address = self.address
AttributeError: 'SwapManager' object has no attribute 'address'
>>>

What I get from it is that the program is looking for /dev/ttyUSB0:
as serial port.
I'm using com6 as serial port and my pyswap works fine and remembers
this setting, for some reason lagarto doesn't :(.
The second part of the log.... no idea if has the same cause or not.
Windows... :(

Daniel Berenguer

unread,
Mar 5, 2012, 4:42:29 PM3/5/12
to pans...@googlegroups.com
Hi Iulian.

Whilst I look into this issue, you may want to configure your serial
port by hand from lagarto/lagarto-swap/config/serial.xml. That should
work. SWAPdmt and lagarto-swap use different configuration files.

Daniel Berenguer

unread,
Mar 5, 2012, 4:44:06 PM3/5/12
to pans...@googlegroups.com
BTW, thanks a lot Iulian for the reports!

Iulian-Marius

unread,
Mar 5, 2012, 5:40:18 PM3/5/12
to panstamp
I'm the one that has to thank you for all your help!!!
I've changed the com port settings...
The result:
SWAP server starting...
Downloading Device Definition Files
Unable to update Device Definition Files
SWAP server is now running...

Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\lagarto\lagarto-swap\lagarto-
swap.py", line 46, in <module>
swap_manager = SwapManager(settings)
File "C:\Python27\Lib\site-packages\lagarto\lagarto-swap
\swapmanager.py", line 253, in __init__
LagartoServer.__init__(self, working_dir)
File "C:\Python27\Lib\site-packages\lagarto\lagarto
\lagartocomms.py", line 129, in __init__
self.config.address = self.address
AttributeError: 'SwapManager' object has no attribute 'address'
>>> Rved:
Rved: Modem ready!
Sent: +++
Rved: OK-Command mode
Sent: ATHV?

Rved: 100
Sent: ATFV?

Rved: 100
Sent: ATCH?

Rved: 0
Sent: ATSW?

Rved: B547
Sent: ATDA?

Rved: 1
Sent: ATO

Rved: OK-Data mode
Sent: 00010000010000

It is somehow a victory!!!
But the server is not working :(.
No luck when i try to access localhost:8001.

Daniel Berenguer

unread,
Mar 6, 2012, 7:10:53 AM3/6/12
to pans...@googlegroups.com
Hi Iulian!

I've uploaded a new version of lagarto that solves the problems you
found... except for the "Unable to update Device Definition Files"...
did you upgraded your local copy of pyswap? Did you install it with
"python setup.py install" again? Have you this same problem with
SWAPdmt too?

Iulian-Marius

unread,
Mar 6, 2012, 12:12:27 PM3/6/12
to panstamp
Ok, after the update and python setup.py install is working.
When i try to connect to localhost:8001 it requires a username and
password. I know it sound ridiculous but i have no idea of the
username and password or how to change it.:(
The good part is that is working... :)

Daniel Berenguer

unread,
Mar 6, 2012, 5:06:22 PM3/6/12
to pans...@googlegroups.com
I uploaded for some reason my own httpauth file. Just delete
lagarto/lagarto/security/httpauth. That should let you get a clean
connection with no user account.

Iulian-Marius

unread,
Mar 6, 2012, 6:44:25 PM3/6/12
to panstamp
Deleting it is not going to fix it.
Just tried now and this is the error report:

Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\lagarto\lagarto-swap\lagarto-
swap.py", line 32, in <module>
from swapmanager import SwapManager
File "C:\Python27\Lib\site-packages\lagarto\lagarto-swap
\swapmanager.py", line 42, in <module>
from lagartocomms import LagartoServer
File "C:\Python27\Lib\site-packages\lagarto\lagarto
\lagartocomms.py", line 28, in <module>
from lagartohttp import LagartoHttpServer
File "C:\Python27\Lib\site-packages\lagarto\lagarto\lagartohttp.py",
line 37, in <module>
class LagartoHttpServer(threading.Thread):
File "C:\Python27\Lib\site-packages\lagarto\lagarto\lagartohttp.py",
line 256, in LagartoHttpServer
@auth.lagartoauth()
TypeError: auth_disabled() takes exactly 1 argument (0 given).
Maybe a default error should fix it.

Daniel Berenguer

unread,
Mar 6, 2012, 6:49:05 PM3/6/12
to pans...@googlegroups.com
Sorry Iulian, I got the same error here when I tried without httpauth.
I was uploading the new code that corrects this when I saw your
message. You just need to upgrade lagarto.

Iulian-Marius

unread,
Mar 10, 2012, 8:01:48 AM3/10/12
to panstamp
The new version of lagarto is working on windows.
I've start playing with binouts.ino.
The pwm outputs are working fine but for I/O outputs i get this error:
Traceback (most recent call last):
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "C:\Python27\Lib\site-packages\lagarto\lagarto\lagartohttp.py",
line 290, in _process_request
(status, response_headers, response_body) =
LagartoHttpServer._serve_values(query_string, path)
File "C:\Python27\Lib\site-packages\lagarto\lagarto\lagartohttp.py",
line 349, in _serve_values
body = LagartoHttpServer._http_json_set_value(uids, locations,
names, values)
File "C:\Python27\Lib\site-packages\lagarto\lagarto\lagartohttp.py",
line 204, in _http_json_set_value
status = LagartoHttpServer.data_server.set_status(req)
File "C:\Python27\Lib\site-packages\lagarto\lagarto-swap
\swapmanager.py", line 162, in set_status
endp.cmdWack(item["value"])
File "C:\Python27\Lib\site-packages\pyswap\src\swap\protocol
\SwapParam.py", line 317, in cmdWack
return self.register.mote.server.setEndpointValue(self, value)
File "C:\Python27\Lib\site-packages\pyswap\src\swap\SwapServer.py",
line 389, in setEndpointValue
ack = endpoint.sendSwapCmd(value)
File "C:\Python27\Lib\site-packages\pyswap\src\swap\protocol
\SwapParam.py", line 391, in sendSwapCmd
lstRegVal[indexReg] |= mask
IndexError: list index out of range
localhost - - [10/Mar/2012 12:51:45] "GET /values/?id=2.11.2&value=ON
HTTP/1.1" 500 59

Also noticed that my CPU usage is aroun 50% for pythonw.exe, mem usage
13.700k.
I know that an atom single core @ 1600mhz is not much (or less to zero
this days) but this looks very strange, especially that
lagarto should run on something as light as rasberryPi.
Is windows again the one that is causing the pain in the...CPU?

Daniel Berenguer

unread,
Mar 10, 2012, 10:25:33 AM3/10/12
to pans...@googlegroups.com
You mean that Lagarto-SWAP can control the PWM outputs but not the
ON/OFF ones? Does the problem appear on a specific output? I'll try to
reproduce the error ASAP.

As for the CPU consumption I don't know what to say... I did some
tests on an old Linksys NSLU2 and Lagarto-SWAP worked just fine but
some of the latest changes may have altered the performance. I'll try
to check this too.

Thanks Iulian!!

Iulian-Marius

unread,
Mar 10, 2012, 11:29:04 AM3/10/12
to panstamp
Yes, PWM works fine, ON/OFF not working- none of them.
It says that list index is out of range...

Daniel Berenguer

unread,
Mar 10, 2012, 11:46:46 AM3/10/12
to pans...@googlegroups.com
Thanks Iulian.

Daniel Berenguer

unread,
Mar 11, 2012, 11:54:14 AM3/11/12
to pans...@googlegroups.com
Solved the problem. This was due to a an incorrect byte position in
binouts.xml. No need to manually update your definition files if you
have the automatic update enabled.

Thanks again for the hunting Iulian.

Daniel Berenguer

unread,
Mar 30, 2012, 8:01:25 PM3/30/12
to pans...@googlegroups.com
A small change has been added to pyswap that solves the CPU usage problem.

Thanks Iulian!

Reply all
Reply to author
Forward
0 new messages