def SaveData(self, raw_data): logging.info("Writing back configuration to key %s.", self._key_spec) # Ensure intermediate directories exist. try: for key, value in iteritems(raw_data): winreg.SetValueEx(self._AccessRootKey(), key, 0, winreg.REG_SZ, utils.SmartStr(value)) finally: # Make sure changes hit the disk. winreg.FlushKey(self._AccessRootKey())
def SaveData(self, raw_data): logging.info("Writing back configuration to key %s.", self._key_spec) # Ensure intermediate directories exist. try: for key, value in iteritems(raw_data): # TODO(user): refactor regconfig. At the moment it has no idea # what kind of data it's serializing and simply stringifies, them # assuming that bytes are simply ascii-encoded strings. Note that # lists (Client.tempdir_roots) also get stringified and can't # really be deserialized, since RegistryConfigParser doesn't # support deserializing anything but strings. if isinstance(value, bytes): str_value = value.decode("ascii") else: str_value = str(value) winreg.SetValueEx(self._AccessRootKey(), key, 0, winreg.REG_SZ, str_value) finally: # Make sure changes hit the disk. winreg.FlushKey(self._AccessRootKey())
def Sync(self): if not self._synced: winreg.FlushKey(_GetServiceKey()) self._synced = True