FAIL and print
If source and dest in copy are the same, it is no longer reported If an image can't be read, it is counted as failed
This commit is contained in:
parent
96247d41d5
commit
4b70374e9d
2 changed files with 5 additions and 6 deletions
|
@ -35,7 +35,6 @@ def check_archive(fullpath):
|
||||||
archive = conf.get_archive_location()
|
archive = conf.get_archive_location()
|
||||||
filename = os.path.basename(fullpath)
|
filename = os.path.basename(fullpath)
|
||||||
archfile = os.path.join(archive, filename)
|
archfile = os.path.join(archive, filename)
|
||||||
#print "Path", archfile, "exists:", os.path.exists(archfile)
|
|
||||||
return os.path.exists(archfile)
|
return os.path.exists(archfile)
|
||||||
|
|
||||||
class Downloader(object):
|
class Downloader(object):
|
||||||
|
@ -134,7 +133,8 @@ class Downloader(object):
|
||||||
else:
|
else:
|
||||||
downloaded += 1
|
downloaded += 1
|
||||||
if self.on_downloaded is not None:
|
if self.on_downloaded is not None:
|
||||||
self.on_downloaded(filename)
|
if not self.on_downloaded(filename):
|
||||||
|
failed += 1
|
||||||
else:
|
else:
|
||||||
skipped += 1
|
skipped += 1
|
||||||
i += 1
|
i += 1
|
||||||
|
|
|
@ -33,6 +33,7 @@ class Sorter:
|
||||||
|
|
||||||
def act(self, filename):
|
def act(self, filename):
|
||||||
download_base = self.conf.get_download_location()
|
download_base = self.conf.get_download_location()
|
||||||
|
retval = True
|
||||||
|
|
||||||
if self.check_filename(filename):
|
if self.check_filename(filename):
|
||||||
image = None
|
image = None
|
||||||
|
@ -40,8 +41,7 @@ class Sorter:
|
||||||
image = Image.open(os.path.join(download_base,
|
image = Image.open(os.path.join(download_base,
|
||||||
filename))
|
filename))
|
||||||
except IOError:
|
except IOError:
|
||||||
print "Cannot read image file %s, might be broken" \
|
retval = False
|
||||||
% filename
|
|
||||||
|
|
||||||
if not image == None and self.archive_check(filename):
|
if not image == None and self.archive_check(filename):
|
||||||
for resolution in self.resolutions:
|
for resolution in self.resolutions:
|
||||||
|
@ -55,13 +55,13 @@ class Sorter:
|
||||||
str(image.size[1]) == resolution[1]:
|
str(image.size[1]) == resolution[1]:
|
||||||
if not os.path.exists(folderpath):
|
if not os.path.exists(folderpath):
|
||||||
os.makedirs(folderpath)
|
os.makedirs(folderpath)
|
||||||
#print "creating", folderpath
|
|
||||||
|
|
||||||
self.copy(filename, folderpath)
|
self.copy(filename, folderpath)
|
||||||
break
|
break
|
||||||
|
|
||||||
self.archive(filename)
|
self.archive(filename)
|
||||||
self.remove(filename)
|
self.remove(filename)
|
||||||
|
return retval
|
||||||
|
|
||||||
def copy(self, filename, destpath):
|
def copy(self, filename, destpath):
|
||||||
download_base = self.conf.get_download_location()
|
download_base = self.conf.get_download_location()
|
||||||
|
@ -73,7 +73,6 @@ class Sorter:
|
||||||
shutil.copy(source, dest)
|
shutil.copy(source, dest)
|
||||||
else:
|
else:
|
||||||
print "\nHow can this even happen?! Copying", source, "to", dest
|
print "\nHow can this even happen?! Copying", source, "to", dest
|
||||||
#print "\nParameters are", filename, "and", destpath
|
|
||||||
|
|
||||||
def archive(self, filename):
|
def archive(self, filename):
|
||||||
download_base = self.conf.get_download_location()
|
download_base = self.conf.get_download_location()
|
||||||
|
|
Loading…
Reference in a new issue