DataManagment_3.py 586 B

1234567891011121314151617
  1. def dump(self, save=False):
  2. try:
  3. if __name__ == '__main__':
  4. f = open("/tmp/test", "wb")
  5. else:
  6. f = open(settings.SAVE_FILE, "wb")
  7. except Exception:
  8. # TODO : Custom exeption for saving error
  9. raise Exception("Error while saving : data may be unavailable")
  10. if self.save_file == None:
  11. self.save_file = self.init_save()
  12. pickle.dump(self.save_file, f)
  13. f.close()
  14. f = open('/tmp/bidule', 'w')
  15. f.write(json.dumps(self.save_file))
  16. f.close()