Example #1
0
 def generateInputJson(self):
     try:
         #Generate Index Configuration File 
         csvgen= CSVgenerator(self.file,_start_word_1_,keyField_1,fieldList)
         csvFile=_input_directory_+"RoamingArea.csv"
         indexInfoList_1=csvgen.generateIndexDict(self.file, _start_word_1_, keyField_1)
         indexInfoList_2_a=csvgen.generateIndexDict(self.file, _start_word_2_, keyField_2_a_)
         indexInfoList_2_b=csvgen.generateIndexDict(self.file, _start_word_2_, keyField_2_b_)
         indexInfoList_2=indexInfoList_2_a+indexInfoList_2_b
         csvgen.addPrefixTokey(indexInfoList_2,'RAP') 
         indexInfoList_3=csvgen.generateIndexDict(self.file, _start_word_3_, keyField_3)
         csvgen.addPrefixTokey(indexInfoList_3 , 'HGNSP')
         indexInfoList = indexInfoList_1+indexInfoList_2+indexInfoList_3            
         csvgen.writeDictToCSV(csvFile, indexInfoList)
         self.logger.info("csv updated---"+csvFile)
         indexdict=indexInfoList
         # End Dynamic Generation Code
         inputJson=self.parseAndGenerateInputMap(indexdict);
         filename =_input_directory_+"ericsson_"+_obj_name_+".json"
         with open(filename, 'w') as f1:
             json.dump(inputJson, f1, indent=4)
         self.logger.info("Json generated after parsing Input file ---"+str(inputJson))
     except(FileNotFoundError):
         self.logger.error("Input file missing:-")
         logging.exception(FileNotFoundError)
         raise ApplicationError("Input file missing for object:- "+config.nokiaObjectName+" Add input files & retry")
     except(Exception):
         self.logger.error("Error while parsing input dump, check for the correct format")
         raise
     return filename 
Example #2
0
 def generateInputJson(self):
     try:
         #Generate Index configuration file
         csvgen = CSVgenerator(self.file, _start_word_, keyField, fieldList)
         csvFile = _input_directory_ + "SMSCsi.csv"
         indexInfoList = csvgen.generateIndexDict(self.file, _start_word_,
                                                  keyField)
         indexInfoList2 = csvgen.generateIndexDict(self.file, _start_word_,
                                                   _object_start_)
         indexInfoList = indexInfoList2 + indexInfoList
         csvgen.writeDictToCSV(csvFile, indexInfoList)
         self.logger1.info("csv updated---" + csvFile)
         indexdict = indexInfoList
         # End Dynamic Index Generation code
         inputJson = self.parseAndGenerateInputMap(indexdict)
         filename = _input_directory_ + "ericsson_" + _obj_name_ + ".json"
         with open(filename, 'w') as f1:
             json.dump(inputJson, f1, indent=4)
         self.logger1.info("Json generated after parsing Input file ---" +
                           str(inputJson))
     except (FileNotFoundError):
         self.logger1.error("Input file missing:-" + self.file)
         raise ApplicationError("Input file missing for object:- " +
                                config.nokiaObjectName +
                                " Add input files & retry")
     except (Exception):
         self.logger1.error(
             "Error while parsing input dump, check for the correct format")
         raise
     return filename
