def finish(self):

        # make sure path exists
        folder_name = MetricsSession.get_folder_name(self.slug)

        if not exists(folder_name):
            # Due to race conditions we still need the try/except
            try:
                makedirs(folder_name)
            except __HOLE__, e:
                if e.errno != errno.EEXIST:
                    LOG.error(str(e))
                    raise

        LOG.info('Metrics session saving to %s', self.file_name)

        session = { 'entries': self.entries }

        try:
            f = open(self.file_name, mode='w')
            json.dump(session, f, indent=4)
            f.close()
        except IOError, e:
            LOG.error(str(e))
dataset/ETHPy150Open turbulenz/turbulenz_local/turbulenz_local/models/metrics.py/MetricsSession.finish