2009-05-09, 16:46
So I'm starting to try and make sense of this python thing, and I've already run into a few snags.
Here's the code I've got started:
My problem comes from the last line. I don't quite understand how I would get an absolute path to tell executebuiltin() where my skin folder is...or how exactly you'd change it either way.
Other stuff maybe somebody could help me with is as follows:
1. Pulling a string out of an RSS stream to determine if the currently installed version is up-to-date. I see from the new code examples that it's possible to read/write to a notepad file...I was thinking that if I could parse the RSS stream, I could just write the rev number to a txt file, and then check against that in the future.
2. SVN. This is most likely beyond the scope of my programming abilities ATM, but I'm still curious. Ideally, I'd like to be able to just look at the svn on googlecode, and if stuff is changed, update the changed files.
So, if you can answer these questions AND/OR are possibly willing to help me make this script a reality, I would be greatly, greatly appreciative.
Here's the code I've got started:
Code:
import urllib, os,re,urllib2
import xbmc,xbmcgui
path = os.getcwd()[:-1]+"\\"
def DownloaderClass(url,dest):
dp = xbmcgui.DialogProgress()
dp.create("My Script","Downloading File",url)
urllib.urlretrieve(url,dest,lambda nb, bs, fs, url=url: _pbhook(nb,bs,fs,url,dp))
def _pbhook(numblocks, blocksize, filesize, url=None,dp=None):
try:
percent = min((numblocks*blocksize*100)/filesize, 100)
print percent
dp.update(percent)
except:
percent = 100
dp.update(percent)
if dp.iscanceled():
print "DOWNLOAD CANCELLED" # need to get this part working
dp.close()
url ='http://www.iamkizer.net/xbmc/serenity/ccounter/click.php?id=8'
DownloaderClass(url,"special://xbmc/skin/serenity.rar")
executebuiltin('extract(path/serenity.rar,path)')
My problem comes from the last line. I don't quite understand how I would get an absolute path to tell executebuiltin() where my skin folder is...or how exactly you'd change it either way.
Other stuff maybe somebody could help me with is as follows:
1. Pulling a string out of an RSS stream to determine if the currently installed version is up-to-date. I see from the new code examples that it's possible to read/write to a notepad file...I was thinking that if I could parse the RSS stream, I could just write the rev number to a txt file, and then check against that in the future.
2. SVN. This is most likely beyond the scope of my programming abilities ATM, but I'm still curious. Ideally, I'd like to be able to just look at the svn on googlecode, and if stuff is changed, update the changed files.
So, if you can answer these questions AND/OR are possibly willing to help me make this script a reality, I would be greatly, greatly appreciative.