Skip to content

Commit

Permalink
In case a download silently failed with no error, check whether the f…
Browse files Browse the repository at this point in the history
…ile is there before trying to call magic parser on it
  • Loading branch information
akkana committed Apr 18, 2017
1 parent 72889e0 commit 08fcf14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pytopo/DownloadTileQueue.py
Expand Up @@ -6,6 +6,7 @@
'''

import sys
import os
import urllib
import gobject

Expand Down Expand Up @@ -89,6 +90,12 @@ def download(url, localpath, callback):
print e
return None

# Sometimes there's no error but we still didn't download anything.
# Don't try to MIME parse that: magic gets confused by empty files.
if not os.path.exists(localpath):
print "Failed to download", url, "to", localpath
return None

if magic_parser is None:
try:
import magic
Expand Down
2 changes: 1 addition & 1 deletion pytopo/MapWindow.py
Expand Up @@ -1349,7 +1349,7 @@ def draw_pixbuf(self, pixbuf, x_off, y_off, x, y, w, h):
# Sometimes the next line prints:
# GtkWarning: gdk_drawable_real_draw_pixbuf: assertion 'width >= 0 && height >= 0' failed
# but checking width and height doesn't seem to guard against that.
# What does?
# What does? This doesn't:
# print "Drawing pixbuf that is %d x %d!" \
# % (pixbuf.get_width(), pixbuf.get_height())
# if (pixbuf.get_width() <= 0 or pixbuf.get_height() <= 0):
Expand Down

0 comments on commit 08fcf14

Please sign in to comment.