Weather Underground

Discussion of plugin / script development for XBMC4Xbox
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Weather Underground

Post by Dan Dar3 »

Sorry, I missed that, the function should return a tuple, with dirs and files separate, this with this:

Code: Select all

def listdir ( path ):
    """ listdir(path) -- returns a tuple containing separate lists of directory and file names in given path.

        example:
          dirs, files = xbmcfs.listdir(path)
    """
    xbmc.log( "[xbmcvfs] listdir(%s)" % ( path ), xbmc.LOGDEBUG )
    listdir = os.listdir( path )
    dirs    = [d for d in listdir if os.path.isdir (os.path.join(path, d))]
    files   = [f for f in listdir if os.path.isfile(os.path.join(path, f))]
    return dirs, files
Note: Ticket #272 created for xbmcvfs.listdir()

Yeah, midnight here and working on couple of things at the same time, maybe we should call it a day and resume tomorrow :-)
User avatar
byron
Posts: 582
Joined: Wed Jul 04, 2012 9:26 pm
Location: Illinois
Has thanked: 27 times
Been thanked: 96 times

Re: Weather Underground

Post by byron »

Souds good, im in the middle of snaking a toilet anyway...the other night I was rinsing a beer bottle out and it slid off the sink broke on the toilet and a big chunk of glass went down while it was flushing! Hopefully someone can get a laugh out of that terrible luck...at any rate thanks again for all of the help, I'm actually starting to get a better picture of what's going on.
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Weather Underground

Post by Dan Dar3 »

Well, you focus on that, you probably don't want anymore accidents happening there :-) glad it helped.
skatulskijean
Posts: 1028
Joined: Wed Jul 04, 2012 8:01 am
Has thanked: 1 time
Been thanked: 148 times

Re: Weather Underground

Post by skatulskijean »

most what you want to adapt addons for xbox have i declared on a other thread here for long time i mpost it here again and hope this will you help on future.
Sorry i have not read this before!

Most what i have changed what simple thinks:

On most addons you have :
as example settings = xbmcaddon.Addon()
this will our scriptmodul.xbmcaddon not understand
you must put the addon id in it thats works
settings = xbmcaddon.Addon(id='plugin.video.svt')

a class with () will not works:
example:
class YouTubeStorage(): works not
class YouTubeStorage: works

import json works not
import simplejson as json works

import

from hashlib import md5 works not we have no hashlib!
from md5 import md5 as md5 works
is the same with sha
and you must simple change on the py as exemple hashlib.md5 to md5
i have a working hashlib pyd with a working hashlib.py i look and make for the future a scriptmodul but i must test!

Storageserver :
storageserver will not works we have no common cache on first i hat to look but with the last YouTube plugin the Storageserverdummy works out of the box and it works for other addons to you must simple change import storageserver to import storageserverdummy and on the py to!
Storageserverdummy have no Filcache and the only addon what not works with is is Icefilms but the storageserverdummy on my build for Icefilms have a simple file cache the better way where to implemented commoncache for xbmc4xbox !

the common function for the addons like YouTube give the scriptmodule parsedom
on parsedom you have import io
python 2,4 can not understand import io but most is simple a io.open(filepath, options) and works with open(filepath, options) !

Format will not work on python 2.4
example:

final_url = "{0}?mode={1}&title={2}".format(sys.argv[0], mode, title) will not works
final_url = "%s?mode=%s&title=%s" % (sys.argv[0], mode, title)

inline if works not on python 2.4
example:
test = True if test2 == True else False works not

if test2 == True:
test = True
else:
test = False works

most you have a error with as simple change as to , and it works!

pfad what not works example:
main xbmc: url = "plugin://plugin.video.youtube/?path=/root/video&action=play_video&videoid=" + id
xbmc4xbox working : url = "plugin://video/YouTube/?path=/root/video&action=play_video&videoid=" + id

URlresolver:
For the first Version what i have do i hat many work on my brain to understand why it not works but with the last Version from Eden you must simple copy the scriptmodule under scriptmodule and as module under plugins (yes this not the right solution) but it works!
The only changes since under the Hoster (hash and accessing the Log ) and for the Youtube and others what access the addons example Youtube the pfad to accessing the Addon!

