X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?p=living-lab-site.git;a=blobdiff_plain;f=cis%2Fbt.py;fp=cis%2Fbt.py;h=928187637d430a53b70a156c55004ea7480d984c;hp=2184fa5d279fd8f37b9c8e04f66700068f8c7504;hb=e487ab3d510e231706a1c0973973496beb25d2ff;hpb=007060953ce46eb7da637ee5fb6eb44c5812d74f diff --git a/cis/bt.py b/cis/bt.py index 2184fa5..9281876 100644 --- a/cis/bt.py +++ b/cis/bt.py @@ -4,6 +4,7 @@ from BaseLib.Core.API import * import tempfile import random import config +import logger def create_torrent(source): """ @@ -58,7 +59,7 @@ class BitTorrent: # setup and start download dscfg = DownloadStartupConfig() - dscfg.set_dest_dir(output_dir); + dscfg.set_dest_dir(output_dir) if torrent.startswith("http") or torrent.startswith(P2PURL_SCHEME): tdef = TorrentDef.load_from_url(torrent) @@ -66,6 +67,16 @@ class BitTorrent: tdef = TorrentDef.load(torrent) if tdef.get_live(): raise ValueError("CIS does not support live torrents") - - d = self.session.start_download(tdef, dscfg) + + new_download = True + try: + d = self.session.start_download(tdef, dscfg) + except DuplicateDownloadException: + new_download = False #d.set_state_callback(state_callback, getpeerlist=False) + + if new_download: + logger.log_msg('download of torrent "%s" started' % torrent) + #else: + #logger.log_msg('download of torrent "%s" already started' \ + #% torrent, logger.LOG_LEVEL_DEBUG)