scoobidoo

This commit is contained in:
age 2006-06-13 23:13:52 +00:00
parent 9c305e9253
commit 3abb7f3841
10 changed files with 422 additions and 1073 deletions

View file

@ -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

View file

@ -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)

View file

@ -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

93
WKNcharts/pyview/pyview Normal file
View file

@ -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()

View file

@ -0,0 +1,177 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<requires lib="gnome"/>
<widget class="GtkWindow" id="pyview">
<property name="visible">True</property>
<property name="title" translatable="yes">PyView</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<signal name="destroy" handler="on_pyview_destroy" last_modification_time="Fri, 28 Nov 2003 07:32:36 GMT"/>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkHPaned" id="hpaned1">
<property name="visible">True</property>
<child>
<widget class="GtkVPaned" id="vpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow5">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="dirs">
<property name="width_request">140</property>
<property name="height_request">140</property>
<property name="visible">True</property>
<property name="tooltip" translatable="yes">select directory</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<signal name="row_activated" handler="on_dirs_row_activated" last_modification_time="Fri, 28 Nov 2003 13:53:21 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow6">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="files">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">select file</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<signal name="cursor_changed" handler="on_files_row_selected" last_modification_time="Thu, 03 Jun 2004 07:14:33 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow8">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkViewport" id="viewport2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkImage" id="image">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkStatusbar" id="status">
<property name="visible">True</property>
<property name="has_resize_grip">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View file

@ -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"

Binary file not shown.

View file

@ -191,6 +191,81 @@
</packing>
</child>
<child>
<widget class="GtkButton" id="bu_pics">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_bu_pics_clicked" last_modification_time="Tue, 13 Jun 2006 21:54:31 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment7">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox12">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="stock">gtk-zoom-in</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="label" translatable="yes">Bilder betrachten</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="bu_exit">
<property name="visible">True</property>
@ -332,7 +407,20 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<placeholder/>
<widget class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkImage" id="chartimage">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>

File diff suppressed because it is too large Load diff

View file

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