For most addons when you have all adapted and changed that works and the addon works on main xbmc and you have a HTTp 404 error change from urllib2 to mechanize but make the http error access with urllib2
example [removed] was not working with urllib2 but with change to mechanize my adapted version works!

Sorry i forgot many addons can not create the settings:
example : LiveOnlineFooty
add this with the addon spezific id and its works:
#xbox fox can not create self Folder
addonID = "plugin.video.lof"
addon_work_folder=xbmc.translatePath("special://profile/addon_data/"+addonID)
if not os.path.isdir(addon_work_folder):
os.mkdir(addon_work_folder)
# end xbox Fix


Ok i think that was what i mainly change to make addons compatible on this time!



ps.

urllib2 from mechaniye works most better as the original urllib2 on python 2.4 .
And have simple function to access a cockie as example and manz more

to change only the code for a addon or script when you it use on the xbox you can work with xbmc.getCondVisibility("System.Platform.xbox")
example

xbox = xbmc.getCondVisibility("System.Platform.xbox")

if xbox==True:
url = "plugin://video/YouTube/?path=/root/video&action=play_video&videoid=" + id
else:
url = "plugin://plugin.video.youtube/?path=/root/video&action=play_video&videoid=" + id
text/html

regards jan
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Weather Underground

Post by Dan Dar3 »

Thanks Jan, quite a lot of information in one take :-)
User avatar
byron
Posts: 582
Joined: Wed Jul 04, 2012 9:26 pm
Location: Illinois
Has thanked: 27 times
Been thanked: 96 times

Re: Weather Underground

Post by byron »

@ jan...thanks for the info, I remember you posting that when you guys were working on a4x installer. It's very helpful knowledge, and nice to have something to bounce back to when stuck.

@ Dan...it seems to work with only one tiny error now (your addition to xbmcvfs.py must be good?):

http://xbmclogs.com/show.php?id=98910

This was all done on 3.3.3, but when I tried running it on the latest nightly I got this:

http://xbmclogs.com/show.php?id=98919

Which means that it does matter which build someone is using which in turn means that it's not really usable at this point. I mean it's usable, but it's gonna take maintenance from build to build until BuZz gets the python to a stable place. At that point it would be a pretty solid contender for a weather provider for us I think, and in the meantime there are things that have to be done on a skinning level (10 day forecast, radar, weekend, hourly options, etc...) not to mention the po files :( and also how to make an option for switching between degrees c/f. As it stands right now though, thanks for the help and patience of going through this exercise with me.
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Weather Underground

Post by Dan Dar3 »

If you're referring to this error, I don't know where it comes from...

Code: Select all

12:22:04 M: 31588352   ERROR: xbp__wfopen = untested
For the other error on nightly, somehow I'd blame the received data than maybe the code:

Code: Select all

12:38:14 M: 23543808   ERROR: Traceback (most recent call last):
                                              File "Q:\plugins\weather\weather.wunderground\default.py", line 657, in <module>
                                                forecast(location, locationid)
                                              File "Q:\plugins\weather\weather.wunderground\default.py", line 159, in forecast
                                                properties(data,loc,locid)
                                              File "Q:\plugins\weather\weather.wunderground\default.py", line 194, in properties
                                                weathercode = WEATHER_CODES[data['current_observation']['icon_url'][31:-4]]
                                            KeyError: ('current_observation',)
What I would do is print out the values received by properties() and then compare in between versions - then it will be clear whether the data is different or the code behaves differently.

Code: Select all

def properties(data,loc,locid):
    print "data  = " + data
    print "loc   = " + loc
    print "locid = " + locid
You're all welcome and glad I could help. More people know how to tinker less I have to do :-) when you don't want to do anymore, teach :-)
skatulskijean
Posts: 1028
Joined: Wed Jul 04, 2012 8:01 am
Has thanked: 1 time
Been thanked: 148 times

Re: Weather Underground

Post by skatulskijean »

xbp__wfopen = untested

i think it
come from the xbmc/cores/DllLoader
look here and it is a old problem, i think so.
https://www.google.de/search?q=ERROR%3A ... D+untested+


regards jan
Post Reply