def run_New_Test(dirPath, confFile, loggerHandler): 
    '''
    The method start a new test asking the technician which csv file to load from the test repository 
    create a new log file for the test in allTest folder and create if wanted specific log for the test in specific folder 
    that the technician will choose
    running the flask server using the port and ip taken from the config file   
    '''
    loggerHandler.start_Test(consts.CLI_SESSION)
    loggerHandler.print_To_Terminal(consts.SET_CSV_FILE_MESSAGE)
    inputAnswer = get_input()
    
    if(inputAnswer!="quit"):
        try: ### initialize the test definition from the csv file 
            csvFileParser = CsvFileParser(str(dirPath) + confFile.getElementsByTagName("testRepoPath")[0].firstChild.data + inputAnswer)
            testDefinition = TestDefinition(csvFileParser.initializeTestDefinition(),csvFileParser.find_Number_Of_Cols())
        except IOError as e:  ### in case there is file not found error try to enter new csv file name
            loggerHandler.print_To_Terminal(e.message)
            run_New_Test(dirPath, confFile, loggerHandler)
        
        insertToFolderAnswer = add_Log_Of_Test_To_Specific_Folder(loggerHandler)
        if (insertToFolderAnswer == "yes"):
            loggerHandler.print_To_Terminal(consts.TYPE_NAME_OF_FOLDER)
            insertToFolderAnswer = raw_input()
            try:
                loggerHandler.start_Test(inputAnswer, insertToFolderAnswer) ### if decided to enter to folder create two logs one in the all test folder ### if decided to enter to folder create two logs one in the all test folder
            except Exception as E:
                loggerHandler.print_To_Terminal(E.message)
                run_New_Test(dirPath, confFile, loggerHandler)
            loggerHandler.print_to_Logs_Files(consts.SELECT_TO_ADD_TEST_MESSAGE+ inputAnswer + consts.SELECT_TO_ADD_FOLDER_MESSAGE 
                                                + insertToFolderAnswer, True)
        else:
            loggerHandler.start_Test(inputAnswer)
            loggerHandler.print_to_Logs_Files(consts.SELECTED_TEST_FROM_USER_MESSAGE + str(inputAnswer), True)
        cliHandler = CLIHandler(inputAnswer, confFile, dirPath, loggerHandler,testDefinition) ### initialize cli session handler
        flaskServer.enodeBController = ENodeBController(cliHandler.engine)
        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) # use TLS to avoid POODLE
        ctx.verify_mode = ssl.CERT_REQUIRED
        ctx.load_verify_locations(str(dirPath) + cliHandler.get_Element_From_Config_File("caCerts"))
        ctx.load_cert_chain(str(dirPath) + cliHandler.get_Element_From_Config_File("pemFilePath"), str(dirPath) + cliHandler.get_Element_From_Config_File("keyFilePath"))## get the certificates for https from config file
        cliHandler.server = flaskServer.runFlaskServer(cliHandler.get_Element_From_Config_File("hostIp"),cliHandler.get_Element_From_Config_File("port"),ctx) ### run flask server using the host name and port  from conf file
        if (cliHandler.engine.check_Validation_Error()):
            cliHandler.stop_Thread_Due_To_Exception()
    if(inputAnswer=="quit"):
        loggerHandler.print_To_Terminal(consts.QUIT_PROGRAM_MESSAGE)
Example #2
0
from controllers.ENodeBController import ENodeBController
import Utils.Consts as consts
from collections import OrderedDict
import json
from controllers.CLIUtils.enums import StepStatus
from __builtin__ import True
import flask

app = Flask(__name__)
app.config['JSON_SORT_KEYS'] = False
import logging

log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)

enodeBController = ENodeBController(None)


@app.route("/v2.0/<typeOfCalling>/", methods=['POST'])
def sent_Flask_Req_To_Server(typeOfCalling):
    '''
    the method get any post request sent from the CBSD that the url includes '/cbsd/<typeOfCalling>/' 
    send to the engine the request and after verification at the engine side sent the response from the engine 
    to the CBSD side    
    '''
    logger = enodeBController.engine.loggerHandler
    json_dict = json.loads(request.data, object_pairs_hook=OrderedDict)
    while (not enodeBController.engine.check_Last_Step_In_All_CBRS()):
        logger.start_Step(json_dict, typeOfCalling, request.remote_addr)
        response = enodeBController.linker_Between_Flask_To_Engine(
            json_dict, typeOfCalling)