Live webcam viewer?
#16
hi, i have never coded any python, but in urllib urlopener.retrieve, i can see:

if self.tempcache and url in self.tempcache:
return self.tempcache[url]

so i guess that your content is in cache... ?

since i have not done any py work i do not know how to flush that single file from cache. (or if it is possible to set a no_cache flag on download.)
Reply
#17
maybe can you try to name your controlimage :

def displaypic(self, source, destination):
if self.downloadurl(source, destination) == 'ok':
self.pic=xbmcgui.controlimage(int((self.getwidth()-self.fullwidth)/2),int((self.getheight()-self.fullheight)/2), self.fullwidth, self.fullheight, destination, '0xffff3300')
self.addcontrol(self.pic)


def onaction(self, action):
if action == action_menu:
self.close()
elif action == action_refresh:
self.removecontrol(self.pic)
self.displaypic(url_webcam, imgpath)
Reply
#18
thanks a lot, that worked!!!! i had already tried using a name for the control image (i read it off your tutorial!Wink. instead of self.pic though i just used pic.

now i'm going to try and figure out how to use threading for the picture refreshing bit. i have a bit of experience with threads in some windows apps i made, but that was years ago back in school :p
Reply
#19
this is how far i got with the threading:

Quote:import urllib
import xbmc
import xbmcgui
import time
import threading

action_menu = 10
action_refresh = 7
root_dir = "q:\\scripts\\cache\\"
url_webcam = 'http://images.earthcam.com/ec_metros/new...indys.jpg'

class webcam(xbmcgui.window):
def (self):

self.scalex = ( float(self.getwidth())  / float(720) )
self.scaley = ( float(self.getheight()) / float(480) )
self.fullwidth = int(720)
self.fullheight = int(480)
self.imgpath = root_dir + 'webcam.jpg'

self.clock = clockthread()
        self.clock.start()
 # this line gets an error Sad

self.status = self.downloadurl(url_webcam, self.imgpath)
if self.status == 'ok':
  self.displaypic(self.imgpath)

def downloadurl(self, source, destination):
try:
loc = urllib.urlopener()
loc.retrieve(source, destination)
del loc
return 'ok'
except:
self.message()
return 'feil'  

def displaypic(self, destination):
self.pic = xbmcgui.controlimage(int((self.getwidth()-self.fullwidth)/2),int((self.getheight()-self.fullheight)/2), self.fullwidth, self.fullheight, destination, '0xffff3300')
self.addcontrol(self.pic)

def message(self):
dialog = xbmcgui.dialog()
dialog.ok("oh shit!", "the pic didn't download right.... fuck!!!")

def onaction(self, action):
if action == action_menu:
self.close()
elif action == action_refresh:
self.status = self.downloadurl(url_webcam, self.imgpath)
self.removecontrol(self.pic)
if self.status == 'ok':
  self.displaypic(self.imgpath)



class clockthread(threading.thread):
def (self):
threading.thread.(self)
self.running = true

def run(self):
while(self.running):
time.sleep(15)
self.message()

def message(self):
dialog = xbmcgui.dialog()
dialog.ok("thread", "mmmm thread!!!!")


win = webcam()
win.domodal()
del win


i basically copied the clockthread class from the tv guide program into this thing to try it out. i removed the label from the clockthread class cause i didn't need it.

then i created a new clockthread object called self.clock and the line to start it. i try to run it in xbmc, and i get the error:

Quote:08-03-2005 22:06:41 info self.clock.start()
08-03-2005 22:06:41 info
08-03-2005 22:06:41 info ^
08-03-2005 22:06:41 info syntaxerror
08-03-2005 22:06:41 info :
08-03-2005 22:06:41 info invalid syntax

but, self.clock.start() works in the tv script! i start it in the same place as well (init of the main class).

am i doing something completely retarded when it comes to threading? or just semi-retarded?
Reply
#20
ignore the last post, i fixed it!!

uhhh... thanks to formatting of this board, i saw that the self.clock.start() line has spaces instead of tabs before it!!! :lol:
Reply
#21
lol
somtimes it is boring ... some strings are missing in this board....
but sometimes it is very helpfull !
lol
is your script working fine ?
because you should write a def in the thread to stop it when you exit your script.
if you need it, i will send you an example.
Reply
#22
yeah i got it working!!! sweet!!!

yeah the thread probably still is running after i exit the script... that's no good! sure, i'd love to see an example!
Reply
#23
i made an extract of one of my scripts to explain a little bit.
you can find it here :
http://xbmc-scripts.gueux.be/documents/c...0thread.py

tell me if it helps !
Reply

Logout Mark Read Team Forum Stats Members Help
Live webcam viewer?0