Example #1
0
    def read_data_file(self):
        try:
            handler = open(self._data_file)
        except (OSError, IOError):
            # Create default config file if non-existant
            handler = open(self._data_file, 'w+')
            handler.write(utils.serialize(BACKUP_DEFAULT_SETTINGS))
            handler.seek(0)
        finally:
            with handler as f:
                data_file = f.read()

            self._data = utils.deserialize(data_file)
            handler.close()
Example #2
0
    def read_data_file(self):
        try:
            handler = open(self._data_file)
        except (OSError, IOError):
            # Create default config file if non-existant
            handler = open(self._data_file, 'w+')
            handler.write(utils.serialize(BACKUP_DEFAULT_SETTINGS))
            handler.seek(0)
        finally:
            with handler as f:
                data_file = f.read()

            self._data = utils.deserialize(data_file)
            handler.close()
Example #3
0
 def write_data_file(self):
     handler = open(self._data_file, 'w+')
     handler.write(utils.serialize(self._data))
     handler.close()
Example #4
0
 def write_data_file(self):
     handler = open(self._data_file, 'w+')
     handler.write(utils.serialize(self._data))
     handler.close()