Skip to content

Commit

Permalink
Add name id to distinguish from other similar experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
ardhipoetra committed Nov 14, 2016
1 parent 7bb5b01 commit d0bcc48
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion experiments/tribler/channel_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def __init__(self, *argv, **kwargs):

self.num_peers = -1

self.id_experiment = os.environ['EXPERIMENT_NAME'].replace(" ", "")

def start_session(self):
super(ChannelDownloadClient, self).start_session()
self.session_deferred.addCallback(self.__config_dispersy)
Expand Down Expand Up @@ -210,6 +212,7 @@ def __ds_active_callback(self, ds):
return 1.0, True

def setup_seeder(self, filename, size):
filename = self.id_experiment + "_" + filename
try:
tdef = TorrentDef.load(path.join(self.upload_dir_path, "%s.torrent" % filename))
except IOError:
Expand All @@ -228,7 +231,7 @@ def setup_seeder(self, filename, size):

def publish(self, filename, size):
if self.my_channel or self.joined_community:
tdef = self._create_test_torrent(filename, size)
tdef = self._create_test_torrent(self.id_experiment + "_" + filename, size)
if self.my_channel:
self.my_channel._disp_create_torrent_from_torrentdef(tdef, int(time.time()))
elif self.joined_community:
Expand Down Expand Up @@ -257,6 +260,7 @@ def _create_test_torrent(self, filename='', size=0):
return tdef

def start_download(self, name):
name = name if name.startswith(self.id_experiment) else self.id_experiment + "_" + name
if name not in self.dl_lc.keys():
self.dl_lc[name] = LoopingCall(self.start_download, name)
self.dl_lc[name].start(1.0, now=False)
Expand Down

0 comments on commit d0bcc48

Please sign in to comment.