Ejemplo n.º 1
0
    def OnEdit(self, event):

        # get 'sel' integer of listbox selection
        sel = self.listbox.GetSelection()

        if sel != -1:
            # 'text' - name of pipeline config displayed in listbox
            text = str(self.listbox.GetString(sel))

            # 'path' - path of pipeline_config.yml
            path = self.get_pipeline_path(text)

            if os.path.exists(path):
                import yaml
                with open(path, 'r') as f:
                    config = yaml.load(f)

                if 'pipelineName' in config.keys():
                    ind = True
                elif 'pipeline_dir' in config.keys():
                    ind = False
                else:
                    raise Exception('[!] This is not a C-PAC configuration '
                                    'file.')

                # open the pipeline_config editor window
                MainFrame(self,
                          option="edit",
                          path=path,
                          pipeline_id=text,
                          ind=ind)
            else:
                print "Couldn't find the config file %s " % path
Ejemplo n.º 2
0
    def OnLoad(self, event):

        # Does this code do anything?? If you are looking for the code that
        # gets called when you click Load, go to 'AddConfig'

        dlg = wx.FileDialog(
            self, message="Choose the config yaml file",
                defaultDir=os.getcwd(), 
                defaultFile="",
                wildcard= "YAML files(*.yaml, *.yml)|*.yaml;*.yml",
                style=wx.OPEN | wx.CHANGE_DIR)
        
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
                
            if len(path)>0 and os.path.exists(path):
                MainFrame(self, option ="load", path=path)


            else:
                dlg = wx.MessageDialog(self, 'Invalid Path',
                                   'Error!',
                                   wx.OK | wx.ICON_ERROR)
                dlg.Destroy()
            
            dlg.Destroy()
Ejemplo n.º 3
0
 def OnEdit(self, event):
     
     sel = self.listbox.GetSelection()
     if sel != -1:
         text = self.listbox.GetString(sel)
         path = self.get_pipeline_path(text)
         if os.path.exists(path):
             MainFrame(self, option ="edit", path=path, pipeline_id = text)
         else:
             print "Couldn't find the config file %s "%path
Ejemplo n.º 4
0
 def OnEdit(self, event):
     
     # get 'sel' integer of listbox selection
     sel = self.listbox.GetSelection()
     
     if sel != -1:
         
         # 'text' - name of pipeline config displayed in listbox
         text = str(self.listbox.GetString(sel))
         
         # 'path' - path of pipeline_config.yml
         path = self.get_pipeline_path(text)
         
         if os.path.exists(path):
             # open the pipeline_config editor window
             MainFrame(self, option ="edit", path=path, pipeline_id = text)
         else:
             print "Couldn't find the config file %s "%path
Ejemplo n.º 5
0
 def OnLoad(self, event):
     
     dlg = wx.FileDialog(
         self, message="Choose the config yaml file",
             defaultDir=os.getcwd(), 
             defaultFile="",
             wildcard= "YAML files(*.yaml, *.yml)|*.yaml;*.yml",
             style=wx.OPEN | wx.CHANGE_DIR)
     
     if dlg.ShowModal() == wx.ID_OK:
         path = dlg.GetPath()
             
         if len(path)>0 and os.path.exists(path):
             MainFrame(self, option ="load", path=path)
         else:
             dlg = wx.MessageDialog(self, 'Invalid Path',
                                'Error!',
                                wx.OK | wx.ICON_ERROR)
             dlg.Destroy()
         
         dlg.Destroy()
