From: Razvan Deaconescu Date: Wed, 28 Oct 2009 06:45:21 +0000 (+0200) Subject: fixed some argument parsing bugs; updated README with session target examples X-Git-Tag: getopt_long~292^2~3 X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=5401ed47857d8cdf69e0720c653b576ec2bc4231;p=cs-p2p-next.git fixed some argument parsing bugs; updated README with session target examples --- diff --git a/auto/db/DatabaseCommander.py b/auto/db/DatabaseCommander.py index ba41805..372b67c 100644 --- a/auto/db/DatabaseCommander.py +++ b/auto/db/DatabaseCommander.py @@ -3,7 +3,7 @@ import sys import getopt import sqlite3 -import julian +from julian import datetimeToJulian from DatabaseAccess import DatabaseAccess class DatabaseCommander: @@ -15,11 +15,11 @@ class DatabaseCommander: def add_swarm(self, torrent_file, filesize, purpose, source): self.dba.insert_swarms(torrent_file, filesize, purpose, source); - def add_client_session(swarm_id, client_name, system_os, + def add_client_session(self, swarm_id, client_name, system_os, system_os_version, system_ram, system_cpu, public_ip, public_port, ds_limit, us_limit, start_time): - client_id = dba.select_btclient_id_by_name(client_name) - self.dba.insert_client_sessions(self, swarm_id, client_id, + client_id = self.dba.select_btclient_id_by_name(client_name) + self.dba.insert_client_sessions(swarm_id, client_id, system_os, system_os_version, system_ram, system_cpu, public_ip, public_port, ds_limit, us_limit, start_time) @@ -122,7 +122,7 @@ def main(): assert False, "unhandled option" if len(args) != 1: - print "Error: incorrect arguments." + print "Error: no database file passed as argument." sys.exit(2) database = args[0] @@ -191,7 +191,7 @@ def main(): system_os = sys.stdin.readline().strip() print "OS version (2.6.28, 7, 10.6): ", os_version = sys.stdin.readline().strip() - print "system RAM (in bytes): ", + print "system RAM (in MB): ", ram = sys.stdin.readline().strip() print "system CPU (in KHz): ", cpu = sys.stdin.readline().strip() @@ -199,13 +199,13 @@ def main(): ip = sys.stdin.readline().strip() print "public port: ", port = sys.stdin.readline().strip() - print "download speed limit: ", + print "download speed limit (in KB/s): ", ds_limit = sys.stdin.readline().strip() - print "upload speed limit: ", + print "upload speed limit (in KB/s): ", us_limit = sys.stdin.readline().strip() print "start time (YYYY-MM-DD HH:MM:SS): ", start_time = sys.stdin.readline().strip().split(' ') - jd = datetimeToJulian(start_time[0], start_time[1]); + jd = float(datetimeToJulian(start_time[0], start_time[1])); dbc.add_client_session(swarm_id, client_name, system_os, os_version, ram, cpu, ip, port, ds_limit, us_limit, jd) diff --git a/auto/db/README b/auto/db/README index 26379ee..3455ea0 100644 --- a/auto/db/README +++ b/auto/db/README @@ -7,6 +7,10 @@ deleting and showing entries in the swarms and client_sessions table. The database has to be created using the db_init script and has to be used as a final argument to the command line program. +If swarm/session id -1 all swarms are deleted/shown. + +If action is "add", standard input is used for reading required arguments. + DatabaseCommander.py calls DatabaseAccess.py. A sample run is shown below: @@ -22,12 +26,34 @@ razvan@valhalla:~/projects/p2p-next/cs-p2p-next/auto/db$ python DatabaseCommande (5, u'Fedora', 1024, u'experiment', u'local') (6, u'Pulp Fiction', 102400, u'streaming', u'isohunt') (7, u'TestSwarm', 12345678, u'test', u'local') + razvan@valhalla:~/projects/p2p-next/cs-p2p-next/auto/db$ python DatabaseCommander.py --list swarm --id 1 p2p-next.db + razvan@valhalla:~/projects/p2p-next/cs-p2p-next/auto/db$ python DatabaseCommander.py --list swarm --id 7 p2p-next.db (7, u'TestSwarm', 12345678, u'test', u'local') + razvan@valhalla:~/projects/p2p-next/cs-p2p-next/auto/db$ python DatabaseCommander.py --delete swarm --id 7 p2p-next.db + razvan@valhalla:~/projects/p2p-next/cs-p2p-next/auto/db$ python DatabaseCommander.py --list swarm --id 7 p2p-next.db + razvan@valhalla:~/projects/p2p-next/cs-p2p-next/auto/db$ python DatabaseCommander.py --list swarm --id -1 p2p-next.db (4, u'DarkKnight', 123000, u'experiment', u'TVTorrents') (5, u'Fedora', 1024, u'experiment', u'local') (6, u'Pulp Fiction', 102400, u'streaming', u'isohunt') + + +razvan@valhalla:~/projects/p2p-next/cs-p2p-next/auto/db$ python DatabaseCommander.py --add session p2p-next.db +swarm id (swarm identifier in database): 4 + client name (Tribler, libtorrent, etc.): Tribler + system OS (Linux, Windows, Mac OS X): Linux + OS version (2.6.28, 7, 10.6): 2.6.30 + system RAM (in MB): 2048 + system CPU (in KHz): 1600 + public IP (dotted decimal format): 141.85.37.1 + public port: 6789 + download speed limit (in KB/s): 512 + upload speed limit (in KB/s): 64 + start time (YYYY-MM-DD HH:MM:SS): 2009-10-28 08:42:00 + +razvan@valhalla:~/projects/p2p-next/cs-p2p-next/auto/db$ python DatabaseCommander.py --list session --id -1 p2p-next.db +(3, 4, 1, u'Linux', u'2.6.30', 2048, 1600, u'141.85.37.1', 6789, 512, 64, 2455132.8624999998)