Example #3
0
 def generateInputJson(self):
     filename = log_path+config.nokiaObjectName+'\\fALU_PDPContext.json'
     try:
         parserValues = self.openXML()
         with open(filename, 'w') as f:
             json.dump(parserValues , f , indent=4)
     except(Exception):
         self.logger.error("Input file missing:-"+self.xmlFileName)
         raise ApplicationError("Input file missing for object:-  "+config.nokiaObjectName)
     return filename
 def generateFaluOCSISubscriptionJson(self):
     
     try :  
         global counter
         filename = log_path+config.nokiaObjectName+'\\fALU_OCSi_Subscription_Dump.json'
         allfiles =self.listofFiles
         frame = pd.DataFrame()
         list_ = []
         for file_ in allfiles:
             fields=['ocsiCamelCapabilityHandling','ocsiCamelVlrNotSuppDfltHandl','ocsiCamelGmscNotSuppDfltHdl','ocsiCollectedInfoTdpScpIsdn','ocsiCollectedInfoTdpServKey','ocsiCollectedInfoTdpDfltCalH','callTypeCriteria']
             df = pd.read_csv(file_,sep=';',skiprows=2, header=0, usecols=fields)
             list_.append(df)
         frame = pd.concat(list_)
         dict_test1 = {'ocsiCamelCapabilityHandling':frame['ocsiCamelCapabilityHandling'], 'ocsiCamelVlrNotSuppDfltHandl':frame['ocsiCamelVlrNotSuppDfltHandl'],'ocsiCamelGmscNotSuppDfltHdl':frame['ocsiCamelGmscNotSuppDfltHdl'], 'ocsiCollectedInfoTdpScpIsdn':frame['ocsiCollectedInfoTdpScpIsdn'],'ocsiCollectedInfoTdpServKey':frame['ocsiCollectedInfoTdpServKey'],'ocsiCollectedInfoTdpDfltCalH':frame['ocsiCollectedInfoTdpDfltCalH'],'callTypeCriteria':frame['callTypeCriteria']}
         data = pd.DataFrame(dict_test1)
         uni_comb=data.drop_duplicates()
         u2 = uni_comb.to_dict(orient = "records")
         # JSON Modified 
         
         for item in u2:
             var1 = item['ocsiCollectedInfoTdpScpIsdn']
             var2 = item['ocsiCamelCapabilityHandling']
             var3 = item['ocsiCollectedInfoTdpServKey']
             mod_var1 = str(var1)
             mod_var2 = str(var2).replace('+', ',')
             mod_var3 = str(var3)
             item['ocsiCollectedInfoTdpScpIsdn'] = mod_var1
             item['ocsiCamelCapabilityHandling'] = mod_var2
             item['ocsiCollectedInfoTdpServKey'] = mod_var3
             
             if (item['ocsiCollectedInfoTdpServKey']!= None):
                  item["tdpid"] = "2"
                  
             item['GsmServiceProfile'] = "OCSi_"+ str(counter) 
             counter+=1     
                 
         
         JSONFiles = u2
         self.logger.info("Parsing of Subscription dum completed ")
         
         
         with open(filename, 'w') as f:
                 json.dump(JSONFiles , f , indent=4)
     except(FileNotFoundError):
             self.logger.error("Input file missing:-")
             raise ApplicationError("Input file missing for object:-  "+config.nokiaObjectName)
     except(Exception):
             logging.exception("Error while parsing input dump, check for the correct format")  
             raise                   
     return filename
Example #5
0
    def generateFaluOCSIJson(self, path):
        filename = log_path + config.nokiaObjectName + '\\fALU_SmsCsi.json'
        try:
            parserValues = self.openXML(path)
            latestdict = {}

            for i in parserValues:
                for k, v in i.items():
                    latestdict[k] = v
            demoList.append(latestdict)

            with open(filename, 'w') as f:
                json.dump(demoList, f, indent=4)
        except (FileNotFoundError):
            self.logger.error("Input file missing:-" + self.xmlFileName)
            raise ApplicationError("Input file missing for object:-  " +
                                   config.nokiaObjectName)
        except (Exception):
            logging.exception(
                "Error while parsing input dump, check for the correct format")
            raise
        return filename
