SoftwareDefinedBuildings / smap

smap - Simple Measurement and Actuation Profile
Other
30 stars 36 forks source link

Can't Retrieve data from archiver. Error: 'NoneType' object has no attribute 'lower', returned #20

Closed jeovanevs closed 8 years ago

jeovanevs commented 8 years ago

On Ubuntu 14.04.1 with python 2.7.6 After a clean install by:

$ sudo add-apt-repository ppa:cal-sdb/smap
$ sudo apt-get update
$ sudo apt-get install -y python-smap readingdb powerdb2

The folder /var/run/smap was not created, so the archiver process could not start. I' ve created it this way:

$ sudo mkdir /var/run/smap
$ sudo chown -R smap /var/run/smap

And restart the archiver process in supervisorctl.

After that I tried to send the file data.json like the example here and when I tried to retrieve this data in smpa-query using this command select data in ("01/01/2010" , now) where uuid = "d24325e6-1d7d-11e2-ad69-a7c2fa8dba61" or even in the browser at http://localhost:8079/api/data

it returned this error

Error: 'NoneType' object has no attribute 'lower'

Any idea how can I solve this on unitoftime branch.

Thanks a lot. Jeovane @jeovanevs

gtfierro commented 8 years ago

Hi there,

Can you provide a log of what's happening on the server-side? You may also need to generate an API key using powerdb2 and append that to the end of the add url, e.g. http://localhost:8079/add/<apikey here>

Gabe

jeovanevs commented 8 years ago

Hi @gtfierro I have created a subscription in* localhost/admim* with an apikey 12345. I have cleaned the log file in* /var/log/archiver.stdout.log* and restarted the archiver. After I send the file data.json as previously mentioned; And tried to see the data in http://localhost:8079/api/data and received that error. Following the log content:

2016-01-28 16:52:41-0800 [-] Log opened. 2016-01-28 16:52:41-0800 [-] twistd 13.2.0 (/usr/bin/python 2.7.6) starting up. 2016-01-28 16:52:41-0800 [-] reactor class: twisted.internet.epollreactor.EPollReactor. 2016-01-28 16:52:41-0800 [-] Site starting on 8079 2016-01-28 16:52:41-0800 [-] Starting factory <twisted.web.server.Site instance at 0x7f48c5465e18> 2016-01-28 16:53:57-0800 [-] 127.0.0.1 - - [29/Jan/2016:00:53:56 +0000] "POST /add/12345 HTTP/1.1" 200 - "-" "curl/7.35.0" 2016-01-28 16:58:12-0800 [-] Unhandled Error Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 1201, in mainLoop self.runUntilCurrent() File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 797, in runUntilCurrent f(_a, _kw) File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 382, in callback self._startRunCallbacks(result) File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 490, in _startRunCallbacks self._runCallbacks() --- --- File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 577, in _runCallbacks current.result = callback(current.result, _args, _kw) File "/usr/lib/python2.7/dist-packages/smap/archiver/api.py", line 402, in d.addCallback(lambda r: data_load_result(request, method, r)) File "/usr/lib/python2.7/dist-packages/smap/archiver/data.py", line 398, in data_load_result d = loader.load_data(request, method, result[:count]) File "/usr/lib/python2.7/dist-packages/smap/archiver/data.py", line 253, in load_data stream_unit = units[0].lower() exceptions.AttributeError: 'NoneType' object has no attribute 'lower'

2016-01-28 16:58:12-0800 [-] 127.0.0.1 - - [29/Jan/2016:00:58:11 +0000] "GET /api/data HTTP/1.1" 400 42 "-" "curl/7.35

Thanks in advance. Jeovane

jeovanevs commented 8 years ago

One more thing: how can I see the data directly on Postgre, or on readingdb. Is there a specific table or sequence where this data are saved? Do you have the commands to do this. Thanks.

gtfierro commented 8 years ago

Try adding UnitofTime = "ms" under the Properties tag; I believe this is the issue. The documentation on the wiki was copied directly from another version of sMAP which does not require this field.

Metadata (kv pairs) is stored in Postgres and the timeseries data is stored in readingdb, which you can read about how to use here

jeovanevs commented 8 years ago

It worked like a charm. Thank you!