def send(self, raises=True): |
""" Sends a sourcedir to all added targets. Flag indicates |
whether to raise an error or return in case of lack of |
targets |
""" |
if not self._channels: |
if raises: |
raise IOError("no targets available, maybe you " |
"are trying call send() twice?") |
return |
|
self._sourcedir = os.path.dirname(os.path.join(self._sourcedir, 'x')) |
|
self._send_directory_structure(self._sourcedir) |
|
|
|
self._paths = {} |
self._to_send = {} |
|
|
while self._channels: |
channel, req = self._receivequeue.get() |
if req is None: |
self._end_of_channel(channel) |
else: |
command, data = req |
if command == "links": |
self._process_link(channel) |
elif command == "done": |
self._done(channel) |
elif command == "ack": |
if self._callback: |
self._callback("ack", self._paths[data], channel) |
elif command == "list_done": |
self._list_done(channel) |
elif command == "send": |
self._send_item(channel, data) |
del data |
else: |
assert "Unknown command %s" % command |