Example #6
0
    def generateFaluOCSIJson(self, path):
        #filename = "D://Data/falu_bearercapability.json"
        #filename = config.project_path+'/inputFiles/fALU_TCsi.json'
        filename = log_path + config.nokiaObjectName + '\\fALU_TCsi.json'

        try:
            parserValues = self.openXML(path)
            latestdict = {}

            for i in parserValues:
                for k, v in i.items():
                    latestdict[k] = v
            demoList.append(latestdict)
            #===================================================================
            # TempList=[]
            # TempList.append(parserValues)
            #===================================================================
            #===================================================================
            # with open(filename, 'w') as f:
            #     json.dump(parserValues , f , indent=4)
            #===================================================================

            with open(filename, 'w') as f:
                json.dump(demoList, f, indent=4)
            #self.logger.debug(" ****************************** fALUAttributeSet structure %d ***************"%len(parserValues))
            #pp = pprint.PrettyPrinter(depth=6)

            #pp.pprint(parserValues)

            #print("***************************************************************")
        except (FileNotFoundError):
            self.logger.error("Input file missing:-" + self.xmlFileName)
            raise ApplicationError("Input file missing for object:-  " +
                                   config.nokiaObjectName)
        except (Exception):
            logging.exception(
                "Error while parsing input dump, check for the correct format")
            raise
        return filename
Example #7
0
 def parseAndGenerateInputMap(self,indexdict):
     global counter
     fullList = []
     ardList = []
     uniqueCombList=self.fetchUniqueCombination(indexdict)
     SSPlanReference_FilePath = _input_directory_+"ericsson_"+_obj_name_Ref_SS+".json"
     ODBPlanReference_FilePath = _input_directory_+"ericsson_"+_obj_name_Ref_ODB+".json"
     
     try:
     
         with open(SSPlanReference_FilePath) as f:
             data_SSPlan = json.load(f)
             #print(data_SSPlan)
         
         with open(ODBPlanReference_FilePath) as f:
             data_ODBPlan = json.load(f)
             #print(data_ODBPlan)    
             
     except(FileNotFoundError):
         self.logger.error("Missing Execution of SSPlan or ODBPlan")
         logging.exception(FileNotFoundError)
         raise ApplicationError("SSPlan and ODBPlan should be executed compulsory before execution of RoamPlan")
             
         
     ardList = self.findARDExistenceorNot()            
     for item in uniqueCombList:
         uniqueCombValues = []
         for k,v in item.items():
             new_dict = {}                
             val1 = self.getJsonObjectWithVal(data_SSPlan, 'treatment', k, 'treatment_Value', v)
             val2 = self.getJsonObjectWithVal(data_ODBPlan, 'treatment', k, 'treatment_Value', v)
             val3 = self.getARDSETValue(ardList, 'treatment', k, 'treatment_val', v)
             if (val3 !=[] and k=='RSP'):
                 new_dict['ARD'] = ",".join(str(item) for item in val3[:] )
                 new_dict['ADD_Treatment'] = 'RSP'
             elif (val3 !=[] and k=='RSIP'):
                 new_dict['ARD'] = ",".join(str(item) for item in val3[:] )
                 new_dict['ADD_Treatment'] = 'RSIP'
             else:
                 new_dict['ARD'] = ""
                 new_dict['ADD_Treatment'] = ""    
             if (val1 !=[] or val2 !=[]):
                 if (val1 !=[]):
                     new_dict['ref_ssPlanName'] = ",".join(str(item) for item in val1[:] )
                 else:
                     new_dict['ref_ssPlanName'] = ""
                 if (val2 !=[]):
                     new_dict['ref_odbPlanName'] = ",".join(str(item) for item in val2[:] )
                 else:
                     new_dict['ref_odbPlanName'] = ""   
                     
             else:
                 new_dict['ref_ssPlanName'] = ""
                 new_dict['ref_odbPlanName'] = ""
                  
             if (val1 !=[] or val2 !=[] or val3 !=[]):
                 listdict = []
                 new_dict['identifier'] = "RoamPlan_"+ str(counter)
                 listdict = self.trimDictValues(item)
                 new_dict['Unique_Comb_Info'] = ",".join(str(item) for item in listdict[:] )
                 #counter+=1  
                 uniqueCombValues.append(new_dict)
                                     
             if (all(x=="" for x in new_dict.values()) == False):                
                 fullList.append(new_dict) 
         if(uniqueCombValues !=[]):
             counter+=1
                 
     
     return fullList