Ejemplo n.º 6
0
    def check_config(self, config):

        ret_val = 1
        
        def display(win, msg, changeBg=True):
            wx.MessageBox(msg, "Error")
            if changeBg:
                win.SetBackgroundColour("pink")
            win.SetFocus()
            win.Refresh()

        try:
            c = yaml.load(open(config, 'r'))
        except:
            dlg = wx.MessageDialog(self, 'Error loading yaml file. Please check the file format',
                                   'Error!', wx.OK | wx.ICON_ERROR)
            ret_val = -1
            dlg.ShowModal()
            dlg.Destroy()

        # the following code checks the loaded pipeline config file for missing parameters (ex. if an old config file is used and new parameters
        # or features have been added) - if missing parameters are detected, it warns the user and informs them of the new defaults
        missingParams = []
        paramList = []

        try:
            params_file = open(p.resource_filename('CPAC', 'GUI/resources/config_parameters.txt'), "r")
        except:
            print "Error: Could not open configuration parameter file.", "\n"
            raise Exception

        paramInfo = params_file.read().split('\n')

        for param in paramInfo:

            if param != '':
                paramList.append(param.split(','))

        notify_centrality_misconfig = True
        for param in paramList:
            try:
                if str(param[0]) not in c:
                    missingParams.append(param)
                # Check centrality threshold options during initial load
                if 'ThresholdOption' in str(param[0]):
                    config_val = c[str(param[0])]
                    if type(config_val) is list:
                        config_val = config_val[0]
                    if type(config_val) is int:
                        missingParams.append(param)
                        if notify_centrality_misconfig:
                            notify_centrality_misconfig = False
                            msg = 'At least one of your centrality treshold '\
                                  'options is mis-formatted as an integer. '\
                                  'Fix this in the pipeline config edit window'
                            dlg = wx.MessageDialog(self, msg, 'Error!', wx.OK | wx.ICON_ERROR)
                            ret_val = -1
                            dlg.ShowModal()
                            dlg.Destroy()
            except:
                errdlg = wx.MessageDialog(self, "Your pipeline " \
                                          "configuration file could not be " \
                                          "processed properly - please " \
                                          "ensure it is formatted properly." \
                                          "\n\nConfig file: %s" % config,
                                          "Error!",
                                       wx.OK | wx.ICON_ERROR)
                errdlg.ShowModal()
                errdlg.Destroy()
                break

        # If any missing parameters, notify user
        if missingParams:
            message = 'The following parameters are missing from your pipeline configuration file:\n\n'

            for param in missingParams:
                message = message + "\"" + str(param[1]) + "\"" + "\n" + "which can be found in tab:" + "\n" +  "\"" + str(param[2]) + "\"\n\n"

            message = message + "Click OK to review the defaults and accept or change the parameters."

            dlg = wx.MessageDialog(self, message, 'Missing Parameters', wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
            dlg.Destroy()

            if os.path.exists(config):
                MainFrame(self, option ="load", path=config)
            else:
                print "Couldn't find the config file %s "%config    

            ret_val = -1

        # Return if config was correct
        return ret_val
Ejemplo n.º 7
0
 def NewItem(self, event):
     MainFrame(self, "save")
Ejemplo n.º 8
0
    def check_config(self, config):

        ret_val = 1

        def display(win, msg, changeBg=True):
            wx.MessageBox(msg, "Error")
            if changeBg:
                win.SetBackgroundColour("pink")
            win.SetFocus()
            win.Refresh()

        try:
            c = yaml.load(open(config, 'r'))
        except:
            dlg = wx.MessageDialog(
                self, 'Error loading yaml file. Please check the file format',
                'Error!', wx.OK | wx.ICON_ERROR)
            ret_val = -1
            dlg.ShowModal()
            dlg.Destroy()

        # the following code checks the loaded pipeline config file for missing parameters (ex. if an old config file is used and new parameters
        # or features have been added) - if missing parameters are detected, it warns the user and informs them of the new defaults
        missingParams = []
        paramList = []

        try:
            params_file = open(
                p.resource_filename('CPAC',
                                    'GUI/resources/config_parameters.txt'),
                "r")
        except:
            print "Error: Could not open configuration parameter file.", "\n"
            raise Exception

        paramInfo = params_file.read().split('\n')

        for param in paramInfo:

            if param != '':
                paramList.append(param.split(','))

        for param in paramList:

            if str(param[0]) not in c:
                missingParams.append(param)

        if missingParams:

            message = 'The following parameters are missing from your pipeline configuration file:\n\n'

            for param in missingParams:
                message = message + "\"" + str(
                    param[1]
                ) + "\"" + "\n" + "which can be found in tab:" + "\n" + "\"" + str(
                    param[2]) + "\"\n\n"

            message = message + "Click OK to review the defaults and accept or change the parameters."

            dlg = wx.MessageDialog(self, message, 'Missing Parameters',
                                   wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
            dlg.Destroy()

            if os.path.exists(config):
                MainFrame(self, option="edit", path=config)
            else:
                print "Couldn't find the config file %s " % config

            ret_val = -1

        return ret_val
Ejemplo n.º 9
0
 def NewGroup(self, event):
     MainFrame(self,
               "load",
               path=p.resource_filename(
                   'CPAC', 'resources/configs/group_config_template.yml'),
               ind=False)
Ejemplo n.º 10
0
 def NewItem(self, event):
     MainFrame(self,
               "load",
               path=p.resource_filename(
                   'CPAC',
                   'resources/configs/pipeline_config_template.yml'))