Bug 859349 - Saving .mozbuild/warnings.json fails if .mozbuild doesn't exist [r=gps]

This commit is contained in:
Matt Brubeck 2013-04-08 11:14:33 -07:00
parent 89cb954609
commit 91c4b690de

View File

@ -6,6 +6,7 @@
from __future__ import unicode_literals
import errno
import json
import os
import re
@ -265,6 +266,12 @@ class WarningsDatabase(object):
def save_to_file(self, filename):
"""Save the database to a file."""
try:
# Ensure the directory exists
os.makedirs(os.path.dirname(filename))
except OSError as e:
if e.errno != errno.EEXIST:
raise
with open(filename, 'wb') as fh:
self.serialize(fh)