From a5206dcc490e481fc74522ed7df125cd4c29c5fe Mon Sep 17 00:00:00 2001 From: Adriana Draghici Date: Tue, 26 Jan 2010 11:34:23 +0200 Subject: [PATCH] created bt_comm directory for test framework (client, server) --- bt_comm/PROTOCOL | 16 ++++++++++++++++ bt_comm/Util.py | 23 +++++++++++++++++++++++ {server => bt_comm/server}/Client.py | 0 bt_comm/server/PROTOCOL | 16 ++++++++++++++++ {server => bt_comm/server}/Server.py | 26 +++++++++++++++++--------- bt_comm/server/Util.py | 23 +++++++++++++++++++++++ {server => bt_comm/server}/daemon.py | 0 server/Util.py | 12 ------------ 8 files changed, 95 insertions(+), 21 deletions(-) create mode 100644 bt_comm/PROTOCOL create mode 100644 bt_comm/Util.py rename {server => bt_comm/server}/Client.py (100%) create mode 100644 bt_comm/server/PROTOCOL rename {server => bt_comm/server}/Server.py (78%) create mode 100644 bt_comm/server/Util.py rename {server => bt_comm/server}/daemon.py (100%) delete mode 100644 server/Util.py diff --git a/bt_comm/PROTOCOL b/bt_comm/PROTOCOL new file mode 100644 index 0000000..cc11eb8 --- /dev/null +++ b/bt_comm/PROTOCOL @@ -0,0 +1,16 @@ + +Comunicare Client <-> Server + +1. Step 1 + - informatiile legate de clienti + - msg 1: tipul mesajului: CONFIG_MSG (definit in Util.py) + - msg 2: lista de dictionare cu datele din clients.xml + exp: [{CLIENT:"tribler", FILE:"Tribler/Tools/cmdline.py", + RUN_TYPE:"script", + INTERPRETER:"python", PREFIX:"PYTHONPATH=.",SUFFIX:"", + UP_LIMIT_OPTION:"",DL_LIMIT_OPTION:"", PORT_OPTION:"-p", + LOG_DIR_OPTION:"-l",DL_DIR_OPTION:"-d"}] + +2. Mesaje START + +..... diff --git a/bt_comm/Util.py b/bt_comm/Util.py new file mode 100644 index 0000000..c844044 --- /dev/null +++ b/bt_comm/Util.py @@ -0,0 +1,23 @@ + +#!/usr/bin/env python + +""" Message types: client -> server """ + +CONFIG_MSG = "0"; +START_MSG = "1"; +STOP_MSG = "2"; +STATUS_MSG = "3"; + + +# xml tags from clients.xml +CLIENT = "client" +FILE = "file" +RUN_TYPE = "run type" +INTERPRETER = "interpreter" +PREFIX = "prefix" +SUFFIX = "suffix" +UP_LIMIT_OPTION = "upload_limit_option" +DL_LIMIT_OPTION = "download_limit_option" +PORT_OPTION = "port_option" +LOG_DIR_OPTION = "logging_dir_option" +DL_DIR_OPTION = "download_dir_option" diff --git a/server/Client.py b/bt_comm/server/Client.py similarity index 100% rename from server/Client.py rename to bt_comm/server/Client.py diff --git a/bt_comm/server/PROTOCOL b/bt_comm/server/PROTOCOL new file mode 100644 index 0000000..cc11eb8 --- /dev/null +++ b/bt_comm/server/PROTOCOL @@ -0,0 +1,16 @@ + +Comunicare Client <-> Server + +1. Step 1 + - informatiile legate de clienti + - msg 1: tipul mesajului: CONFIG_MSG (definit in Util.py) + - msg 2: lista de dictionare cu datele din clients.xml + exp: [{CLIENT:"tribler", FILE:"Tribler/Tools/cmdline.py", + RUN_TYPE:"script", + INTERPRETER:"python", PREFIX:"PYTHONPATH=.",SUFFIX:"", + UP_LIMIT_OPTION:"",DL_LIMIT_OPTION:"", PORT_OPTION:"-p", + LOG_DIR_OPTION:"-l",DL_DIR_OPTION:"-d"}] + +2. Mesaje START + +..... diff --git a/server/Server.py b/bt_comm/server/Server.py similarity index 78% rename from server/Server.py rename to bt_comm/server/Server.py index b1a1f70..f7348da 100644 --- a/server/Server.py +++ b/bt_comm/server/Server.py @@ -18,6 +18,8 @@ WAITING_START_DATA = 3 WAITING_STOP_DATA = 4 WAITING_STATUS_DATA = 5 +clients_data = [] + def recv_pickled_data(clientsock): # while chunk: @@ -36,8 +38,7 @@ def doServer(): while(1): (clientsock, address) = serversocket.accept(); - - """ draft + """ DRAFT if clientsock not in states: states[clientsock] = WAITING_MSG_TYPE; @@ -48,28 +49,35 @@ def doServer(): states[clientsock] = WAITING_CONFIG_DATA; else if msg == Util.START_MSG: - states[clientsock] = WAITING_CONFIG_DATA; + states[clientsock] = WAITING_START_DATA; else if msg == Util.STOP_MSG: - states[clientsock] = WAITING_CONFIG_DATA; + states[clientsock] = WAITING_STOP_DATA; else if msg == Util.STATUS_MSG: - states[clientsock] = WAITING_CONFIG_DATA; + states[clientsock] = WAITING_STATUS_DATA; else clientsock.send("error: wrong message type " + msg) else: if states[clientsock] == WAITING_CONFIG_DATA: - config = recv_pickled_data(clientsock) + config_data = recv_pickled_data(clientsock) + if states[clientsock] == WAITING_START_DATA: + config = recv_pickled_data(clientsock) + if states[clientsock] == WAITING_STOP_DATA: + config = recv_pickled_data(clientsock) + + if states[clientsock] == WAITING_STATUS_DATA: + config = recv_pickled_data(clientsock) + states[clientsock] = WAITING_MSG_TYPE """ - - #clientsock.recv(BUFFER_SIZE) - recv_pickled_data(clientsock) + # clientsock.recv(BUFFER_SIZE) + # recv_pickled_data(clientsock) clientsock.send("ACK") clientsock.close() diff --git a/bt_comm/server/Util.py b/bt_comm/server/Util.py new file mode 100644 index 0000000..c844044 --- /dev/null +++ b/bt_comm/server/Util.py @@ -0,0 +1,23 @@ + +#!/usr/bin/env python + +""" Message types: client -> server """ + +CONFIG_MSG = "0"; +START_MSG = "1"; +STOP_MSG = "2"; +STATUS_MSG = "3"; + + +# xml tags from clients.xml +CLIENT = "client" +FILE = "file" +RUN_TYPE = "run type" +INTERPRETER = "interpreter" +PREFIX = "prefix" +SUFFIX = "suffix" +UP_LIMIT_OPTION = "upload_limit_option" +DL_LIMIT_OPTION = "download_limit_option" +PORT_OPTION = "port_option" +LOG_DIR_OPTION = "logging_dir_option" +DL_DIR_OPTION = "download_dir_option" diff --git a/server/daemon.py b/bt_comm/server/daemon.py similarity index 100% rename from server/daemon.py rename to bt_comm/server/daemon.py diff --git a/server/Util.py b/server/Util.py deleted file mode 100644 index 289e417..0000000 --- a/server/Util.py +++ /dev/null @@ -1,12 +0,0 @@ - -#!/usr/bin/env python - -""" Message types: client -> server """ - -CONFIGURE_MSG = "0"; -START_MSG = "1"; -STOP_MSG = "2"; -STATUS_MSG = "3"; - - - -- 2.20.1