Skip to content

HTTP Plugin: Several Errors #19

Description

@Sebb767

Hey there! I'm currently setting up my own AirPi and I'm pretty happy about this fork for having done all the things I'd need to implement myself ;) Thank you!

However, trying to use the http plugin results in serveral errors. They appear in the dev and master branches, my current setup is using the dev branch:

[AirPi] Current installed version and latest change:

commit 4c0341dea64ad26e8a3e1acd6758361dd1a4de3d
Author: Haydn Williams <pi@hwmail.co.uk>
Date:   Sun May 31 19:38:46 2015 +0000
Change: Add clarification to calibration function comments.

(snip)

My outputs.cfg (for http)

[HTTP]
filename = http
enabled = yes
calibration = on
wwwPath = www ; Must be full path if used with AirPi bootstart feature
port = 8080
history = on
historyFile = history.dat
historySize = 2880
historyInterval = 30
historyCalibrated = false
title = AirPi - <hostname>
about = This is an AirPi pollution / air quality monitoring device.
#target = internet
target = lan

Trying to simply use the http plugin throws the following error:

{'historyCalibrated': False, 'historyFile': 'history.dat', 'about': 'This is an AirPi pollution / air quality monitoring device.', 'historyInterval': '30', 'target': 'lan', 'limits': False, 'calibration': True, 'title': 'AirPi - <hostname>', 'history': True, 'historySize': '2880', 'httpVersion': False, 'wwwPath': 'www', 'port': '8080', 'metadata': False}
done first bit
done second bit
done third bit
starting hostname
starting title et al.
ERROR:   Failed to import plugin HTTP: global name 'calibration' is not defined

I solved that one myself by adding a simple import calibration at the start of the file. With that, the http plugin loads, but trying to access the site gives me the following error:

----------------------------------------
Exception happened during processing of request from ('192.168.2.112', 52948)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
    self.handle()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
    method()
  File "/home/pi/AirPi/outputs/http.py", line 333, in do_GET
    page = replace(page, "$time$", self.server.httpoutput.lastUpdate)
AttributeError: 'HTTP' object has no attribute 'lastUpdate'
----------------------------------------

This happens no matter if the sampling has actually started or not. I fixed it by replacing self.server.httpoutput.lastUpdate with the current time, but this yields the following error:

----------------------------------------
Exception happened during processing of request from ('192.168.2.112', 52955)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
    self.handle()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
    method()
  File "/home/pi/AirPi/outputs/http.py", line 336, in do_GET
    for i in self.server.httpoutput.data:
AttributeError: 'HTTP' object has no attribute 'data'
----------------------------------------

I'm assuming that the sample data isn't send to the http output module, but since my understanding of the projects code (and, well, python) is very shallow, I can't fix this on my own. Any ideas?

I'll maybe try an older commit until this is fixed.

Update: Reverting to commit/version 1.0 didn't fix this :/ (it did fix the import however)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions