Exemple #1
0
 def __init__(self, config, doneflag, errorfunc, listen_fail_ok=False):
     self.dht = None
     self.config = config
     self.errorfunc = errorfunc
     self.rawserver = RawServer(doneflag, config, errorfunc=errorfunc,
                                tos=config['peer_socket_tos'])
     set_zurllib_rawserver(self.rawserver)
     add_unsafe_thread()
     self.nattraverser = NatTraverser(self.rawserver, logfunc=errorfunc)
     self.singleport_listener = SingleportListener(self.rawserver,
                                                   self.nattraverser)
     self.ratelimiter = RateLimiter(self.rawserver.add_task)
     self.ratelimiter.set_parameters(config['max_upload_rate'],
                                     config['upload_unit_size'])
     self._find_port(listen_fail_ok)
     self.filepool = FilePool(config['max_files_open'])
     set_filesystem_encoding(config['filesystem_encoding'],
                                              errorfunc)
    def run(self, ui, ui_wrap, startflag):
        zurllib.add_unsafe_thread()
        self.rawserver.associate_thread()
        startflag.set()

        try:
            self.ui = ui
            self.run_ui_task = ui_wrap
            self.multitorrent = Multitorrent(self.config, self.doneflag,
                                             self.rawserver, self.global_error,
                                             listen_fail_ok=True)

            #upload_like_crazy.init(self.rawserver)
            #self.rawserver.add_task(0, upload_like_crazy.queue_connections)
            #def get_rates():
            #    rate, delivered = upload_like_crazy.measure.get_last_rate()
            #    return rate, 0
            self.bwm = BandwidthManager(external_add_task=self.rawserver.external_add_task,
                                        config=self.config,
                                        set_config=self.set_config,
                                        get_remote_endpoints=self.rawserver.get_remote_endpoints,
                                        get_rates=self._get_total_rates)
                                        #get_rates=get_rates)


            self.ipc.start(self.external_command)
            #qb = QueueButler(self.rawserver, self)
            #qb.update()
            try:
                self._restore_state()
            except BTFailure, e:
                self.torrents = {}
                self.running_torrents = []
                self.queue = []
                self.other_torrents = []
                self.global_error(ERROR, _("Could not load saved state: ")+str(e))
            else:
Exemple #3
0
            psyco.bind(RawServer.listen_forever)
            from BTL import sparse_set
            psyco.bind(sparse_set.SparseSet)
            from BitTorrent import PiecePicker
            psyco.bind(PiecePicker.PieceBuckets)
            psyco.bind(PiecePicker.PiecePicker)
            from BitTorrent import PieceSetBuckets
            psyco.bind(PieceSetBuckets.PieceSetBuckets)
            psyco.bind(PieceSetBuckets.SortedPieceBuckets)
            psyco.profile(memorymax=30000) # that's 30MB for the whole process
            #psyco.log()
            # see below for more
    except ImportError:
        pass

    zurllib.add_unsafe_thread()

    try:
        config, args = configfile.parse_configuration_and_args(defaults,
                                        'bittorrent', sys.argv[1:], 0, None)
        if debug:
            config['upnp'] = False
            config['one_connection_per_ip'] = False

    except BTFailure, e:
        print unicode(e.args[0])
        sys.exit(1)

    config = Preferences().initWithDict(config)
    # bug set in DownloadInfoFrame
Exemple #4
0
            psyco.bind(RawServer.listen_forever)
            from BTL import sparse_set
            psyco.bind(sparse_set.SparseSet)
            from BitTorrent import PiecePicker
            psyco.bind(PiecePicker.PieceBuckets)
            psyco.bind(PiecePicker.PiecePicker)
            from BitTorrent import PieceSetBuckets
            psyco.bind(PieceSetBuckets.PieceSetBuckets)
            psyco.bind(PieceSetBuckets.SortedPieceBuckets)
            psyco.profile(memorymax=30000)  # that's 30MB for the whole process
            #psyco.log()
            # see below for more
    except ImportError:
        pass

    zurllib.add_unsafe_thread()

    try:
        config, args = configfile.parse_configuration_and_args(
            defaults, 'bittorrent', sys.argv[1:], 0, None)
        if debug:
            config['upnp'] = False
            config['one_connection_per_ip'] = False

    except BTFailure, e:
        print unicode(e.args[0])
        sys.exit(1)

    config = Preferences().initWithDict(config)
    # bug set in DownloadInfoFrame