Commit a1f34c49 authored by Adam Caprez's avatar Adam Caprez
Browse files

Add handling for non-existent file in GridFS.

parent 9b8396be
......@@ -238,8 +238,14 @@ class MongoDB(object):
Fetch the file with _id 'gridfs_id' from GridFS and save to the file 'filename'.
"""
gridfs_file = self.gfs.get(gridfs_id)
gridfs_md5 = gridfs_file.md5
try:
gridfs_file = self.gfs.get(gridfs_id)
gridfs_md5 = gridfs_file.md5
except gridfs.errors.NoFile as e:
print "Error fetching file from GridFS!\nNo file with ID '%s'" % (gridfs_id)
print e
sys.exit(1)
try:
output_fh = open(filename,'wb')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment