projects
/
comic-widget
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
14d3022
)
bugfixes
author
Marcus Wikström
<mece@ovi.com>
Sun, 31 Jan 2010 17:22:22 +0000
(19:22 +0200)
committer
Marcus Wikström
<mece@ovi.com>
Sun, 31 Jan 2010 17:22:22 +0000
(19:22 +0200)
src/usr/lib/hildon-desktop/comic-widget.py
patch
|
blob
|
history
diff --git
a/src/usr/lib/hildon-desktop/comic-widget.py
b/src/usr/lib/hildon-desktop/comic-widget.py
index
6c3ae6e
..
0965909
100644
(file)
--- a/
src/usr/lib/hildon-desktop/comic-widget.py
+++ b/
src/usr/lib/hildon-desktop/comic-widget.py
@@
-28,14
+28,13
@@
comics = {"xkcd":{"name":"xkcd","link":"http://xkcd.org/","start":666,"dbfile":d
# handling of the comics
class ComicDb():
def __init__(self, comic):
# 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
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)
# if not, create it.
dbf = self.get_dbfile()
dbr = csv.DictReader(dbf)
@@
-49,17
+48,21
@@
class ComicDb():
def get_dbfile(self):
#if db file exist, read it
def get_dbfile(self):
#if db file exist, read it
+ print "fetching " + self.dbfile
if os.path.isfile(self.dbfile) == True:
if os.path.isfile(self.dbfile) == True:
+ print "found " + self.dbfile
dbf = open(self.dbfile, 'r')
return dbf
# if not, copy it.
else:
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:
try:
- os.makedirs(dbdir)
+ os.makedirs(dbdir + self.comic + "/")
except:
print "comic db creation failed on mkdir"
except:
print "comic db creation failed on mkdir"
- exit()
+ exit()
try:
shutil.copyfile(basedbdir + "comicdb." + self.comic + ".csv", dbdir + "comicdb." + self.comic + ".csv")
except:
try:
shutil.copyfile(basedbdir + "comicdb." + self.comic + ".csv", dbdir + "comicdb." + self.comic + ".csv")
except:
@@
-93,6
+96,13
@@
class ComicDb():
else:
#fetch file
print filename + " not found\nretrieving " + dbrow['url'] + "\n"
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
urllib.urlretrieve(dbrow['url'], filename)
print "success\n"
return filename