From 147962baf80823f1a51a6a4077a48241f8dc8f20 Mon Sep 17 00:00:00 2001 From: Ardhi Putra Pratama H Date: Mon, 14 Nov 2016 16:17:22 +0100 Subject: [PATCH] Add name id to distinguish from other similar experiment --- experiments/tribler/channel_download.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/experiments/tribler/channel_download.py b/experiments/tribler/channel_download.py index 96faf2aa6..17fe6ec0c 100755 --- a/experiments/tribler/channel_download.py +++ b/experiments/tribler/channel_download.py @@ -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) @@ -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: @@ -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: @@ -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)