Nasty bug where it didn't actually save anything
This commit is contained in:
parent
99b87aeffb
commit
ef79c9991b
4 changed files with 21 additions and 4 deletions
|
@ -34,7 +34,9 @@ class _Backend(object):
|
|||
return False
|
||||
|
||||
def save(self):
|
||||
os.remove(self.table)
|
||||
if os.path.exists(self.table):
|
||||
os.remove(self.table)
|
||||
|
||||
self.create_store_if_needed()
|
||||
for f in self.__new_collection:
|
||||
self.store.insert(self.table, [f])
|
||||
|
|
|
@ -23,6 +23,7 @@ import htmlparser
|
|||
import config
|
||||
import sys
|
||||
import backend
|
||||
import util
|
||||
|
||||
def get_savedir():
|
||||
conf = config.Configuration()
|
||||
|
@ -125,6 +126,8 @@ class Downloader(object):
|
|||
progress.show_progress(i)
|
||||
filename = os.path.join(get_savedir(), os.path.split(link)[1])
|
||||
if not check_archive(filename):
|
||||
util.log(util.LogType.Msg, "%s is not in archive" % filename, None)
|
||||
|
||||
tries = 10
|
||||
while tries > 0:
|
||||
try:
|
||||
|
@ -135,10 +138,15 @@ class Downloader(object):
|
|||
if tries == 0:
|
||||
failed += 1
|
||||
else:
|
||||
util.log(util.LogType.Msg, "succsesfully downloaded %s" % filename, None)
|
||||
downloaded += 1
|
||||
if self.on_downloaded is not None:
|
||||
util.log(util.LogType.Msg, "", self.on_downloaded)
|
||||
|
||||
if not self.on_downloaded(filename):
|
||||
failed += 1
|
||||
else:
|
||||
util.log(util.LogType.Warn, "on_downloaded is None", None)
|
||||
else:
|
||||
skipped += 1
|
||||
i += 1
|
||||
|
|
10
sorter.py
10
sorter.py
|
@ -24,6 +24,8 @@ import os
|
|||
import datetime
|
||||
import backend
|
||||
|
||||
import util
|
||||
|
||||
def dummy_option_creator(value1, value2): pass
|
||||
config._optioncreator = dummy_option_creator
|
||||
|
||||
|
@ -34,10 +36,12 @@ class Sorter:
|
|||
self.resolutions = self.conf.get_resolutions()
|
||||
|
||||
def act(self, filename):
|
||||
util.log(util.LogType.Msg, "sorter is acting", filename)
|
||||
|
||||
download_base = self.conf.get_download_location()
|
||||
retval = True
|
||||
|
||||
if not self.check_filename(filename):
|
||||
if self.check_filename(filename):
|
||||
image = None
|
||||
try:
|
||||
image = Image.open(os.path.join(download_base,
|
||||
|
@ -46,6 +50,8 @@ class Sorter:
|
|||
retval = False
|
||||
|
||||
if not image == None and self.archive_check(filename):
|
||||
util.log(util.LogType.Msg, "Checking resolution", {"filename":filename, "resolution":image.size})
|
||||
|
||||
for resolution in self.resolutions:
|
||||
resolution = resolution.split('x')
|
||||
foldername = "%s-%s" % (resolution[0],
|
||||
|
@ -72,6 +78,8 @@ class Sorter:
|
|||
today = datetime.date.today()
|
||||
dest = os.path.join(destpath,
|
||||
"%d-%d-%d" % (today.year, today.month, today.day))
|
||||
util.log(util.LogType.Msg, "going to copy %s to %s" % (source, dest), None)
|
||||
|
||||
if not os.path.exists(dest):
|
||||
os.makedirs(dest)
|
||||
|
||||
|
|
3
util.py
3
util.py
|
@ -28,11 +28,10 @@ def raw_input_with_default(default, prompt):
|
|||
|
||||
def log(logtype, message, data = None):
|
||||
global loglevel
|
||||
print logtype, loglevel, loglevel >= logtype
|
||||
if loglevel >= logtype:
|
||||
print message
|
||||
if not data is None:
|
||||
print data
|
||||
print "data:\n\tdata"
|
||||
|
||||
homedir = os.getenv("HOME")
|
||||
if homedir is None:
|
||||
|
|
Loading…
Reference in a new issue