dba.connect()
+ dba.insert_swarms_row(('dbex-fedora-i686-live-KDE', 100000, 'test', 'local'))
+
+# dba.insert_btclients_row(('libtorrent', 'C++', '1', '0'))
+
+ dba.insert_client_sessions_row(('1', '2', 'Linux', '2.6.26', '512', '1500', '141.85.224.205', '50500', '512', '64', '2011-05-17 13:23:54'))
+
+ dba.get_status()
+
+ dba.disconnect()
+ """
for t in [('DarkKnight', '123000', 'experiment', 'TVTorrents'),
('Fedora', '1024', 'experiment', 'local'),
('Pulp Fiction', '102400', 'streaming', 'isohunt'),
dba.select_btclient_by_name("Tribler")
dba.disconnect()
-
+ """
if __name__ == "__main__":
sys.exit(main())
#!/bin/bash
-SQL_INIT_SCRIPT=../sql/p2p-log-mysql.sql
+DIR_LOCAL="$(cd "$(dirname "$0")" && pwd)"
+SQL_INIT_SCRIPT=$DIR_LOCAL/../sql/p2p-log-mysql.sql
if test $# -ne 1; then
echo "Usage: $0 db_name"
DB_NAME=$1
-mysql --user=root --password=p2p4th3m42232 $DB_NAME <../sql/p2p-log-mysql.sql
+mysql --user=root --password=p2p4th3m42232 -e "create database if not exists $DB_NAME"
+mysql --user=root --password=p2p4th3m42232 $DB_NAME <$SQL_INIT_SCRIPT
exit 0
# fill status information
echo -e "Parsing status file.\n"
-PYTHONPATH=$DIR_LOCAL/../../db-mysql/ python $DIR_LOCAL/StatusParser.py -i $SWARM_ID -f $DIR_ARCHIVE/temp/status.log $DB_NAME
+yes y | PYTHONPATH=$DIR_LOCAL/../../db-mysql/ python $DIR_LOCAL/StatusParser.py -i $SWARM_ID -f $DIR_ARCHIVE/temp/status.log $DB_NAME
echo -e "Status file parsed.\n"
echo -e "DONE!\n"
FILE=$1
if [ $# -lt 2 ]; then
- echo -e "Usage: $0 <file_name> <database_name>\n"
+ echo -e "Usage: $0 <log_filename> <database_name>\n"
exit 1
fi
print "\tstatus_file:"
print "\t--file"
print "\t-f\t\tstatus_file for tribler"
- print "\tdatabase\t\tSQLite database file"
+ print "\tdatabase\t\tMySQL database name"
print "\t--help"
print "\t-h\t\t\tprint this help screen"
--- /dev/null
+#!/bin/bash
+
+ARCHIVE=$1
+DB_NAME=$2
+SWARM_ID=$3
+DIR_LOCAL="$(cd "$(dirname "$0")" && pwd)"
+DIR_ARCHIVE="$(cd "$(dirname "$1")" && pwd)"
+
+if [ $# -lt 2 ]; then
+ echo -e "Usage: $0 <archive_file> <db_name>\n"
+ exit 1
+fi
+
+# if clause to be comented before final use
+#if test -d $DIR_ARCHIVE/temp; then
+# echo -e "Skipping extraction...\n"
+#else
+
+# remove temp folder in case it exists
+rm -Rf $DIR_ARCHIVE/temp
+
+# extract archive in folder $DIR_ARCHIVE/temp
+pushd $DIR_ARCHIVE
+mkdir temp
+echo -e "Extracting archive...\n"
+tar --transform='s,^,temp/,' -xzf "$ARCHIVE"
+echo -e "Archive extracted successfully.\n"
+popd
+#fi
+
+# create database
+pushd $DIR_LOCAL/../../db-mysql
+$DIR_LOCAL/../../db-mysql/db_init $DB_NAME
+
+#fill database with test data
+PYTHONPATH=$DIR_LOCAL/../../db-mysql/ python DatabaseAccess.py $DB_NAME
+popd
+
+# fill logging information
+echo -e "Parsing log files. \n"
+
+pushd $DIR_LOCAL
+
+for folder in $( find $DIR_ARCHIVE/temp -type d -name 'libtorrent_logs*' | sort ); do
+ for log_file in $(find $folder -type f | sort); do
+ if [[ "$log_file" =~ [[:digit:]]*.log ]]; then
+ echo "$log_file"
+ yes y | PYTHONPATH=$DIR_LOCAL/../../db-mysql/ python $DIR_LOCAL/LogParser.py -i $SWARM_ID -f $log_file $DB_NAME
+ fi
+ done
+done
+echo -e "Log files parsed.\n"
+
+# fill status information
+echo -e "Parsing status file.\n"
+yes y | PYTHONPATH=$DIR_LOCAL/../../db-mysql/ python $DIR_LOCAL/StatusParser.py -i $SWARM_ID -f $DIR_ARCHIVE/temp/status.log $DB_NAME
+echo -e "Status file parsed.\n"
+
+echo -e "DONE!\n"
+
+rm -Rf temp
+popd
+exit 0
--- /dev/null
+#!/bin/bash
+
+DB_NAME=$2
+DIR_LOCAL="$(cd "$(dirname "$0")" && pwd)"
+FILE=$1
+
+if [ $# -lt 2 ]; then
+ echo -e "Usage: $0 <log_filename> <database_name>\n"
+ exit 1
+fi
+
+pushd $DIR_LOCAL/../../db-mysql
+#fill database with test data
+PYTHONPATH=$DIR_LOCAL/../../db-mysql/ python DatabaseAccess.py $DB_NAME
+popd
+
+# fill logging information
+yes y | PYTHONPATH=$DIR_LOCAL/../../db-mysql/ python $DIR_LOCAL/LogParser.py -i 1 -f $FILE $DB_NAME
+echo -e "Log file parsed\n"
+echo -e "DONE!\n"
+
+exit 0