|
Post by cybertek007 on Sept 17, 2013 6:57:07 GMT -8
So`the app is connected ans shows green in the server report and the control object report, but the demonstration page just shows blank white in the W-1 Status Web View??? Any help getting over this hump would be nice ,been stuck on this one to many hrs.
10.0.0.149:54303 - - [17/Sep/2013 03:58:09] "HTTP/1.1 POST /raspi" - 500 Internal Server Error Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 239, in process return self.handle() File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 230, in handle return self._delegate(fn, self.fvars, args) File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 420, in _delegate return handle_class(cls) File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 396, in handle_class return tocall(*args) File "/home/pi/RasPiConnectServer/RasPiConnectServer.py", line 211, in POST outgoingData += ExecuteRemoteWebView.Generate_Remote_WebView(element, Config.localURL()) File "./ExecuteFiles/ExecuteRemoteWebView.py", line 149, in Generate_Remote_WebView freeSplit = freeSplit[1].split(" ", 1) IndexError: list index out of range
|
|
|
Post by SDL on Sept 17, 2013 8:28:56 GMT -8
Cybertek007,
I suspect that you are using a wireless LAN on this Pi, aren't you? I just looked at the code (File "./ExecuteFiles/ExecuteRemoteWebView.py", line 149, in Generate_Remote_WebView) and it looks like it is depending on eth0 being present. That's effectively a bug, and I see why we didn't catch it in testing. We were all on wired Pi's!
Replace the lines in File "./ExecuteFiles/ExecuteRemoteWebView.py", line 149
with if (len(freesplit) >1 ): freeSplit = freeSplit[1].split(" ", 1) freeData = freeSplit[0] else: freeData = ""
That will fix your immediate problem. We will put a fix up on the github site later today.
BP
|
|
|
Post by SDL on Sept 17, 2013 8:45:58 GMT -8
Cybertek007,
Quickly hooked up a Pi on wireless and duplicated the issue. One more thing needs to be fixed. Use this code:
try: freeString = subprocess.check_output(["ifconfig", "eth0"]) freeSplit = freeString.split("inet addr:", 1)
if (len(freesplit) >1 ): freeSplit = freeSplit[1].split(" ", 1) freeData = freeSplit[0] else: freeData = "" except: freeData = ""
It will be up on GitHub shortly
BP
|
|
|
Post by cybertek007 on Sept 17, 2013 10:48:24 GMT -8
Thank you! That fixed the problem! I did have a little problem with matching the indentation format. So I'm posting the full edit at the end of this reply.
Right now this is the errors I'm getting, not sure but it may be due to the fact I have no camera!
10.0.0.149:55365 - - [17/Sep/2013 12:50:04] "HTTP/1.1 GET /raspistatic/anm5213a41ecdc79b75.gif" - 405 Method Not Allowed 10.0.0.149:55366 - - [17/Sep/2013 12:50:04] "HTTP/1.1 GET /raspistatic/RovioImage.jpg" - 405 Method Not Allowed 10.0.0.149:55364 - - [17/Sep/2013 12:50:08] "HTTP/1.1 POST /raspi" - 200 OK 10.0.0.149:55370 - - [17/Sep/2013 12:54:40] "HTTP/1.1 POST /raspi" - 200 OK 10.0.0.149:55371 - - [17/Sep/2013 12:54:45] "HTTP/1.1 POST /raspi" - 200 OK 10.0.0.149:55372 - - [17/Sep/2013 12:54:46] "HTTP/1.1 GET /raspistatic/anm5213a41ecdc79b75.gif" - 405 Method Not Allowed 10.0.0.149:55373 - - [17/Sep/2013 12:54:46] "HTTP/1.1 GET /raspistatic/RovioImage.jpg" - 405 Method Not Allowed 10.0.0.149:55387 - - [17/Sep/2013 13:01:44] "HTTP/1.1 POST /raspi" - 200 OK 10.0.0.149:55388 - - [17/Sep/2013 13:01:45] "HTTP/1.1 GET /raspistatic/anm5213a41ecdc79b75.gif" - 405 Method Not Allowed 10.0.0.149:55389 - - [17/Sep/2013 13:01:45] "HTTP/1.1 GET /raspistatic/RovioImage.jpg" - 405 Method Not Allowed 10.0.0.149:55390 - - [17/Sep/2013 13:02:15] "HTTP/1.1 POST /raspi" - 200 OK 10.0.0.149:55391 - - [17/Sep/2013 13:02:16] "HTTP/1.1 GET /raspistatic/anm5213a41ecdc79b75.gif" - 405 Method Not Allowed 10.0.0.149:55392 - - [17/Sep/2013 13:02:16] "HTTP/1.1 GET /raspistatic/RovioImage.jpg" - 405 Method Not Allowed 10.0.0.149:55413 - - [17/Sep/2013 13:18:14] "HTTP/1.1 POST /raspi" - 200 OK 10.0.0.149:55414 - - [17/Sep/2013 13:18:14] "HTTP/1.1 GET /raspistatic/anm5213a41ecdc79b75.gif" - 405 Method Not Allowed 10.0.0.149:55415 - - [17/Sep/2013 13:18:14] "HTTP/1.1 GET /raspistatic/RovioImage.jpg" - 405 Method Not Allowed 10.0.0.149:55413 - - [17/Sep/2013 13:18:21] "HTTP/1.1 POST /raspi" - 200 OK 10.0.0.149:55416 - - [17/Sep/2013 13:18:22] "HTTP/1.1 GET /raspistatic/anm5213a41ecdc79b75.gif" - 405 Method Not Allowed10.0.0.149:55417 - - [17/Sep/2013 13:18:22] "HTTP/1.1 GET /raspistatic/RovioImage.jpg" - 405 Method Not Allowed
10.0.0.149:55418 - - [17/Sep/2013 13:18:38] "HTTP/1.1 POST /raspi" - 200 OK 10.0.0.149:55419 - - [17/Sep/2013 13:19:02] "HTTP/1.1 POST /raspi" - 200 OK 10.0.0.149:55420 - - [17/Sep/2013 13:20:10] "HTTP/1.1 POST /raspi" - 200 OK
updated code
#!/usr/bin/python # Filename: ExecuteWebView.py # Version 2.1 04/13/13 RV MiloCreek
import Config
import subprocess import sys
if (Config.i2c_demo()): from Adafruit_BMP085 import *
import time import Validate import BuildResponse
def Generate_Remote_WebView(root, LOCALURL):
if (Config.i2c_demo()): from pyblinkm import BlinkM, Scripts
objectServerID = root.find("./OBJECTSERVERID").text objectFlags = root.find("./OBJECTFLAGS").text validate = Validate.checkForValidate(root)
if (Config.debug()): print "VALIDATE=%s" % validate
outgoingXMLData = BuildResponse.buildHeader(root)
if (objectServerID == "W-1"): #check for validate request if (validate == "YES"): outgoingXMLData += Validate.buildValidateResponse("YES") outgoingXMLData += BuildResponse.buildFooter()
return outgoingXMLData # normal response requested responseData = ""
# check to see if i2c_demo is turned on if (Config.i2c_demo()): if (Config.debug()): print "Config.i2c_demo passed as True"
# Yes, it is on
# Initialise the BMP085 and use STANDARD mode (default value) # bmp = BMP085(0x77, debug=True) # bmp = BMP085(0x77) # To specify a different operating mode, uncomment one of the following: # bmp = BMP085(0x77, 0) # ULTRALOWPOWER Mode # bmp = BMP085(0x77, 1) # STANDARD Mode # bmp = BMP085(0x77, 2) # HIRES Mode bmp = BMP085(0x77, 3) # ULTRAHIRES Mode count = 0 exceptionCount = 0 exceptionCountBMP = 0 blinkm = BlinkM(1,0xc) blinkm.reset() try: temp = bmp.readTemperature() pressure = bmp.readPressure() altitude = bmp.readAltitude() tempData = "%.2f C" % temp pressureData = "%.2f hPa" % (pressure / 100.0)
except IOError as e: exceptionCountBMP = exceptionCountBMP + 1 print "I/O error({0}): {1}".format(e.errno, e.strerror) except: exceptionCountBMP = exceptionCountBMP + 1 print "Unexpected error:", sys.exc_info()[0] raise
else: # now set some values for display since we don't have i2C tempData = "xx.x C (no i2c enabled)" pressureData = "xxxx.x hPa (no i2c enabled)"
# read an HTML template into aw string with open ("./Templates/W-1.html", "r") as myfile: responseData += myfile.read().replace('\n', '') # replace the URL so it will point to static responseData = responseData.replace("XXX", LOCALURL)
# now replace the AAA, BBB, etc with the right data responseData = responseData.replace("AAA", subprocess.check_output(["date", ""], shell=True))
# split uptime at first blank, then at first , uptimeString = subprocess.check_output(["uptime", ""]) uptimeType = uptimeString.split(",") uptimeCount = len(uptimeType)
if (uptimeCount == 6): # over 24 hours uptimeSplit = uptimeString.split(",") uptimeSplit = uptimeSplit[0]+uptimeSplit[1] uptimeSplit = uptimeSplit.split(" ", 1) uptimeData = uptimeSplit[1] else: # under 24 hours uptimeSplit = uptimeString.split(" ", 2) uptimeSplit = uptimeSplit[2].split(",", 1) uptimeData = uptimeSplit[0]
responseData = responseData.replace("BBB", uptimeData)
usersString = subprocess.check_output(["who", "-q"], shell=False, stderr=subprocess.STDOUT,) responseData = responseData.replace("CCC", usersString)
freeString = subprocess.check_output(["free", "-mh"]) freeSplit = freeString.split("cache: ", 1) freeSplit = freeSplit[1].split(" ", 2) freeSplit = freeSplit[2].split("\nSwap:", 1) freeData = freeSplit[0]
responseData = responseData.replace("DDD", freeData) responseData = responseData.replace("EEE", tempData) responseData = responseData.replace("FFF", pressureData)
output = subprocess.check_output(["cat", "/sys/class/thermal/thermal_zone0/temp"]) cpuTemp = "%3.2f C" % (float(output)/1000.0) responseData = responseData.replace("GGG", cpuTemp) freeString = subprocess.check_output(["ifconfig", "eth0"]) freeSplit = freeString.split("inet addr:", 1) freeString = subprocess.check_output(["ifconfig", "eth0"])
if (len(freeSplit) >1 ): freeSplit = freeSplit[1].split(" ", 1) freeData = freeSplit[0] else: freeData = ""
responseData = responseData.replace("HHH", freeData) responseData = responseData.replace("III", Config.localURL()) # responseData = responseData.replace("III", "'your external address here'")
responseData = responseData.replace("JJJ", Config.version_number())
# read latest data from ST-1 SendText control on RasPiConnect
try: with open ("./local/ST-1.txt", "r") as myfile: sendTextData = myfile.read().replace('\n', '') except IOError: sendTextData = ""
responseData = responseData.replace("KKK", sendTextData)
# check to see if i2c_demo is turned on if (Config.i2c_demo()): time.sleep(0.2)
try: blinkm.go_to(255, 0, 0) time.sleep(0.2) blinkm.go_to(0, 255, 0) except IOError as e: #blinkm.reset() exceptionCount = exceptionCount + 1 print "I/O error({0}): {1}".format(e.errno, e.strerror) except: blinkm.reset() exceptionCount = exceptionCount + 1 print "Unexpected error:", sys.exc_info()[0] raise #responseData += subprocess.check_output(["cat", "/proc/cpuinfo"]) #responseData += subprocess.check_output(["cat", "/proc/meminfo"]) outgoingXMLData += BuildResponse.buildResponse(responseData)
if (Config.debug()): print outgoingXMLData elif (objectServerID == "W-2"): #check for validate request if (validate == "YES"): outgoingXMLData += Validate.buildValidateResponse("YES") outgoingXMLData += BuildResponse.buildFooter()
return outgoingXMLData # normal response requested
imageName = "RovioImage.jpg"
responseData = "<html><head>" responseData += "<title></title><style>body,html,iframe{margin:0;padding:0;}</style>" responseData += "</head>" responseData += "<body><img src=\"" responseData += LOCALURL responseData += "static/" responseData += imageName responseData += "\" type=\"jpg\" width=\"300\" height=\"300\">" responseData += "<BR>Picture<BR>"
responseData +="</body>" responseData += "</html>" outgoingXMLData += BuildResponse.buildResponse(responseData)
if (Config.debug()): print outgoingXMLData
else: # invalid RaspiConnect Code outgoingXMLData += Validate.buildValidateResponse("NO")
outgoingXMLData += BuildResponse.buildFooter()
return outgoingXMLData
# End of ExecuteWebView.py
|
|
|
Post by cybertek007 on Sept 17, 2013 10:56:48 GMT -8
PS: just wanted to add many kudo's for your development team!!!!!!!!!!!!!!!
I love this Program! Now if you could just bring the RasPi server to the ipad apps ease of use level?
|
|
|
Post by SDL on Sept 17, 2013 15:00:24 GMT -8
Hi Cybertek007,
I *think* that you are requesting a file from a directory called "raspistatic". A web.py limitation (found by experience) is that all files to be downloaded to the browser have to be in the directory "static" in the same directory as the RasPiConnectServer
We are serving up lots of files and they all are copied into the "static" directory.
Hope that helps!
Best regards,
BP
|
|