thread bug gefixt

This commit is contained in:
age 2006-06-10 12:18:28 +00:00
parent 40172e25e0
commit 4ed16744e8
7 changed files with 24 additions and 13 deletions

View file

@ -1,13 +1,13 @@
##TODO fuer WKNcharts 02006-06 = TODO =
[ ] download abbrechenbar machen
[ ] intervallcheckboxen auswerten [ ] intervallcheckboxen auswerten
[ ] zielverzeichnis auswerten [ ] zielverzeichnis auswerten
[ ] dateinamen besser vergeben [ ] dateinamen besser vergeben
[ ] datum einbringen [ ] datum einbringen
[ ] bilder im programm anzeigen [ ] bilder im programm anzeigen
[!] loggen in threads erzeugt Speicherzugriffsfehler
= DONE =
[*] loggen in threads erzeugt Speicherzugriffsfehler
----- -----

View file

@ -18,8 +18,11 @@ class WknCharts:
import wknGUI import wknGUI
wg = wknGUI.WknGUI(gtk) wg = wknGUI.WknGUI(gtk)
# this is necessary for using threads later
gtk.gdk.threads_init() gtk.gdk.threads_init()
gtk.gdk.threads_enter()
gtk.main() gtk.main()
gtk.gdk.threads_leave()
if __name__ == "__main__": if __name__ == "__main__":
wc = WknCharts() wc = WknCharts()

View file

@ -46,28 +46,28 @@ class WKNCharts:
}) })
#print "ich hole jetzt \"%s\" %i:" % (self.wkn_dict[wkn], time) #print "ich hole jetzt \"%s\" %i:" % (self.wkn_dict[wkn], time)
#print host + params #print host + params
self.gui.add_log(host + params) self.gui.add_log("%s %s" % (host, params))
try: try:
'''
f = urllib.urlopen(host + params) f = urllib.urlopen(host + params)
png = open("images/"+self.wkn_dict[wkn]+str(time)+".png", "w") png = open("images/"+self.wkn_dict[wkn]+str(time)+".png", "w")
png.write(f.read()) png.write(f.read())
png.close() png.close()
'''
import time
time.sleep(2)
except IOError, e: except IOError, e:
#self.gui.add_log(e)
print e print e
def set_times(self, times): def set_times(self, times):
self.times = times self.times = times
def getallcharts(self, gui): def getallcharts(self, gui) :
self.gui = gui self.gui = gui
for wkn in self.wkn_dict.keys(): for wkn in self.wkn_dict.keys():
self.gui.add_log("hole: %s (%s)" % (self.wkn_dict[wkn], wkn))
for time in self.times: for time in self.times:
#gui.gtk.gdk.threads_enter()
##TODO: logbuch killt den thread
##gui.add_log("hole: %s %i" % (wkn, time))
self.getchart(wkn, time) self.getchart(wkn, time)
#gui.gtk.gdk.threads_leave()
print "Download fertig" print "Download fertig"
return return

View file

@ -38,6 +38,7 @@ class WknGUI:
charts.set_times([30, 300]) charts.set_times([30, 300])
self.add_log("beginne Download der WKNS") self.add_log("beginne Download der WKNS")
## downlaoding in threads, so the gui won't hang ## downlaoding in threads, so the gui won't hang
## giving it 'self', so that it can use the logging window
Thread(target=charts.getallcharts,args=(self,)).start() Thread(target=charts.getallcharts,args=(self,)).start()
## unthreaded version ## unthreaded version
#charts.getallcharts(self) #charts.getallcharts(self)

Binary file not shown.

View file

@ -4,7 +4,7 @@
<glade-interface> <glade-interface>
<widget class="GtkWindow" id="window1"> <widget class="GtkWindow" id="window1">
<property name="width_request">300</property> <property name="width_request">500</property>
<property name="height_request">400</property> <property name="height_request">400</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">WKN Charts</property> <property name="title" translatable="yes">WKN Charts</property>

View file

@ -1,2 +1,9 @@
881823 samsung 881823 samsung
661823 sumsang 621823 sumsang
631823 sumsang
841823 samsung
181823 samsung
851823 samsung
666823 sumsang
663823 sumsang
661323 sumsang