Пример #1
0
    if not os.access(options.directory, os.F_OK):
            os.makedirs(options.directory)

    dscfg = DownloadStartupConfig()
    dscfg.set_dest_dir(options.directory)
    global my_dir
    my_dir = options.directory
    dscfg.set_video_events([simpledefs.VODEVENT_START,
                            simpledefs.VODEVENT_PAUSE,
                            simpledefs.VODEVENT_RESUME])
    dscfg.set_video_event_callback(vod_event_callback)
    dscfg.set_max_speed(simpledefs.DOWNLOAD, options.dlrate)
    dscfg.set_max_speed(simpledefs.UPLOAD, options.ulrate)

    if dscfg.get_mode() == simpledefs.DLMODE_VOD:
        print >>sys.stderr, 'Client runs in streaming mode'
    
    d = s.start_download(tdef, dscfg)
    
    d.set_state_callback(state_event_callback)

    time.sleep(1)

    communicator = TrackerCommunicator(tracker_url, options.port, d.sd.peerid)
    #communicator.send_registration()

    try:
        while True:
            time.sleep(5)
    except KeyboardInterrupt:
Пример #2
0
    if not os.access(options.directory, os.F_OK):
        os.makedirs(options.directory)

    dscfg = DownloadStartupConfig()
    dscfg.set_dest_dir(options.directory)
    global my_dir
    my_dir = options.directory
    dscfg.set_video_events([
        simpledefs.VODEVENT_START, simpledefs.VODEVENT_PAUSE,
        simpledefs.VODEVENT_RESUME
    ])
    dscfg.set_video_event_callback(vod_event_callback)
    dscfg.set_max_speed(simpledefs.DOWNLOAD, options.dlrate)
    dscfg.set_max_speed(simpledefs.UPLOAD, options.ulrate)

    if dscfg.get_mode() == simpledefs.DLMODE_VOD:
        print >> sys.stderr, 'Client runs in streaming mode'

    d = s.start_download(tdef, dscfg)

    d.set_state_callback(state_event_callback)

    time.sleep(1)

    communicator = TrackerCommunicator(tracker_url, options.port, d.sd.peerid)
    #communicator.send_registration()

    try:
        while True:
            time.sleep(5)
    except KeyboardInterrupt: