start client Python scripts; base class and Transmission
authorp2p <p2p@p2p-next-01-01.(none)>
Fri, 29 Jan 2010 08:47:02 +0000 (08:47 +0000)
committerp2p <p2p@p2p-next-01-01.(none)>
Fri, 29 Jan 2010 08:47:02 +0000 (08:47 +0000)
scripts/start-clients/BitTorrentClientRun.py [new file with mode: 0644]
scripts/start-clients/TransmissionRun.py [new file with mode: 0644]
scripts/start-clients/aria-start [new file with mode: 0644]
scripts/start-clients/azureus-start [new file with mode: 0644]
scripts/start-clients/hrktorrent-start [new file with mode: 0644]
scripts/start-clients/mainline-start [new file with mode: 0644]
scripts/start-clients/transmission-start [new file with mode: 0644]
scripts/start-clients/tribler-start [new file with mode: 0644]

diff --git a/scripts/start-clients/BitTorrentClientRun.py b/scripts/start-clients/BitTorrentClientRun.py
new file mode 100644 (file)
index 0000000..eca5bde
--- /dev/null
@@ -0,0 +1,120 @@
+#!/usr/bin/env python
+
+"""
+ Base class for running BitTorrent client instances
+ 2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
+"""
+
+"""
+    <client id="transmission">
+       <run type="executable">
+           <file>src/transmission-cli</file>
+           <interpreter></interpreter>
+           <prefix></prefix>
+           <suffix></suffix>
+       </run>
+       <upload_limit_option>-u</upload_limit_option>
+       <download_limit_option>-d</download_limit_option>
+       <port_option>-p</port_option>
+       <logging_dir_option>-l</logging_dir_option>
+       <download_dir_option>-o</download_dir_option>
+    </client>
+"""
+
+"""
+    <node id="1">
+       <public_address>141.85.224.201</public_address>
+       <public_port>10150</public_port>
+       <private_address>172.30.10.0</private_address>
+       <private_port>10150</private_port>
+       <ssh_port>10122</ssh_port>
+       <clients>
+           <client id="tribler">
+               <base>/home/p2p/p2p-clients/tribler/</base>
+           </client>
+           <client id="libtorrent">
+               <base>/home/p2p/p2p-clients/libtorrent/</base>
+           </client>
+           <client id="transmission">
+               <base>/home/p2p/p2p-clients/transmission/</base>
+           </client>
+        </clients>
+    </node>
+"""
+
+"""
+    <instance id="1">
+       <node>1</node>
+       <client>triber</client>
+       <upload_limit>512</upload_limit>
+       <download_limit>256</download_limit>
+       <port>9999</port>
+       <download_dir>/this/dir</download_dir>
+       <logging_dir>/this/dir</logging_dir>
+       <actions>
+           <action type="start" delay="00:05:00" />
+           <action type="stop" delay="00:10:00" />
+           <action type="start" delay="00:15:00" />
+           <action type="stop" delay="00:20:00" />
+           <action type="start" delay="00:25:00" />
+           <action type="start" delay="end" />
+       </actions>
+    </instance>
+"""
+
+import sys
+import os.path
+
+DEBUG = False
+
+class BitTorrentClientRun:
+       def __init__(self, base_path):
+               self.base_path = base_path
+               pass
+
+       def config_client(self, simple_run_expr, logging_run_expr):
+               self.simple_run_expr = simple_run_expr
+               self.logging_run_expr = logging_run_expr
+
+       def config_client2(self, prefix, suffix, file, run_type,
+                       interpreter, download_dir_option,
+                       logging_dir_option, port_option):
+               self.prefix = prefix
+               self.suffix = suffix
+               self.file = file
+               self.run_type = run_type
+               self.interpreter = interpreter
+               self.download_dir_option = download_dir_option
+               self.logging_dir_option = logging_dir_option
+               self.port_option = port_option
+
+       def config_run(self, download_dir, logging_dir, port):
+               self.download_dir = download_dir
+               self.logging_dir = logging_dir
+               self.port = port
+
+       def start2(self):
+               self.command = "%s %s %s/%s %s %s %s %s %s %d %s" % (self.prefix, self.interpreter, self.base_path, self.file, self.download_dir_option, self.download_dir, self.logging_dir_option, self.logging_dir, self.port_option, self.port, self.suffix)
+               print self.command
+
+       def start(self):
+               self.simple_run_command = self.simple_run_expr.replace("$base_pat", self.base_path).replace("$download_dir", self.download_dir).replace("$logging_dir", self.logging).replace("$port", self.port)
+               self.logging_run_command = self.logging_run_expr.replace("$base_pat", self.base_path).replace("$download_dir", self.download_dir).replace("$logging", self.logging).replace("$port", self.port)
+
+               print self.simple_run_command
+               print self.logging_run_command
+
+def main():
+
+    """
+    Test case
+    """
+
+    btcr = BitTorrentClientRun("/home/p2p/p2p-clients/transmission/")
+    btcr.config_client("", "", "cli/transmissioncli", "executable", "", "--download-dir", "", "--port")
+    btcr.config_run("/home/p2p/p2p-dld/transmission/", "/home/p2p/p2p-log/transmission/", 10150)
+    btcr.start()
+
+
+if __name__ == "__main__":
+    sys.exit(main())
diff --git a/scripts/start-clients/TransmissionRun.py b/scripts/start-clients/TransmissionRun.py
new file mode 100644 (file)
index 0000000..fb389e8
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+"""
+ Base class for running Transmission client instances
+ 2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
+"""
+
+import sys
+import os.path
+import BitTorrentClientRun
+
+DEBUG = False
+
+class TransmissionRun(BitTorrentClientRun):
+       def __init__(self, base_path):
+               self.base_path = base_path
+               simple_run_expr = "$base_path/cli/transmissioncli --download-dir $download_dir --port $port $torrent_file > $output_dir/$out_file"
+               logging_run_expr = "TR_DEBUG=2 $base_path/cli/transmissioncli --download-dir $download_dir --port $port $torrent_file 2> $logging_dir/$log_file > $output_dir/$out_file"
+               BitTorrentClientRun.config_client(simple_run_expr, logging_run_expr)
+
+
+def main():
+
+    """
+    Test case
+    """
+
+    tr = TransmissionRun("/home/p2p/p2p-clients/transmission/")
+    tr.config_run("/home/p2p/p2p-dld/transmission/", "/home/p2p/p2p-log/transmission/", 10150)
+    tr.start()
+
+
+if __name__ == "__main__":
+    sys.exit(main())
diff --git a/scripts/start-clients/aria-start b/scripts/start-clients/aria-start
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/scripts/start-clients/azureus-start b/scripts/start-clients/azureus-start
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/scripts/start-clients/hrktorrent-start b/scripts/start-clients/hrktorrent-start
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/scripts/start-clients/mainline-start b/scripts/start-clients/mainline-start
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/scripts/start-clients/transmission-start b/scripts/start-clients/transmission-start
new file mode 100644 (file)
index 0000000..af2e4ba
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+ID=transmission
+FILE=src/transmission-cli
+RUN_TYPE=executable
+
diff --git a/scripts/start-clients/tribler-start b/scripts/start-clients/tribler-start
new file mode 100644 (file)
index 0000000..e69de29