diff --git a/WKNcharts/TODO b/WKNcharts/TODO index e4605ce..5a78f63 100644 --- a/WKNcharts/TODO +++ b/WKNcharts/TODO @@ -1,5 +1,7 @@ -[.] eingelesenen srcfile Namen, aus dem Textfeld wieder auslesen -[ ] mehrere intervalle holen (30, 300, 10000, 30000) +[ ] intervallcheckboxen auswerten +[ ] zielverzeichnis auswerten [ ] dateinamen besser vergeben [ ] datum einbringen +[ ] bilder im programm anzeigen +[ ] download in threads laufen lassen diff --git a/WKNcharts/getWKNcharts.py b/WKNcharts/getWKNcharts.py index 633e407..235d589 100755 --- a/WKNcharts/getWKNcharts.py +++ b/WKNcharts/getWKNcharts.py @@ -10,6 +10,7 @@ class WKNCharts: '''fetches images from stocks''' def __init__(self): self.wkn_dict = {} + self.times = [300] def readwkndictfromfile(self, filename): '''reads lines like "wkn name\n" from a file and fills a dictionary''' @@ -19,35 +20,52 @@ class WKNCharts: tmp = line.strip("\n").split(" ") if tmp[0] and tmp[1]: self.wkn_dict[tmp[0]] = tmp[1] wknfile.close() + + def readwkndictfromstring(self, wknstring): + '''takes the given string into a "wkn name" dictionary''' + tmp2 = wknstring.splitlines() + print len(tmp2) + for i in tmp2: + tmp = i.split() + if tmp[0] and tmp[1]: self.wkn_dict[tmp[0]] = tmp[1] - def getchart(self, wkn): + def getchart(self, wkn, time, width=400, height=240): '''fetches the images via http''' host = "http://gfx.finanztreff.de/charts/cc_gatrixx.gfx?" params = urllib.urlencode({ 'string':wkn, - 'b':400, - 'h':240, + 'b':width, + 'h':height, 'out':"png", - 'zeit':300, + 'zeit':time, 'typ':0, 'boerse':1, 'land':276, 'seite':"kurse", 'herkunft':123 }) - print "ich hole jetzt \"%s\":" % self.wkn_dict[wkn] - print host + params + #print "ich hole jetzt \"%s\" %i:" % (self.wkn_dict[wkn], time) + #print host + params + self.gui.add_log(host + params) try: f = urllib.urlopen(host + params) - png = open(self.wkn_dict[wkn]+".png", "w") + png = open("images/"+self.wkn_dict[wkn]+str(time)+".png", "w") png.write(f.read()) png.close() except IOError, e: - print e + self.gui.add_log(e) + #print e - def getallcharts(self): + def set_times(self, times): + self.times = times + + def getallcharts(self, gui): + self.gui = gui for wkn in self.wkn_dict.keys(): - self.getchart(wkn) + for time in self.times: + self.gui.add_log("hole: %s %i" % (wkn, time)) + self.getchart(wkn, time) + return if __name__ == "__main__": diff --git a/WKNcharts/wknGUI.py b/WKNcharts/wknGUI.py index 77514d4..265b6a1 100644 --- a/WKNcharts/wknGUI.py +++ b/WKNcharts/wknGUI.py @@ -7,37 +7,82 @@ class WknGUI: """ This is a GTK-Frontend for getWKNcharts.py """ - import sys + import sys, time + wkns = "" + log = "" def __init__(self, gtk): self.gladefile = "wkncharts.glade" self.gtk = gtk self.gladefile = "wkncharts.glade" self.wkngui = self.gtk.glade.XML(self.gladefile) - actions = { "on_read_srcfile_clicked": self.clicked_read_srcfile, + actions = { "on_read_settings_clicked": self.clicked_read_settings, + "on_cancel_settings_clicked": self.clicked_cancel_settings, "on_choose_srcfile_clicked": self.clicked_choose_srcfile, + "on_bu_wget_charts_clicked": self.clicked_wget_charts, + "on_bu_exit_clicked": self.exit, "on_window1_destroy": self.exit } self.wkngui.signal_autoconnect (actions) + self.log += "\n"+self.time.strftime('%H:%M:%S')+" " + self.log += "Programm gestartet " + self.clicked_read_settings(self) - def clicked_read_srcfile(self, widget): - file = self.wkngui.get_widget("tf_srcfile").get_text() + def clicked_wget_charts(self, widget): + import getWKNcharts + '''the real download logic lies in getWKNcharts + that's why, we let it read in the wkn file''' + charts = getWKNcharts.WKNCharts() + charts.readwkndictfromstring(self.wkns) + charts.set_times([30, 300]) + self.add_log("beginne Download der WKNS") + charts.getallcharts(self) + self.add_log("Download abgeschlossen") + def clicked_read_settings(self, widget): + self.outputfield = self.wkngui.get_widget("tf_srcfile") + self.textbuffer = self.outputfield.get_buffer() + file = self.textbuffer.get_text(*self.textbuffer.get_bounds ()) + try: + tmpfile = open(file, "r") + filecontent = tmpfile.read() + tmpfile.close() + self.add_log("%s erfolgreich eingelesen" % file) + except: + self.buffer.set_text(filecontent) + self.log = "Achtung: Konnte %s nicht einlesen" % file + self.wkns = (filecontent) + self.tf_wknlist = self.wkngui.get_widget("tf_wknlist") + self.wknlistbuffer = self.tf_wknlist.get_buffer() + self.wknlistbuffer.set_text(self.wkns) + self.add_log("neue Einstellungen gespeichert") + + def clicked_cancel_settings(self, widget): + '''TODO: + self.add_log("alte Einstellungen wieder hergestellt") + ''' + pass def clicked_choose_srcfile(self, widget): import filechooser fcd = filechooser.FileChooserDialog() filename = fcd.getfilename() + self.outputfield = self.wkngui.get_widget("tf_srcfile") + self.textbuffer = self.outputfield.get_buffer() if filename: - self.outputfield = self.wkngui.get_widget("tf_srcfile") - self.textbuffer = self.outputfield.get_buffer() self.textbuffer.set_text(filename) else: - self.outputfield = self.wkngui.get_widget("tf_srcfile") - self.textbuffer = self.outputfield.get_buffer() self.textbuffer.set_text("keine Datei ausgewaehlt") + def add_log(self, text): + self.logbuch = self.wkngui.get_widget("tf_logbook") + self.buffer = self.logbuch.get_buffer() + self.log += "\n"+self.time.strftime('%H:%M:%S')+" " + self.log += text + self.buffer.set_text(self.log) + def exit(self, widget): print "ciao ciao" self.sys.exit(1) + diff --git a/WKNcharts/wknGUI.pyc b/WKNcharts/wknGUI.pyc index 479303d..d2cfd95 100644 Binary files a/WKNcharts/wknGUI.pyc and b/WKNcharts/wknGUI.pyc differ diff --git a/WKNcharts/wkncharts.glade b/WKNcharts/wkncharts.glade index 2ae9808..acd4ac4 100644 --- a/WKNcharts/wkncharts.glade +++ b/WKNcharts/wkncharts.glade @@ -4,11 +4,15 @@ + 500 + 400 True - window1 + WKN Charts GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False + 200 + 300 True False True @@ -30,9 +34,10 @@ + 1 True False - 0 + 1 @@ -43,42 +48,21 @@ True - Wertpapierkennnummer - False + WKN / Name + True False - GTK_JUSTIFY_LEFT + GTK_JUSTIFY_CENTER False False 0.5 0.5 0 - 0 + 4 0 - False - False - - - - - - True - Aktien/Fond Name - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False + True + True @@ -90,47 +74,33 @@ - + True - False - 0 + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - + True True - True - True - 0 - - True - * - False + False + False + True + GTK_JUSTIFY_CENTER + GTK_WRAP_NONE + True + 2 + 2 + 2 + 0 + 0 + 0 + -- noch keine WKNs eingelesen -- +(siehe Einstellungen) - - 0 - True - True - - - - - - True - True - True - True - 0 - - True - * - False - - - 0 - True - True - @@ -143,17 +113,76 @@ True - False + True 0 - + True True - Hinzufügen - True GTK_RELIEF_NORMAL True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-ok + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Charts herunterladen + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 0 @@ -163,13 +192,72 @@ - + True True - Löschen - True GTK_RELIEF_NORMAL True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-quit + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Beenden + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 0 @@ -179,8 +267,8 @@ - 0 - True + 7 + False False GTK_PACK_END @@ -218,15 +306,40 @@ 0 - + + True + gtk-zoom-fit + 4 + 0.5 + 0.5 + 0 + 0 + + + 7 + False + True + - - + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT - - + + + + + + 0 + True + True + @@ -261,29 +374,60 @@ 0 - + + 2 True + 2 + 3 False - 0 + 3 + 4 True - Quelldatei + Quelldatei: False False - GTK_JUSTIFY_LEFT + GTK_JUSTIFY_RIGHT False False - 0.5 - 0.5 + 0 + 0 0 0 - 0 - False - False + 0 + 1 + 0 + 1 + fill + + + + + + + True + Zielverzeichnis: + False + False + GTK_JUSTIFY_RIGHT + False + False + 0 + 0 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + @@ -299,30 +443,347 @@ True + True + True True GDK_EXTENSION_EVENTS_ALL - False + True False True GTK_JUSTIFY_LEFT GTK_WRAP_NONE - False - 0 + True + 6 + 0 + 0 + 0 + 0 + 2 + wkns.txt + + + + + 1 + 2 + 0 + 1 + fill + + + + + + True + True + GTK_POLICY_NEVER + GTK_POLICY_NEVER + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + True + True + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 6 0 0 0 0 0 - Dateiname + TODO - 0 - True - True + 1 + 2 + 1 + 2 + fill + fill + + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-open + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + auswählen + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-open + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + auswählen + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 2 + 3 + 1 + 2 + fill + + + + + + 3 + False + True + + + + + + 5 + True + 1 + 4 + True + 0 + 0 + + + + True + True + 300 Tage + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + True + 30 Tage + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + True + 3 Jahre + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 3 + 4 + 0 + 1 + fill + + + + + + + True + True + ein Tag + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 0 + 1 + 0 + 1 + fill + + + + + + 2 + False + False + + + + + + True 0 @@ -332,37 +793,166 @@ - + + 10 True - True - Quelldatei einlesen - True - GTK_RELIEF_NORMAL - True - - - - 0 - True - False - GTK_PACK_END - - + True + 10 - - - True - True - Quelldatei auswählen - True - GTK_RELIEF_NORMAL - True - + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-undo + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Rückgängig + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-apply + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Einstellungen übernehmen + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + 0 False - False + True @@ -397,49 +987,17 @@ False 0 - - - True - label5 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - - - 0 - True - True - - - True True - GTK_POLICY_ALWAYS + GTK_POLICY_NEVER GTK_POLICY_ALWAYS GTK_SHADOW_NONE GTK_CORNER_TOP_LEFT - + True True True @@ -459,7 +1017,7 @@ - 0 + 1 True True diff --git a/WKNcharts/wkncharts.glade.bak b/WKNcharts/wkncharts.glade.bak index 23c7a1d..225ff2e 100644 --- a/WKNcharts/wkncharts.glade.bak +++ b/WKNcharts/wkncharts.glade.bak @@ -4,11 +4,15 @@ + 300 + 400 True - window1 + WKN Charts GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False + 200 + 300 True False True @@ -30,9 +34,10 @@ + 1 True False - 0 + 1 @@ -43,42 +48,21 @@ True - Wertpapierkennnummer - False + WKN / Name + True False - GTK_JUSTIFY_LEFT + GTK_JUSTIFY_CENTER False False 0.5 0.5 0 - 0 + 4 0 - False - False - - - - - - True - Aktien/Fond Name - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False + True + True @@ -90,47 +74,33 @@ - + True - False - 0 + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - + True True - True - True - 0 - - True - * - False + False + False + True + GTK_JUSTIFY_CENTER + GTK_WRAP_NONE + True + 2 + 2 + 2 + 0 + 0 + 0 + -- noch keine WKNs eingelesen -- +(siehe Einstellungen) - - 0 - True - True - - - - - - True - True - True - True - 0 - - True - * - False - - - 0 - True - True - @@ -143,17 +113,76 @@ True - False + True 0 - + True True - Hinzufügen - True GTK_RELIEF_NORMAL True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-ok + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Charts herunterladen + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 0 @@ -163,13 +192,72 @@ - + True True - Löschen - True GTK_RELIEF_NORMAL True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-quit + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Beenden + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 0 @@ -179,8 +267,8 @@ - 0 - True + 7 + False False GTK_PACK_END @@ -218,15 +306,40 @@ 0 - + + True + gtk-zoom-fit + 4 + 0.5 + 0.5 + 0 + 0 + + + 7 + False + True + - - + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT - - + + + + + + 0 + True + True + @@ -261,36 +374,66 @@ 0 - + + 2 True + 2 + 3 False - 0 + 3 + 4 True - Quelldatei + Quelldatei: False False - GTK_JUSTIFY_LEFT + GTK_JUSTIFY_RIGHT False False - 0.5 - 0.5 + 0 + 0 0 0 - 0 - False - False + 0 + 1 + 0 + 1 + fill + - + + True + Zielverzeichnis: + False + False + GTK_JUSTIFY_RIGHT + False + False + 0 + 0 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + True - False True GTK_POLICY_NEVER GTK_POLICY_NEVER @@ -300,30 +443,347 @@ True + True + True True GDK_EXTENSION_EVENTS_ALL True False - False + True GTK_JUSTIFY_LEFT GTK_WRAP_NONE True - 0 + 6 + 0 + 0 + 0 + 0 + 2 + wkns.txt + + + + + 1 + 2 + 0 + 1 + fill + + + + + + True + True + GTK_POLICY_NEVER + GTK_POLICY_NEVER + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + True + True + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 6 0 0 0 0 0 - Dateiname + TODO - 0 - True - True + 1 + 2 + 1 + 2 + fill + fill + + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-open + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + auswählen + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-open + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + auswählen + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 2 + 3 + 1 + 2 + fill + + + + + + 3 + False + True + + + + + + 5 + True + 1 + 4 + True + 0 + 0 + + + + True + True + 300 Tage + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + True + 30 Tage + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + True + 3 Jahre + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 3 + 4 + 0 + 1 + fill + + + + + + + True + True + ein Tag + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 0 + 1 + 0 + 1 + fill + + + + + + 2 + False + False + + + + + + True 0 @@ -333,37 +793,166 @@ - + + 10 True - True - Quelldatei einlesen - True - GTK_RELIEF_NORMAL - True - - - - 0 - True - False - GTK_PACK_END - - + True + 10 - - - True - True - Quelldatei auswählen - True - GTK_RELIEF_NORMAL - True - + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-undo + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Rückgängig + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-apply + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Einstellungen übernehmen + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + 0 False - False + True @@ -398,49 +987,17 @@ False 0 - - - True - label5 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - - - 0 - True - True - - - True True - GTK_POLICY_ALWAYS + GTK_POLICY_NEVER GTK_POLICY_ALWAYS GTK_SHADOW_NONE GTK_CORNER_TOP_LEFT - + True True True @@ -460,7 +1017,7 @@ - 0 + 1 True True diff --git a/WKNcharts/wkns.txt b/WKNcharts/wkns.txt index 05b3a8e..f5062f4 100644 --- a/WKNcharts/wkns.txt +++ b/WKNcharts/wkns.txt @@ -1,2 +1,2 @@ 881823 samsung - +661823 sumsang