Skip to content

Commit

Permalink
Merge pull request #10 from dakotasmith/exceptional_branch
Browse files Browse the repository at this point in the history
Exceptional branch
  • Loading branch information
adammathes committed May 4, 2012
2 parents dbd3806 + 145d7e8 commit 6da735e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions ekko.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@

# TODO: put all this in a config/settings
data_directory = 'data'
connection = pymongo.Connection()
db = connection.ekko
collection = db.items

try:
connection = pymongo.Connection()
db = connection.ekko
collection = db.items
except pymongo.errors.AutoReconnect as e:
# couldn't connect to MongoDB, die
print e
quit()


# This is an abstract class describing what accounts must do
Expand Down Expand Up @@ -587,10 +593,14 @@ def write_file(outfile, output):
os.makedirs(outdir)

f = open(outfile, 'w')
f.write(output) #.encode('utf-8', 'ignore'))
f.close()
except IOError:
print 'NO!!! could not write to %s' % outfile
try:
f.write(output)
except UnicodeEncodeError as e:
f.write(output.encode('utf-8', 'ignore'))
finally:
f.close()
except IOError:
print 'NO!!! could not write to %s' % outfile



Expand Down

0 comments on commit 6da735e

Please sign in to comment.