Esempio n. 1
0
 def set(self, key, value):
     if READONLY:
         raise RuntimeError("Registry set readonly")
     pathname = self.get_filepath(key)
     tempfile = pathname+".tmp"
     with open(tempfile, 'wb') as f:
         #f.write(labrad.types.reprLRData(value))
         f.write(delphi_compat.data_to_string(value)+'\r\n')
         f.flush()
         os.fsync(f.fileno())
     if os.name != 'posix': # Windows doesn't get atomic renames.  Sad.
         os.remove(pathname)
     os.rename(tempfile, pathname)
     self.do_callbacks(key, False, True)
 def data_to_string(self, c, data):
     '''
     Returns an unambiguous string representation of the data sent to it
     '''
     return delphi_compat.data_to_string(data)