def _process_limbo(self): """Process the FSM limbos and send corresponding AQ orders.""" log_info("processing trash") trash_log = "share_id=%r parent_id=%r node_id=%r path=%r" for share_id, node_id, parent_id, path, is_dir in \ self.fsm.get_iter_trash(): datalog = trash_log % (share_id, parent_id, node_id, path) if IMarker.providedBy(node_id) or IMarker.providedBy(parent_id): # situation where the node is not in the server log_info("removing from trash: " + datalog) self.fsm.remove_from_trash(share_id, node_id) continue log_info("generating Unlink from trash: " + datalog) self.aq.unlink(share_id, parent_id, node_id, path, is_dir) log_info("processing move limbo") move_log = ("share_id=%r node_id=%r old_parent_id=%r " "new_parent_id=%r new_name=%r path_from=%r path_to=%r") for data in self.fsm.get_iter_move_limbo(): to_log = move_log % data (share_id, node_id, old_parent_id, new_parent_id, new_name, path_from, path_to) = data maybe_markers = (share_id, node_id, old_parent_id, new_parent_id) if any(IMarker.providedBy(x) for x in maybe_markers): # situation where the move was not ready log_info("removing from move limbo: " + to_log) self.fsm.remove_from_move_limbo(share_id, node_id) continue log_info("generating Move from limbo: " + to_log) self.aq.move(share_id, node_id, old_parent_id, new_parent_id, new_name, path_from, path_to)
def sanitize_dict(data): """Sanitize *IN PLACE* a dict values to go through IPC.""" for k, v in data.items(): if IMarker.providedBy(v): # this goes first, as it also is instance of basestring data[k] = repr(v) elif isinstance(v, basestring): pass # to avoid str() to already strings elif isinstance(v, bool): data[k] = bool_str(v) elif v is None: data[k] = 'None' else: data[k] = str(v)
def test_serialization_markers(self): """Check that it can store markers.""" marker = MDMarker("foo") self.oq.push(marker) retrieved = self.oq.pop() self.assertTrue(IMarker.providedBy(retrieved))