I'm trying to load a weather plugin for a website I'm working on. The weather plugin is a separate weather.py file located at /var/www/piss/plugins/base/weather.py. In the PSP it seems to import correctly, but I am unable to access any variables or objects from the weather.py plugin in the PSP. Here's the code I have:
...HTML and CSS stuff...
<%
sys.path.append('/var/www/piss/plugins/base/')
pwd = os.getcwd()
import sys, os
import string
from weather import weather
%>
<%= pwd %>
<%= html1 %>
<%= currentWeather %>
</div>
</div>
<div id="footer">Piss + INK Version 0.00001</div>
<div id="bottom"></div>
</div>
</body>
</html>
Here's the weather.py code:
from basePlugin import plugin
import MySQLdb
import pywapi
class weather(plugin):
"""
weather.py
Built-in weather plugin.
"""
def __init__(self,zipcode):
self.zipcode = zipcode
#Tested without DB access
#db=_mysql.connect(host="localhost",user="things",passwd="things",db="things")
#zip="SELECT zipcode FROM "+currentUser+"\;"
#c = db.cursor()
#dbResult = c.execute (zip)
wResult=pywapi.get_weather_from_google('05401')
html1="""
<div class="weather">
Weather:<br />
"""
print html1
currently = wResult['current_conditions']
currentWeather = currently['condition']
print currentWeather
print "<br />"
if currentWeather == "Mostly Cloudy":
print '<img src="themes/default/images/weather/cloudy.png" alt="cloudy">'
if currentWeather == "Cloudy":
print '<img src="themes/default/images/weather/cloudy.png" alt="cloudy">'
if currentWeather == "Sunny":
print '<img src="themes/default/images/weather/sunny.png" alt="sunny">'
if currentWeather == "Showers":
print '<img src="themes/default/images/weather/rain.png" alt="rain">'
#More conditions will be added in actual plugin.
print "</div>"