def install_compform_from_dict(self, compform_dict):
        compName = str(compform_dict['component'])
        compNameAndDir = self.comp_XML_dir + compName 

        self.alfFrameRef.compform_counter = self.alfFrameRef.compform_counter + 1

        tmp_dir_name = "/sdr/dom/_tmp_alf_waveforms/"  # this is where I put my temporary
                                              # xml files
        tmp_wave_name = "_" + compName + str(self.alfFrameRef.compform_counter)


        #make the directory to put the XML
        if os.path.exists(tmp_dir_name) == False:
            try:
                os.mkdir(tmp_dir_name)   
            except:
                errorMsg(self,"Cannot create temporary directory in the waveform directory.  You may need to change the temporary directory to one that you have write permissions to")

        if os.path.exists(tmp_dir_name + tmp_wave_name) == False:   
            try:
                os.mkdir(tmp_dir_name + tmp_wave_name)
            except:
                errorMsg(self,"Cannot create temporary directory in the waveform directory.  You may need to change the temporary directory to one that you have write permissions to")
                return
 

        # assumes that alf is in /sdr/tools
        my_compform = compform.compform(compName, compNameAndDir, 
                                        tmp_dir_name, tmp_wave_name)
        my_compform.create()

     
        print "WARNING: tmp files generated in " + tmp_dir_name

        tmp_dir_name = tmp_dir_name +  tmp_wave_name + "/"

        app_ref = self.alfFrameRef.InstallWaveform(tmp_wave_name + ".sad.xml", 
                                   tmp_dir_name + tmp_wave_name + ".sad.xml",
                                   tmp_wave_name + "_DAS.xml",
                                   tmp_dir_name + tmp_wave_name + "_DAS.xml")

        return app_ref
Beispiel #2
0
    def InstallCompform(self, start_flag = False):
        ''' This method will take the component selected from the GUI
            and create the necessary files to define a Waveform Application
            consisting of a single instance of this component.  The files will
            then be passed to the InstallWaveform method which will create
            an (SCA) application from the Waveform Application.   '''


        print "WARNING: if your node's GPP UUID is not DCE:5ba336ee-aaaa-aaaa-aaaa-00123f573a7f this will not work...\n"
        # get component name from the list
        selection = self.componentsBox.GetSelection()
        compName, compNameAndDir = self.componentsBox.GetPyData(selection)

        self.compform_counter = self.compform_counter + 1

        tmp_dir_name = "/_tmp_alf_waveforms/"  # this is where I put my temporary
                                              # xml files
        tmp_wave_name = "_" + compName + str(self.compform_counter)


        #make the directory to put the XML
        if self.fileMgr.exists(tmp_dir_name) == False:
            try:
                #for some weird reasons, fileMgr.exists(...) looks by default in /sdr/dom/
                #but mkdir(...) creates a directory under /sdr/dev :-(
                #as a temp fix, use "dom/_tmp_alf_waveforms"
                print "creating _tmp_alf_waveforms directory\n"
                self.fileMgr.mkdir("dom" + tmp_dir_name)   
            except:
                errorMsg(self,"Cannot create temporary directory in the waveform directory.\n"
                              "You may need to change the temporary directory to one that you have write permissions to")
        
        #Ticket 272:could not create a second instance of a component as a waveform if ALF is restarted.   
        #Fix: loop into _tmp_alf_waveforms/ directory and see if tmp waveforms exists already
        #with the same name. If found, increment the counter and form a new name for the temp
        #waveform. Repeat this until you find a new name.
        while (self.fileMgr.exists(tmp_dir_name + tmp_wave_name) == True ):
            print "InstallCompform(): ", tmp_wave_name + " exists already...Regenerating new name ", "at ", tmp_dir_name
            self.compform_counter = self.compform_counter + 1
            tmp_wave_name = "_" + compName + str(self.compform_counter)

        if self.fileMgr.exists(tmp_dir_name + tmp_wave_name) == False:   
            try:
                #Add "dom" to the directory because of the above said weird reasons
                print tmp_dir_name, tmp_wave_name
                self.fileMgr.mkdir("dom" + tmp_dir_name + tmp_wave_name)
                
            except:
                errorMsg(self,"Cannot create temporary directory in the waveform directory.\n"
                              "You may need to change the temporary directory to one that you have write permissions to")
                return
                
                
        #till this place, all file related operations are done through framework fileManager
        #generating temp compform files is done by Wavedev code. hence, passing the sdr install
        #path of the component files that should be in config/alf.cfg under installpath
        my_compform = compform.compform(compName, self.installPath + '/' +compNameAndDir, 
                                        self.installPath + '/' +tmp_dir_name, tmp_wave_name)
        my_compform.create()


        print "WARNING: tmp files generated in " + tmp_dir_name

        tmp_dir_name =  tmp_dir_name +  tmp_wave_name + "/"
        
        self.DisplayAvailableWaveforms()
        #the second and fourth arguments are kind of redundant. but passing to keep inline
        #with the previous version of this code. can be removed in future.
        self.InstallWaveform(tmp_dir_name + tmp_wave_name + ".sad.xml", 
                             tmp_dir_name + tmp_wave_name + ".sad.xml",
                             tmp_dir_name + tmp_wave_name + "_DAS.xml",
                             tmp_dir_name + tmp_wave_name + "_DAS.xml", 
                             start_flag)