self.my_logger = logging.getLogger('autorun.BitTorrentClientRun')
self.my_logger.setLevel(logging.DEBUG)
- def config_run(self, download_dir, output_dir, output_file, log_dir, log_file, port, torrent_file):
+ def config_run(self, download_dir, output_dir,
+ output_file, log_dir, log_file,
+ port, up_limit, down_limit, torrent_file):
+
self.download_dir = download_dir
self.output_dir = output_dir
self.output_file = output_file # output from stdout
self.log_dir = log_dir
self.log_file = log_file # output from stderr
self.port = port
+ self.up_limit = up_limit
+ self.down_limit = down_limit
self.torrent_file = torrent_file
-
+
def start(self):
t = Template(self.simple_run_expr)
self.simple_run_command = t.substitute(
log_dir = self.log_dir,
log_file = self.log_file,
port = str(self.port),
+ up_limit = str(self.up_limit),
+ down_limit = str(self.down_limit),
torrent_file = self.torrent_file
)
log_dir = self.log_dir,
log_file = self.log_file,
port = str(self.port),
+ up_limit = str(self.up_limit),
+ down_limit = str(self.down_limit),
torrent_file = self.torrent_file
)
stderr=log_redirect)
else: #for HRKTORRENT, verbose logs are not redirected
#set lib env variable !!!!hardcodeeeeeeeeeeeed!!!!
- parts = self.base_path.split("/");
+ """parts = self.base_path.split("/");
lib_path = ""
for i in range(0, len(parts)-1):
lib_path = lib_path + parts[i]+"/"
lib_path = lib_path + "libtorrent-rasterbar/lib"
os.environ["LD_LIBRARY_PATH"] = lib_path
+ """
if not os.path.isdir(self.log_dir):
try:
os.makedirs(self.log_dir)
"""
Base class for running libtorrent (hrktorrent) client instances
2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
+ 2010, Adriana Draghici, adriana.draghici@cti.pub.ro
"""
import sys
class HrktorrentRun(BitTorrentClientRun):
def __init__(self, base_path):
+ #!!! Local limits are always on (-l parameter)
BitTorrentClientRun.__init__(self, base_path,
- "$base_path/hrktorrent --downloaddir$download_dir --minport$port --maxport$port $torrent_file &> $output_dir/$output_file",
- "$base_path/hrktorrent --downloaddir$download_dir --minport$port --maxport$port $torrent_file &> $output_dir/$output_file")
+ "$base_path/hrktorrent -o$download_dir -p$port -P$port -d$down_limit -u$up_limit -l $torrent_file &> $output_dir/$output_file",
+ "$base_path/hrktorrent -o$download_dir -p$port -P$port -d$down_limit -u$up_limit -l $torrent_file &> $output_dir/$output_file")
def main():
bt_client_data = {
CLIENT: HRKTORRENT, PORT:10350,
BASE_DIR:"/home/p2p/p2p-clients/hrktorrent-logging/hrktorrent",
- TORRENT: "/home/p2p/export/torrent-files/himym.torrent",
+ TORRENT: "/home/p2p/export/torrent-files/fedora.torrent",
DL_DIR: "/home/p2p/p2p-dld/hrktorrent",
LOG_DIR: "/home/p2p/p2p-log/hrktorrent",
OUT_DIR: "/home/p2p/p2p-log/hrktorrent",
OUT_FILE: "test.out", #status messages
LOG_FILE: "", #verbose messages
-
+ UP_LIMIT:100,
+ DL_LIMIT:300
}
hr = HrktorrentRun("/home/p2p/p2p-clients/hrktorrent-logging/hrktorrent")
hr.config_run(bt_client_data[DL_DIR], bt_client_data[OUT_DIR],
bt_client_data[OUT_FILE], bt_client_data[LOG_DIR],
- bt_client_data[LOG_FILE], bt_client_data[PORT],
+ bt_client_data[LOG_FILE], bt_client_data[PORT],
+ bt_client_data[UP_LIMIT], bt_client_data[DL_LIMIT],
bt_client_data[TORRENT])
hr.start()
hr.run_client(hr.simple_run_command, HRKTORRENT)
"""
Base class for running Transmission client instances
2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
+ 2010, Adriana Draghici, adriana.draghici@cti.pub.ro
"""
import sys
import os.path
from BitTorrentClientRun import BitTorrentClientRun
+from Util import *
DEBUG = False
class TransmissionRun(BitTorrentClientRun):
def __init__(self, base_path):
BitTorrentClientRun.__init__(self, base_path,
- "$base_path/transmissioncli --download-dir $download_dir --port $port $torrent_file >> $output_dir/$output_file",
- "TR_DEBUG=2 $base_path/transmission --download-dir $download_dir --port $port $torrent_file 2>> $log_dir/$log_file >> $output_dir/$output_file")
-
+ "$base_path/transmissioncli -w $download_dir -p $port -u $up_limit -d $down_limit $torrent_file >> $output_dir/$output_file",
+ "TR_DEBUG=2 $base_path/transmissioncli -w $download_dir -p $port -u $up_limit -d $down_limit $torrent_file \
+ 2>> $log_dir/$log_file >> $output_dir/$output_file")
def main():
"""
Test case
"""
-
+ """
tr = TransmissionRun("/home/p2p/p2p-clients/transmission")
- tr.config_run("/home/p2p/p2p-dld/transmission", "/home/p2p/p2p-log/transmission", "transmission-fedora.out", "/home/p2p/p2p-log/transmission", "transmission-fedora.log", 10150, "/home/p2p/p2p-meta/fedora.torrent")
+ tr.config_run("/home/p2p/p2p-dld/transmission",
+ "/home/p2p/p2p-log/transmission",
+ "transmission-opensuse.out",
+ "/home/p2p/p2p-log/transmission",
+ "transmission-opensuse.log",
+ 10150,
+ 200,
+ 300,
+ "/home/p2p/export/torrent-files/opensuse.torrent")
tr.start()
+ """
+ bt_client_data = {
+ CLIENT: TRANSMISSION, PORT:10150,
+ BASE_DIR:"",
+ TORRENT: "/home/p2p/export/torrent-files/opensuse.torrent",
+ DL_DIR: "/home/p2p/p2p-dld/transmission",
+ LOG_DIR: "/home/p2p/p2p-log/transmission",
+ OUT_DIR: "/home/p2p/p2p-log/transmission",
+ OUT_FILE: "test.out", #status messages
+ LOG_FILE: "", #verbose messages
+ UP_LIMIT:100,
+ DL_LIMIT:300
+ }
+ tr = TransmissionRun("/home/p2p/p2p-clients/transmission")
+ tr.config_run(bt_client_data[DL_DIR], bt_client_data[OUT_DIR],
+ bt_client_data[OUT_FILE], bt_client_data[LOG_DIR],
+ bt_client_data[LOG_FILE], bt_client_data[PORT],
+ bt_client_data[UP_LIMIT], bt_client_data[DL_LIMIT],
+ bt_client_data[TORRENT])
+ tr.start()
+ tr.run_client(tr.simple_run_command, HRKTORRENT)
+
if __name__ == "__main__":
sys.exit(main())