parser = optparse.OptionParser(usage="Usage: " + sys.argv[0] + " [options]")
    parser.add_option("-d", "--directory", dest="directory", default="vodclient")
    parser.add_option("-p", "--port", type="int", dest="port", default=5000)
    parser.add_option("-t", "--torrent", dest="torrent", default=None)
    parser.add_option("-x", "--dlrate", type="int", dest="dlrate", default=128)
    parser.add_option("-y", "--ulrate", type="int", dest="ulrate", default=128)
    parser.add_option("-l", "--logfile", dest="logfile", default=None)

    (options, args) = parser.parse_args()

    print >>sys.stderr, "download rate is: %i" % options.dlrate
    
    __TORRENT_FILE__ = options.torrent
    __LOGFILE__ = options.logfile or 'vodclient.log'

    scfg = SessionStartupConfig()
    scfg.set_state_dir(tempfile.mkdtemp())
    scfg.set_listen_port(options.port)
    scfg.set_overlay(False)
    scfg.set_megacache(False)
    scfg.set_upnp_mode(simpledefs.UPNPMODE_DISABLED)
    scfg.set_dialback(False)
    scfg.set_social_networking(False)
    scfg.set_buddycast(False)
    scfg.set_crawler(False)
    scfg.set_internal_tracker(False)

    s = Session(scfg)

    tdef = TorrentDef.load(__TORRENT_FILE__)
# tdef.get_tracker() returns the announce-url; we must omit the "announce" part
示例#2
0
    def init_session(self):
        scfg = SessionStartupConfig()
        scfg.set_state_dir(tempfile.mkdtemp())
        scfg.set_listen_port(self._port)
        scfg.set_overlay(False)
        scfg.set_megacache(False)
        scfg.set_upnp_mode(simpledefs.UPNPMODE_DISABLED)
        scfg.set_dialback(False)
        scfg.set_social_networking(False)
        scfg.set_buddycast(False)
        scfg.set_crawler(False)
        scfg.set_internal_tracker(False)

        self._session = Session(scfg)
 def init_session(self):
     scfg = SessionStartupConfig()
     scfg.set_state_dir(tempfile.mkdtemp())
     scfg.set_listen_port(self._port)
     scfg.set_overlay(False)
     scfg.set_megacache(False)
     scfg.set_upnp_mode(simpledefs.UPNPMODE_DISABLED)
     scfg.set_dialback(False)
     scfg.set_social_networking(False)
     scfg.set_buddycast(False)
     scfg.set_crawler(False)
     scfg.set_internal_tracker(False)
     
     self._session = Session(scfg)