Пример #1
0
def main():
    command_line_parser = optparse.OptionParser()
    command_line_parser.add_option("--statedir",
                                   action="store",
                                   type="string",
                                   help="Use an alternate statedir")
    command_line_parser.add_option("--port",
                                   action="store",
                                   type="int",
                                   help="Listen at this port")
    command_line_parser.add_option("--dispersy-port",
                                   action="store",
                                   type="int",
                                   help="Dispersy uses this UDL port",
                                   default=6421)
    command_line_parser.add_option("--nickname",
                                   action="store",
                                   type="string",
                                   help="The moderator name",
                                   default="Booster")

    # parse command-line arguments
    opt, args = command_line_parser.parse_args()

    if not opt.statedir:
        command_line_parser.print_help()
        print "\nExample: python", sys.argv[
            0], "--statedir /home/tribler/booster --nickname Booster"
        sys.exit()

    print "Press Ctrl-C to stop the booster"

    sscfg = SessionStartupConfig()
    if opt.statedir:
        sscfg.set_state_dir(os.path.realpath(opt.statedir))
    if opt.port:
        sscfg.set_listen_port(opt.port)
    if opt.dispersy_port:
        sscfg.set_dispersy_port(opt.dispersy_port)
    if opt.nickname:
        sscfg.set_nickname(opt.nickname)

    sscfg.set_megacache(True)
    sscfg.set_overlay(True)
    # turn torrent collecting on. this will cause torrents to be distributed
    sscfg.set_torrent_collecting(True)
    sscfg.set_dialback(False)
    sscfg.set_internal_tracker(False)

    session = Session(sscfg)

    # KeyboardInterrupt
    try:
        while True:
            sys.stdin.read()
    except:
        print_exc()

    session.shutdown()
    print "Shutting down..."
    time.sleep(5)
def main():
    sscfg = SessionStartupConfig()
    sscfg.set_state_dir(unicode(os.path.realpath("/tmp")))
    sscfg.set_dispersy_port(6421)
    sscfg.set_nickname("dispersy")

    # The only modules needed by dispersy and DHT.
    sscfg.set_dispersy(True)
    sscfg.set_megacache(True)

    # Disable all other tribler modules.
    sscfg.set_swift_proc(False)
    sscfg.set_buddycast(False)
    sscfg.set_social_networking(False)
    sscfg.set_remote_query(False)
    sscfg.set_bartercast(False)
    sscfg.set_overlay(False)
    sscfg.set_torrent_collecting(False)
    sscfg.set_dialback(False)
    sscfg.set_internal_tracker(False)

    # Create the session and wait for it to be created.
    session = Session(sscfg)
    time.sleep(5)

    # Create the dispersy instance and make it accessible out of the main().
    dispersy.append(Dispersy.has_instance())

    # Create the NetworkBuzzDBHandler that should be made in the tribler GUI.
    NetworkBuzzDBHandler.getInstance()

    #def on_torrent(messages):
    #pass

    # Find the search community from the dispersy instance.
    def findSearchCommunity():
        for community in dispersy[0].get_communities():
            if isinstance(community, SearchCommunity):
                 search_community.append(community)
                 #searchCommunity.on_torrent = on_torrent
                 break

    # Let the dispersy thread find the search community.
    # MUST be called on the dispersy thread.
    dispersy[0].callback.register(findSearchCommunity)

    # Any search request before this point will create a segfault!
    print >> sys.stderr, "Ready to search!"

    # Keep the main function spinning to keep the session alive and dispersy and DHT running.
    try:
        while True:
            sys.stdin.read()
    except:
        print_exc()

    # Shutdown everything.
    session.shutdown()
    print "Shutting down..."
    time.sleep(5)
Пример #3
0
def main():
    command_line_parser = optparse.OptionParser()
    command_line_parser.add_option("--statedir", action="store", type="string", help="Use an alternate statedir")
    command_line_parser.add_option("--port", action="store", type="int", help="Listen at this port")
    command_line_parser.add_option("--dispersy-port", action="store", type="int", help="Dispersy uses this UDL port", default=6421)
    command_line_parser.add_option("--nickname", action="store", type="string", help="The moderator name", default="Booster")

    # parse command-line arguments
    opt, args = command_line_parser.parse_args()

    if not opt.statedir:
        command_line_parser.print_help()
        print "\nExample: python", sys.argv[0], "--statedir /home/tribler/booster --nickname Booster"
        sys.exit()

    print "Press Ctrl-C to stop the booster"

    sscfg = SessionStartupConfig()
    if opt.statedir: sscfg.set_state_dir(os.path.realpath(opt.statedir))
    if opt.port: sscfg.set_listen_port(opt.port)
    if opt.dispersy_port: sscfg.set_dispersy_port(opt.dispersy_port)
    if opt.nickname: sscfg.set_nickname(opt.nickname)

    sscfg.set_megacache(True)
    sscfg.set_overlay(True)
    # turn torrent collecting on. this will cause torrents to be distributed
    sscfg.set_torrent_collecting(True)
    sscfg.set_dialback(False)
    sscfg.set_internal_tracker(False)

    session = Session(sscfg)

    # KeyboardInterrupt
    try:
        while True:
            sys.stdin.read()
    except:
        print_exc()

    session.shutdown()
    print "Shutting down..."
    time.sleep(5)
Пример #4
0
def main():
    sscfg = SessionStartupConfig()
    sscfg.set_state_dir(unicode(os.path.realpath("/tmp")))
    sscfg.set_dispersy_port(6421)
    sscfg.set_nickname("dispersy")

    # The only modules needed by dispersy and DHT.
    sscfg.set_dispersy(True)
    sscfg.set_megacache(True)

    # Disable all other tribler modules.
    sscfg.set_swift_proc(False)
    sscfg.set_buddycast(False)
    sscfg.set_social_networking(False)
    sscfg.set_remote_query(False)
    sscfg.set_bartercast(False)
    sscfg.set_overlay(False)
    sscfg.set_torrent_collecting(False)
    sscfg.set_dialback(False)
    sscfg.set_internal_tracker(False)

    # Create the session and wait for it to be created.
    session = Session(sscfg)
    time.sleep(5)

    # Create the dispersy instance and make it accessible out of the main().
    dispersy.append(Dispersy.has_instance())

    # Create the NetworkBuzzDBHandler that should be made in the tribler GUI.
    NetworkBuzzDBHandler.getInstance()

    #    def on_torrent(messages):
    #        pass

    # Find the search community from the dispersy instance.
    def findSearchCommunity():
        for community in dispersy[0].get_communities():
            if isinstance(community, SearchCommunity):
                search_community.append(community)
                #                 searchCommunity.on_torrent = on_torrent
                break

    # Let the dispersy thread find the search community.
    # MUST be called on the dispersy thread.
    dispersy[0].callback.register(findSearchCommunity)

    # Any search request before this point will create a segfault!
    # TODO: Disable searching on C++ side before this happens.
    print >> sys.stderr, "Ready to search!"

    # Keep the main function spinning to keep the session alive and dispersy and DHT running.
    try:
        while True:
            sys.stdin.read()
    except:
        print_exc()

    # Shutdown everything.
    session.shutdown()
    print "Shutting down..."
    time.sleep(5)