+import gobject
import hildon
import hildondesktop
import gtk
# handling of the comics
class ComicDb():
def __init__(self, comic):
- #if no db, start from this comic id.
self.comic = comic
self.start = comics[self.comic]["start"]
self.dbfile = comics[self.comic]["dbfile"]
#if db file exist, read it
- if os.path.isfile(self.dbfile) == True:
- dbf = open(self.dbfile, 'r')
+ # if os.path.isfile(self.dbfile) == True:
+ # dbf = open(self.dbfile, 'r')
# if not, create it.
dbf = self.get_dbfile()
dbr = csv.DictReader(dbf)
def get_dbfile(self):
#if db file exist, read it
+ print "fetching " + self.dbfile
if os.path.isfile(self.dbfile) == True:
+ print "found " + self.dbfile
dbf = open(self.dbfile, 'r')
return dbf
# if not, copy it.
else:
- if not os.path.exists(dbdir):
+ print "file " + self.dbfile + " not found"
+ if not os.path.exists(dbdir + self.comic + "/"):
+ print "path not found: " + dbdir + self.comic + "/"
try:
- os.makedirs(dbdir)
+ os.makedirs(dbdir + self.comic + "/")
except:
print "comic db creation failed on mkdir"
- exit()
+ exit()
try:
shutil.copyfile(basedbdir + "comicdb." + self.comic + ".csv", dbdir + "comicdb." + self.comic + ".csv")
except:
else:
#fetch file
print filename + " not found\nretrieving " + dbrow['url'] + "\n"
+ if not os.path.exists(comiccache + self.comic + "/"):
+ print "create dir " + comiccache + self.comic + "/"
+ try:
+ os.makedirs(comiccache + self.comic + "/")
+ print "created dir"
+ except:
+ print "comic db creation failed on mkdir"
urllib.urlretrieve(dbrow['url'], filename)
print "success\n"
return filename
# ------------UI
class ComicHomePlugin(hildondesktop.HomePluginItem):
+ __gtype_name__ = 'ComicHomePlugin'
def __init__(self):
hildondesktop.HomePluginItem.__init__(self)
global supports_alpha
dialog.run()
dialog.destroy()
-hd_plugin_type = ComicHomePlugin
-
+def hd_plugin_get_object():
+ return gobject.new(ComicHomePlugin, plugin_id = hildon_plugin_id)
if __name__ == "__main__":
- import gobject
- gobject.type_register(hd_plugin_type)
- obj = gobject.new(hd_plugin_type, plugin_id="plugin_id")
+ obj = hd_plugin_get_object()
obj.show_all()
+ print obj.get_text()
gtk.main()