From dab741a80699f86e86c91718872a052cca9bbb25 Mon Sep 17 00:00:00 2001 From: Dan Klein Date: Mon, 24 Aug 2015 13:22:48 +0300 Subject: Fixed dependencies of Control Plane to use external_lib sources --- .../trex_control_plane/client/outer_packages.py | 6 ++--- .../trex_control_plane/client/trex_client.py | 12 ++++----- .../examples/client_interactive_example.py | 2 +- .../server/extended_daemon_runner.py | 30 ++++++++++------------ .../trex_control_plane/server/outer_packages.py | 10 +++++--- 5 files changed, 29 insertions(+), 31 deletions(-) (limited to 'scripts/automation') diff --git a/scripts/automation/trex_control_plane/client/outer_packages.py b/scripts/automation/trex_control_plane/client/outer_packages.py index 092cad2c..886aef93 100755 --- a/scripts/automation/trex_control_plane/client/outer_packages.py +++ b/scripts/automation/trex_control_plane/client/outer_packages.py @@ -2,14 +2,12 @@ import sys import site -import platform import os - CURRENT_PATH = os.path.dirname(os.path.realpath(__file__)) ROOT_PATH = os.path.abspath(os.path.join(CURRENT_PATH, os.pardir)) # path to trex_control_plane directory -PATH_TO_PYTHON_LIB = os.path.abspath(os.path.join(ROOT_PATH, 'python_lib')) - +PATH_TO_PYTHON_LIB = os.path.abspath(os.path.join(ROOT_PATH, os.pardir, os.pardir, + os.pardir, 'external_libs', 'python')) CLIENT_MODULES = ['enum34-1.0.4', 'jsonrpclib-pelix-0.2.5', diff --git a/scripts/automation/trex_control_plane/client/trex_client.py b/scripts/automation/trex_control_plane/client/trex_client.py index 1f297538..0fbb4719 100755 --- a/scripts/automation/trex_control_plane/client/trex_client.py +++ b/scripts/automation/trex_control_plane/client/trex_client.py @@ -35,7 +35,7 @@ class CTRexClient(object): def __init__(self, trex_host, max_history_size = 100, trex_daemon_port = 8090, trex_zmq_port = 4500, verbose = False): """ - Instatiate a T-Rex client object, and connecting it to listening deamon-server + Instantiate a T-Rex client object, and connecting it to listening daemon-server :parameters: trex_host : str @@ -45,15 +45,15 @@ class CTRexClient(object): default value : **100** trex_daemon_port : int - the port number on which the trex-deamon server can be reached + the port number on which the trex-daemon server can be reached default value: **8090** trex_zmq_port : int - the port number on which trex's zmq module will interact with deamon server + the port number on which trex's zmq module will interact with daemon server default value: **4500** verbose : bool - sets a verbose output on suported class method. + sets a verbose output on supported class method. default value : **False** @@ -153,7 +153,7 @@ class CTRexClient(object): """ Request to stop a T-Rex run on server. - The request is only valid if the stop intitiator is the same client as the T-Rex run intitiator. + The request is only valid if the stop initiator is the same client as the T-Rex run initiator. :parameters: None @@ -223,7 +223,7 @@ class CTRexClient(object): """ Block the client application until T-Rex changes state from 'Starting' to either 'Idle' or 'Running' - The request is only valid if the stop intitiator is the same client as the T-Rex run intitiator. + The request is only valid if the stop initiator is the same client as the T-Rex run initiator. :parameters: timeout : int diff --git a/scripts/automation/trex_control_plane/examples/client_interactive_example.py b/scripts/automation/trex_control_plane/examples/client_interactive_example.py index d45e4cef..10735221 100755 --- a/scripts/automation/trex_control_plane/examples/client_interactive_example.py +++ b/scripts/automation/trex_control_plane/examples/client_interactive_example.py @@ -4,7 +4,7 @@ import trex_root_path from client.trex_client import * from common.trex_exceptions import * import cmd -from python_lib.termstyle import termstyle +import termstyle import os from argparse import ArgumentParser from pprint import pprint diff --git a/scripts/automation/trex_control_plane/server/extended_daemon_runner.py b/scripts/automation/trex_control_plane/server/extended_daemon_runner.py index 07eedd9f..2ce1eb06 100755 --- a/scripts/automation/trex_control_plane/server/extended_daemon_runner.py +++ b/scripts/automation/trex_control_plane/server/extended_daemon_runner.py @@ -8,18 +8,17 @@ import os, sys from argparse import ArgumentParser from trex_server import trex_parser try: - from python_lib.termstyle import termstyle + from termstyle import termstyle except ImportError: import termstyle - -def daemonize_parser (parser_obj, action_funcs, help_menu): +def daemonize_parser(parser_obj, action_funcs, help_menu): """Update the regular process parser to deal with daemon process options""" parser_obj.description += " (as a daemon process)" parser_obj.usage = None - parser_obj.add_argument("action", choices = action_funcs, - action="store", help = help_menu ) + parser_obj.add_argument("action", choices=action_funcs, + action="store", help=help_menu) return @@ -42,7 +41,7 @@ class ExtendedDaemonRunner(runner.DaemonRunner): (*) start-live : start the application in live mode (no daemon process). """ - def __init__ (self, app, parser_obj): + def __init__(self, app, parser_obj): """ Set up the parameters of a new runner. THIS METHOD INTENTIONALLY DO NOT INVOKE SUPER __init__() METHOD @@ -78,8 +77,8 @@ class ExtendedDaemonRunner(runner.DaemonRunner): self.daemon_context = daemon.DaemonContext() self.daemon_context.stdin = open(app.stdin_path, 'rt') self.daemon_context.stdout = open(app.stdout_path, 'w+t') - self.daemon_context.stderr = open( - app.stderr_path, 'a+t', buffering=0) + self.daemon_context.stderr = open(app.stderr_path, + 'a+t', buffering=0) self.pidfile = None if app.pidfile_path is not None: @@ -87,23 +86,22 @@ class ExtendedDaemonRunner(runner.DaemonRunner): self.daemon_context.pidfile = self.pidfile # mask out all arguments that aren't relevant to main app script - - def update_action_funcs (self): + def update_action_funcs(self): self.action_funcs.update({u'start-live': self._start_live, u'show': self._show}) # add key (=action), value (=desired func) @staticmethod - def _start_live (self): + def _start_live(self): self.app.run() @staticmethod - def _show (self): + def _show(self): if self.pidfile.is_locked(): print termstyle.red("T-Rex server daemon is running") else: print termstyle.red("T-Rex server daemon is NOT running") - def do_action (self): + def do_action(self): self.__prevent_duplicate_runs() self.__prompt_init_msg() try: @@ -117,7 +115,7 @@ class ExtendedDaemonRunner(runner.DaemonRunner): self.do_action() - def __prevent_duplicate_runs (self): + def __prevent_duplicate_runs(self): if self.action == 'start' and self.pidfile.is_locked(): print termstyle.green("Server daemon is already running") exit(1) @@ -125,13 +123,13 @@ class ExtendedDaemonRunner(runner.DaemonRunner): print termstyle.green("Server daemon is not running") exit(1) - def __prompt_init_msg (self): + def __prompt_init_msg(self): if self.action == 'start': print termstyle.green("Starting daemon server...") elif self.action == 'stop': print termstyle.green("Stopping daemon server...") - def __verify_termination (self): + def __verify_termination(self): pass # import time # while self.pidfile.is_locked(): diff --git a/scripts/automation/trex_control_plane/server/outer_packages.py b/scripts/automation/trex_control_plane/server/outer_packages.py index 218ac22a..730934bf 100755 --- a/scripts/automation/trex_control_plane/server/outer_packages.py +++ b/scripts/automation/trex_control_plane/server/outer_packages.py @@ -5,12 +5,14 @@ import site import os CURRENT_PATH = os.path.dirname(os.path.realpath(__file__)) -ROOT_PATH = os.path.abspath(os.path.join(CURRENT_PATH, os.pardir)) # path to trex_control_plane directory -PATH_TO_PYTHON_LIB = os.path.abspath(os.path.join(ROOT_PATH, 'python_lib')) +ROOT_PATH = os.path.abspath(os.path.join(CURRENT_PATH, os.pardir)) # path to trex_control_plane directory +PATH_TO_PYTHON_LIB = os.path.abspath(os.path.join(ROOT_PATH, os.pardir, os.pardir, + os.pardir, 'external_libs', 'python')) SERVER_MODULES = ['enum34-1.0.4', 'jsonrpclib-pelix-0.2.5', 'zmq', + 'pyzmq-14.7.0', 'python-daemon-2.0.5', 'lockfile-0.10.2', 'termstyle' @@ -24,11 +26,11 @@ def import_server_modules(): import_module_list(SERVER_MODULES) -def import_module_list (modules_list): +def import_module_list(modules_list): assert(isinstance(modules_list, list)) for p in modules_list: full_path = os.path.join(PATH_TO_PYTHON_LIB, p) - fix_path = os.path.normcase(full_path) + fix_path = os.path.normcase(full_path) site.addsitedir(full_path) import_server_modules() -- cgit 1.2.3-korg