diff --git a/WKNcharts/TODO b/WKNcharts/TODO index 7b59164..5008511 100644 --- a/WKNcharts/TODO +++ b/WKNcharts/TODO @@ -1,10 +1,12 @@ = TODO = -[ ] download abbrechenbar machen +[.] bilder im programm anzeigen + - pyview integrieren +[ ] download abbrechbar machen [ ] intervallcheckboxen auswerten [ ] zielverzeichnis auswerten -[ ] dateinamen besser vergeben -[ ] datum einbringen -[ ] bilder im programm anzeigen +[ ] dateinamen fuer downloads besser vergeben, datum einbringen +[ ] libglade wrapper nutzen +[ ] einstellungen rueckgaengig machen = DONE = [*] loggen in threads erzeugt Speicherzugriffsfehler diff --git a/WKNcharts/getWKNcharts.py b/WKNcharts/getWKNcharts.py index 632aded..b9e0ff6 100755 --- a/WKNcharts/getWKNcharts.py +++ b/WKNcharts/getWKNcharts.py @@ -14,7 +14,10 @@ class WKNCharts: def readwkndictfromfile(self, filename): '''reads lines like "wkn name\n" from a file and fills a dictionary''' - wknfile = open(filename,"r") + try: + wknfile = open(filename,"r") + except IOError, e: + print e for line in wknfile: 'remove CRLF and split the line in two parts on spacer' tmp = line.strip("\n").split(" ") @@ -44,16 +47,14 @@ class WKNCharts: 'seite':"kurse", 'herkunft':123 }) - #print "ich hole jetzt \"%s\" %i:" % (self.wkn_dict[wkn], time) - #print host + params - self.gui.add_log("%s %s" % (host, params)) + print "ich hole jetzt \"%s\" %i:" % (self.wkn_dict[wkn], time) + print host + params + ###self.gui.add_log("%s %s" % (host, params)) try: - ''' f = urllib.urlopen(host + params) png = open("images/"+self.wkn_dict[wkn]+str(time)+".png", "w") png.write(f.read()) png.close() - ''' import time time.sleep(2) except IOError, e: @@ -62,6 +63,13 @@ class WKNCharts: def set_times(self, times): self.times = times + def getallchartsnogui(self) : + for wkn in self.wkn_dict.keys(): + for time in self.times: + self.getchart(wkn, time) + print "Download fertig" + return + def getallcharts(self, gui) : self.gui = gui for wkn in self.wkn_dict.keys(): @@ -82,6 +90,6 @@ if __name__ == "__main__": wkn.readwkndictfromfile(options.filename) #for i in wkn.wkn_dict.keys(): #print "%s \t %s" % (i, wkn.wkn_dict[i]) - wkn.getallcharts() + wkn.getallchartsnogui() #wkn.addwkn(wkn, name) #wkn.delwkn(wkn) diff --git a/WKNcharts/pyview/libglade.py b/WKNcharts/pyview/libglade.py new file mode 100644 index 0000000..2effff3 --- /dev/null +++ b/WKNcharts/pyview/libglade.py @@ -0,0 +1,33 @@ +#This requires pygtk2 + +import gettext +import gtk +import gtk.glade + +class GladeWrapper: + """ + Superclass for glade based applications. Just derive from this + and your subclass should create methods whose names correspond to + the signal handlers defined in the glade file. Any other attributes + in your class will be safely ignored. + + This class will give you the ability to do: + subclass_instance.GtkWindow.method(...) + subclass_instance.widget_name... + """ + def __init__(self, Filename, WindowName): + #load glade file. + self.widgets = gtk.glade.XML(Filename, WindowName, gettext.textdomain()) + self.GtkWindow = getattr(self, WindowName) + + instance_attributes = {} + for attribute in dir(self.__class__): + instance_attributes[attribute] = getattr(self, attribute) + self.widgets.signal_autoconnect(instance_attributes) + + def __getattr__(self, attribute): #Called when no attribute in __dict__ + widget = self.widgets.get_widget(attribute) + if widget is None: + raise AttributeError("Widget [" + attribute + "] not found") + self.__dict__[attribute] = widget #add reference to cache + return widget diff --git a/WKNcharts/pyview/pyview b/WKNcharts/pyview/pyview new file mode 100644 index 0000000..ac4057a --- /dev/null +++ b/WKNcharts/pyview/pyview @@ -0,0 +1,93 @@ +#!/usr/bin/env python + +import libglade +import gtk + +import locale +locale.setlocale(locale.LC_ALL,'') + +import os,stat + +import re #fnmatch doesn't support *.{png,tiff}" +match_pics=re.compile(r".*\.(png|tiff|jpg|jpeg|xpm)$") + +import sys + +if len(sys.argv) == 2: + start_dir=sys.argv[1] +else: + start_dir="." + +class pyview(libglade.GladeWrapper): + + def __init__(self, Filename, WindowName, start_dir="."): + libglade.GladeWrapper.__init__(self, Filename, WindowName) + + #self.files.get_selection().set_mode(gtk.SELECTION_BROWSE) + """ + GTK_SELECTION_NONE, /* Nothing can be selected */ + GTK_SELECTION_SINGLE, /* One can be selected (default) */ + GTK_SELECTION_BROWSE, /* One must be selected */ + GTK_SELECTION_MULTIPLE, /* Multiple can be selected */ + """ + self.status_id = self.status.get_context_id("file") + + self.files_model=gtk.ListStore(str) + self.files.set_model(self.files_model) + files_column = gtk.TreeViewColumn("", gtk.CellRendererText(), text=0) + self.files.append_column(files_column) + + self.dirs_model=gtk.ListStore(str) + self.dirs.set_model(self.dirs_model) + dirs_column = gtk.TreeViewColumn("", gtk.CellRendererText(), text=0) + self.dirs.append_column(dirs_column) + + self._chdir(start_dir) + + def _chdir(self,newdir): + try: + os.chdir(newdir) + direntries=os.listdir(".") + direntries.sort() + direntries.insert(0,"..") + except: + return + self.files_model.clear() + self.dirs_model.clear() + for direntry in direntries: + mode=os.stat(direntry).st_mode + if stat.S_ISREG(mode): + if match_pics.match(direntry): + iter=self.files_model.append() + self.files_model.set(iter,0,direntry) + elif stat.S_ISDIR(mode): + iter=self.dirs_model.append() + self.dirs_model.set(iter,0,direntry) + + ################# + # Signal handlers + ################# + + def on_dirs_row_activated(self, tv, *args): + model, iter = tv.get_selection().get_selected() + self._chdir(model.get_value(iter,0)) + tv.set_cursor(0) + + def on_files_row_selected(self, tv, *args): + self.status.pop(self.status_id) + model, iter = tv.get_selection().get_selected() + filename=model.get_value(iter,0) + self.image.set_from_file(filename) + size=locale.format("%d",os.stat(filename).st_size,1) + self.status.push(self.status_id,size+" bytes") + + def quit(self, *args): + gtk.main_quit() + + def on_pyview_destroy(self, event): + self.quit() + + +PYVIEW = pyview("./pyview.glade", "pyview", start_dir) + +gtk.main() diff --git a/WKNcharts/pyview/pyview.glade b/WKNcharts/pyview/pyview.glade new file mode 100644 index 0000000..2654676 --- /dev/null +++ b/WKNcharts/pyview/pyview.glade @@ -0,0 +1,177 @@ + + + + + + + + True + PyView + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + + + + + True + False + 0 + + + + True + False + 0 + + + + True + False + 0 + + + + True + + + + True + True + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + 140 + 140 + True + select directory + True + False + False + False + True + + + + + + True + False + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + select file + True + False + False + False + True + + + + + + True + True + + + + + True + False + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + True + GTK_SHADOW_IN + + + + True + 0.5 + 0.5 + 0 + 0 + + + + + + + True + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + True + True + + + 0 + False + False + + + + + + + diff --git a/WKNcharts/wknGUI.py b/WKNcharts/wknGUI.py index ae9b532..3152a69 100644 --- a/WKNcharts/wknGUI.py +++ b/WKNcharts/wknGUI.py @@ -20,6 +20,7 @@ class WknGUI: "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_pics_clicked": self.clicked_show_pics, "on_bu_exit_clicked": self.exit, "on_window1_destroy": self.exit } @@ -35,7 +36,8 @@ class WknGUI: that's why, we let it read in the wkn file''' charts = getWKNcharts.WKNCharts() charts.readwkndictfromstring(self.wkns) - charts.set_times([30, 300]) + #charts.set_times([30, 300]) + charts.set_times([30]) self.add_log("beginne Download der WKNS") ## downlaoding in threads, so the gui won't hang ## giving it 'self', so that it can use the logging window @@ -85,6 +87,12 @@ class WknGUI: self.log += "\n"+self.time.strftime('%H:%M:%S')+" " self.log += text self.buffer.set_text(self.log) + + def clicked_show_pics(self, widget): + '''this is for now 'cause i'm to lazy to implement the viewer + atm''' + self.ci = self.wkngui.get_widget("chartimage") + self.ci.set_from_file("foo.png") def exit(self, widget): print "ciao ciao" diff --git a/WKNcharts/wknGUI.pyc b/WKNcharts/wknGUI.pyc index a6f2918..42c55e4 100644 Binary files a/WKNcharts/wknGUI.pyc and b/WKNcharts/wknGUI.pyc differ diff --git a/WKNcharts/wkncharts.glade b/WKNcharts/wkncharts.glade index acd4ac4..7df5048 100644 --- a/WKNcharts/wkncharts.glade +++ b/WKNcharts/wkncharts.glade @@ -191,6 +191,81 @@ + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-zoom-in + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Bilder betrachten + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + True @@ -332,7 +407,20 @@ GTK_CORNER_TOP_LEFT - + + True + GTK_SHADOW_IN + + + + True + 0.5 + 0.5 + 0 + 0 + + + diff --git a/WKNcharts/wkncharts.glade.bak b/WKNcharts/wkncharts.glade.bak deleted file mode 100644 index acd4ac4..0000000 --- a/WKNcharts/wkncharts.glade.bak +++ /dev/null @@ -1,1054 +0,0 @@ - - - - - - - 500 - 400 - True - WKN Charts - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 200 - 300 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - - - - - True - True - True - True - GTK_POS_TOP - False - False - - - - 1 - True - False - 1 - - - - True - True - 0 - - - - True - WKN / Name - True - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 4 - - - 0 - True - True - - - - - 0 - False - False - - - - - - True - True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - 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 - 0 - - - - True - 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 - False - False - - - - - - True - 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 - False - False - - - - - 7 - False - False - GTK_PACK_END - - - - - False - True - - - - - - True - Download - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 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 - - - - - False - True - - - - - - True - Bilder - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - 2 - True - 2 - 3 - False - 3 - 4 - - - - True - Quelldatei: - False - False - GTK_JUSTIFY_RIGHT - False - False - 0 - 0 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - Zielverzeichnis: - False - False - GTK_JUSTIFY_RIGHT - False - False - 0 - 0 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - True - GTK_POLICY_NEVER - GTK_POLICY_NEVER - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - True - GDK_EXTENSION_EVENTS_ALL - True - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_NONE - 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 - TODO - - - - - 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 - True - True - - - - - - 10 - True - True - 10 - - - - 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 - True - - - - - False - True - - - - - - True - Einstellungen - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - True - GTK_POLICY_NEVER - GTK_POLICY_ALWAYS - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_NONE - True - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - 1 - True - True - - - - - False - True - - - - - - True - Logbuch - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - - diff --git a/WKNcharts/wkns.txt b/WKNcharts/wkns.txt index 520dd3e..28a0a01 100644 --- a/WKNcharts/wkns.txt +++ b/WKNcharts/wkns.txt @@ -1,9 +1,3 @@ 881823 samsung 621823 sumsang -631823 sumsang -841823 samsung -181823 samsung -851823 samsung -666823 sumsang -663823 sumsang 661323 sumsang