def store_and_forward(self): self._read_header() header = self.json_header requests_a = header['requests'] self._open_dest_files(requests_a) destinations = header['destinations'] self._get_valid_vcons(destinations) self._process_io() # close all open files self._close_files() # read the footer from the sending machine self._read_footer() # send foot to all machines this is streaming to self._send_footer() # wait for eof and close self._close_connections() self._rename_files(requests_a) pylantorrent.log(logging.DEBUG, "All data sent %s %d" % (self.md5str, len(requests_a))) # if we got to here it was successfully written to a file # and we can call it success. Print out a success message for # everyfile written vex = LTException(0, "Success", header['host'], int(header['port']), requests_a, md5sum=self.md5str) s = vex.get_printable() self.print_results(s) self.clean_up()
def store_and_forward(self): self._read_header() header = self.json_header requests_a = header['requests'] self._open_dest_files(requests_a) destinations = header['destinations'] self._get_valid_vcons(destinations) self._process_io() # close all open files self._close_files() # read the footer from the sending machine self._read_footer() # send foot to all machines this is streaming to self._send_footer() # wait for eof and close self._close_connections() self._rename_files(requests_a) pylantorrent.log( logging.DEBUG, "All data sent %s %d" % (self.md5str, len(requests_a))) # if we got to here it was successfully written to a file # and we can call it success. Print out a success message for # everyfile written vex = LTException(0, "Success", header['host'], int(header['port']), requests_a, md5sum=self.md5str) s = vex.get_printable() self.print_results(s) self.clean_up()
pylantorrent.log(logging.INFO, "server starting") rc = 1 v = LTServer(sys.stdin, sys.stdout) try: v.store_and_forward() rc = 0 except LTException, ve: pylantorrent.log(logging.ERROR, "error %s" % (str(ve)), traceback) s = ve.get_printable() v.print_results(s) v.clean_up() except Exception, ex: pylantorrent.log(logging.ERROR, "error %s" % (str(ex)), traceback) vex = LTException(500, str(ex)) s = vex.get_printable() v.print_results(s) v.clean_up() return rc if __name__ == "__main__": if 'LANTORRENT_HOME' not in os.environ: msg = "The env LANTORRENT_HOME must be set" print msg raise Exception(msg) rc = main() sys.exit(rc)