def subtest_download(self): """ Now download the file via another Session """ self.config2 = self.config.copy() # not really necess self.config2.set_state_dir(self.getStateDir(2)) self.config2.set_listen_port(self.mylistenport) self.session2 = Session(self.config2, ignore_singleton=True) # Allow session2 to start print >> sys.stderr, "test: downloader: Sleeping 3 secs to let Session2 start" time.sleep(3) tdef2 = TorrentDef.load(self.torrentfn) dscfg2 = DownloadStartupConfig() dscfg2.set_dest_dir(self.getDestDir(2)) dscfg2.set_video_event_callback(self.downloader_vod_ready_callback) d = self.session2.start_download(tdef2, dscfg2) d.set_state_callback(self.downloader_state_callback) time.sleep(40) # To test if BITFIELD is indeed wrapping around. self.subtest_connect2downloader() time.sleep(80)
def subtest_download(self): """ Now download the file via another Session """ self.session2 = Session(self.config2, ignore_singleton=True) self.session2.start() time.sleep(5) tdef2 = TorrentDef.load(self.torrentfn) d = self.session2.start_download(tdef2, self.dscfg2) d.set_state_callback(self.downloader_state_callback) time.sleep(5) d.add_peer(("127.0.0.1", self.hisport)) assert self.downloading_event.wait(60)
def subtest_download(self): """ Now download the file via another Session """ self.config2 = self.config.copy() # not really necess self.config_path2 = tempfile.mkdtemp() self.config2.set_state_dir(self.config_path2) self.config2.set_listen_port(self.mylistenport) self.session2 = Session(self.config2, ignore_singleton=True) # Allow session2 to start print >> sys.stderr, "test: Sleeping 3 secs to let Session2 start" time.sleep(3) tdef2 = TorrentDef.load(self.torrentfn) dscfg2 = DownloadStartupConfig() dscfg2.set_dest_dir(self.config_path2) d = self.session2.start_download(tdef2, dscfg2) d.set_state_callback(self.downloader_state_callback) time.sleep(20)
from Tribler.Core.TorrentDef import * def states_callback(dslist): for ds in dslist: d = ds.get_download() print >> sys.stderr, "bctest 1: Stats", ` d.get_def().get_name( ) `, dlstatus_strings[ds.get_status()], ds.get_progress( ), "%", ds.get_error(), "up", ds.get_current_speed( UPLOAD), "down", ds.get_current_speed( DOWNLOAD), currentThread().getName() return (10.0, False) if __name__ == "__main__": sscfg = SessionStartupConfig() sscfg.set_state_dir('Session1') sscfg.set_overlay(1) sscfg.set_overlay_log('test.log') sscfg.set_superpeer_file('superpeer1.txt') sscfg.set_listen_port(7011) s = Session(sscfg) s.set_download_states_callback(states_callback, getpeerlist=False) tdef = TorrentDef.load('bla.torrent') d = s.start_download(tdef) time.sleep(3600 * 24 * 7)
def setUp(self): """ unittest test setup code """ self.setUpPreSession() self.session = Session(self.config) self.hisport = self.session.get_listen_port() self.setUpPostSession()