-class GetImage(threading.Thread):
- def __init__(self, url, stream):
- threading.Thread.__init__(self)
- self.url = url
- self.stream = stream
-
- def run(self):
- f = urllib2.urlopen(self.url)
- data = f.read()
- f.close()
- self.stream.write(data)
- self.stream.close()
-
-class ImageDownloader():
- def __init__(self):
- self.images = []
- self.downloading = False
-
- def queueImage(self, url, stream):
- self.images.append((url, stream))
- if not self.downloading:
- self.downloading = True
- gobject.timeout_add(50, self.checkQueue)
-
- def checkQueue(self):
- for i in range(4-threading.activeCount()):
- if len(self.images) > 0:
- (url, stream) = self.images.pop()
- GetImage(url, stream).start()
- if len(self.images)>0:
- gobject.timeout_add(200, self.checkQueue)
- else:
- self.downloading=False
-
- def stopAll(self):
- self.images = []
+#class GetImage(threading.Thread):
+# def __init__(self, url, stream):
+# threading.Thread.__init__(self)
+# self.url = url
+# self.stream = stream
+#
+# def run(self):
+# f = urllib2.urlopen(self.url)
+# data = f.read()
+# f.close()
+# self.stream.write(data)
+# self.stream.close()
+#
+#class ImageDownloader():
+# def __init__(self):
+# self.images = []
+# self.downloading = False
+#
+# def queueImage(self, url, stream):
+# self.images.append((url, stream))
+# if not self.downloading:
+# self.downloading = True
+# gobject.timeout_add(50, self.checkQueue)
+#
+# def checkQueue(self):
+# for i in range(4-threading.activeCount()):
+# if len(self.images) > 0:
+# (url, stream) = self.images.pop()
+# GetImage(url, stream).start()
+# if len(self.images)>0:
+# gobject.timeout_add(200, self.checkQueue)
+# else:
+# self.downloading=False
+#
+# def stopAll(self):
+# self.images = []