def executeTask(self, skipCompletedTasks, **args):
     cdmsDataset = self.getInputValue("dataset")
     tValue = args.get('timeValue', cdmsDataset.timeRange[2])
     self.timeValue = cdtime.reltime(float(tValue),
                                     cdmsDataset.referenceTimeUnits)
     taskInputData = self.getInputValue("task")
     taskMap = deserializeTaskData(
         getItem(taskInputData)) if taskInputData else None
     taskData = taskMap.get(cdmsDataset.getDsetId(),
                            None) if taskMap else None
     task = None
     if taskData:
         taskName = taskData[0]
         if taskName:
             taskClass = TaskManager.getTask(taskName)
             if taskClass:
                 task = taskClass(cdmsDataset)
                 task_key = task.getInputMap(self)
                 if (skipCompletedTasks
                         and self.getTaskCompleted(task_key)):
                     print " Skipping completed task: %s " % task_key
                 else:
                     task.compute([
                         self.timeValue,
                     ])
                 self.setTaskCompleted(task_key)
     if task == None:
         print >> sys.stderr, "Error, no task defined in CDATUtilities module"
     self.setResult('dataset', cdmsDataset)
 def getSerializedIOData(self, taskName):
     ioData = []
     varDimMap = {}
     firstVar = None
     for input in self.varCombos:
         var = self.varCombos[input].currentText()
         varData = var.split('(')
         if len(varData) > 1:
             if not firstVar: firstVar = str(varData[0]).strip()
             varType = str(varData[1]).strip()
             ndim = 3 if (varType[0] == 'v') else 2
             varDimMap[input] = ndim
             ioData.append('%s+%s+%d' %
                           (str(input), str(varData[0]).strip(), ndim))
     serializedInputs = ';'.join(ioData)
     ioData = []
     taskClass = TaskManager.getTask(taskName)
     for output in self.outputNames:
         var = self.outputNames[output].text()
         ndim = taskClass.getOutputDimensionality(output, varDimMap)
         varData = firstVar.split('*') if firstVar else None
         varName = '*'.join([varData[0], str(var)]) if varData else str(var)
         if ndim: ioData.append('%s+%s+%d' % (str(output), varName, ndim))
     serializedOutputs = ';'.join(ioData)
     return serializedInputs, serializedOutputs
 def executeTask( self, skipCompletedTasks, **args ):
     cdmsDataset = self.getInputValue( "dataset"  ) 
     tValue = args.get( 'timeValue', cdmsDataset.timeRange[2] )
     self.timeValue = cdtime.reltime( float( tValue ), cdmsDataset.referenceTimeUnits )
     taskInputData = self.getInputValue( "task"  ) 
     taskMap =  deserializeTaskData( getItem( taskInputData ) ) if taskInputData else None   
     taskData =  taskMap.get( cdmsDataset.getDsetId(), None ) if taskMap else None
     task = None
     if taskData:
         taskName = taskData[0]
         if taskName:
             taskClass = TaskManager.getTask( taskName )
             if taskClass:
                 task = taskClass( cdmsDataset )
                 task_key = task.getInputMap( self )
                 if ( skipCompletedTasks and self.getTaskCompleted( task_key ) ):   print " Skipping completed task: %s " % task_key
                 else:  task.compute( [ self.timeValue, ] )
                 self.setTaskCompleted( task_key )
 def getSerializedIOData( self, taskName ):
     ioData = []
     varDimMap = {}
     firstVar = None
     for input in self.varCombos:
         var = self.varCombos[input].currentText() 
         varData = var.split('(')
         if len( varData ) > 1:
             if not firstVar: firstVar = str(varData[0]).strip()
             varType = str(varData[1]).strip()
             ndim = 3 if ( varType[0] == 'v' ) else 2
             varDimMap[ input ] = ndim
             ioData.append( '%s+%s+%d' % ( str(input), str(varData[0]).strip(), ndim ) )
     serializedInputs = ';'.join( ioData )
     ioData = []
     taskClass = TaskManager.getTask( taskName )
     for output in self.outputNames:
         var = self.outputNames[output].text() 
         ndim = taskClass.getOutputDimensionality( output, varDimMap )
         varData = firstVar.split('*') if firstVar else None
         varName = '*'.join( [ varData[0], str(var) ] ) if varData else str(var)
         if ndim: ioData.append( '%s+%s+%d' % ( str(output), varName, ndim ) )
     serializedOutputs = ';'.join( ioData )
     return serializedInputs, serializedOutputs 
    def updateTask(self, qtask):
        taskName = str(qtask)
        if self.outputTabIndex >= 0:
            self.tabbedWidget.removeTab(self.outputTabIndex)
        if self.inputTabIndex >= 0:
            self.tabbedWidget.removeTab(self.inputTabIndex)
        inputsTab = QWidget()
        self.inputTabIndex = self.tabbedWidget.addTab(inputsTab, 'inputs')
        self.tabbedWidget.setCurrentWidget(inputsTab)
        outputsTab = QWidget()
        self.outputTabIndex = self.tabbedWidget.addTab(outputsTab, 'outputs')
        self.tabbedWidget.setCurrentWidget(outputsTab)

        taskClass = TaskManager.getTask(taskName)
        if taskClass:
            inputs_layout = QVBoxLayout()
            inputsTab.setLayout(inputs_layout)
            inputs_layout.setMargin(10)
            inputs_layout.setSpacing(10)
            self.varCombos = {}
            inputVar = None
            firstVar = None
            for input in taskClass.inputs:
                input_selection_layout = QHBoxLayout()
                input_selection_label = QLabel("%s:" % str(input))
                input_selection_layout.addWidget(input_selection_label)

                varCombo = QComboBox(self.parent())
                input_selection_label.setBuddy(varCombo)
                varCombo.setMaximumHeight(30)
                input_selection_layout.addWidget(varCombo)
                for (var, ndims) in self.variableList:
                    if ndims == 2:
                        varCombo.addItem(getVariableSelectionLabel(var, ndims))
                        if not firstVar: firstVar = var
                for (var, ndims) in self.variableList:
                    if ndims == 3:
                        varCombo.addItem(getVariableSelectionLabel(var, ndims))
                        if not firstVar: firstVar = var
                self.varCombos[input] = varCombo
                self.connect(varCombo, SIGNAL("currentIndexChanged(QString)"),
                             self.updateOutputs)
                inputs_layout.addLayout(input_selection_layout)
                if self.inputMap:
                    (varValue, ndim) = self.inputMap.get(input, (None, None))
                    if varValue:
                        varLabel = getVariableSelectionLabel(varValue, ndim)
                        currentIndex = varCombo.findText(varLabel)
                        varCombo.setCurrentIndex(currentIndex)
                        if not inputVar: inputVar = varValue
            if not inputVar: inputVar = firstVar

            outputs_layout = QVBoxLayout()
            outputsTab.setLayout(outputs_layout)
            outputs_layout.setMargin(10)
            outputs_layout.setSpacing(10)
            self.outputNames = {}
            for output in taskClass.outputs:
                output_selection_layout = QHBoxLayout()

                output_selection_label = QLabel("%s:" % str(output))
                output_selection_layout.addWidget(output_selection_label)

                outputEdit = QLineEdit(self.parent())
                output_selection_label.setBuddy(outputEdit)
                output_selection_layout.addWidget(outputEdit)
                self.outputNames[output] = outputEdit
                outputs_layout.addLayout(output_selection_layout)
                outputValue = self.outputMap.get(output, None)
                if inputVar:
                    if not outputValue:
                        inputVarData = inputVar.split('*')
                        outputValue = "%s.%s.%s" % (
                            inputVarData[-1], taskName,
                            output) if inputVar else "%s.%s" % (taskName,
                                                                output)
                        self.outputMap[output] = outputValue
                    outputEdit.setText(outputValue)
                self.connect(outputEdit, SIGNAL("editingFinished()"),
                             self.stateChanged)

            self.stateChanged()
        else:
            print >> sys.stderr, "Error, class undefined for task %s" % taskName
    def updateTask( self, qtask ):
        taskName = str( qtask )
        if self.outputTabIndex >= 0: self.tabbedWidget.removeTab( self.outputTabIndex )
        if self.inputTabIndex  >= 0: self.tabbedWidget.removeTab( self.inputTabIndex )
        inputsTab = QWidget()        
        self.inputTabIndex = self.tabbedWidget.addTab( inputsTab, 'inputs' )                 
        self.tabbedWidget.setCurrentWidget(inputsTab)
        outputsTab = QWidget()        
        self.outputTabIndex = self.tabbedWidget.addTab( outputsTab, 'outputs' ) 
        self.tabbedWidget.setCurrentWidget(outputsTab)

        taskClass = TaskManager.getTask( taskName )
        if taskClass:
            inputs_layout = QVBoxLayout()
            inputsTab.setLayout( inputs_layout ) 
            inputs_layout.setMargin(10)
            inputs_layout.setSpacing(10)
            self.varCombos = {}
            inputVar = None
            firstVar = None
            for input in taskClass.inputs:
                input_selection_layout = QHBoxLayout()
                input_selection_label = QLabel( "%s:" % str(input) )
                input_selection_layout.addWidget( input_selection_label ) 
        
                varCombo =  QComboBox ( self.parent() )
                input_selection_label.setBuddy( varCombo )
                varCombo.setMaximumHeight( 30 )
                input_selection_layout.addWidget( varCombo  )
                for ( var, ndims ) in self.variableList: 
                    if ndims == 2: 
                        varCombo.addItem( getVariableSelectionLabel( var, ndims ) )
                        if not firstVar: firstVar = var
                for ( var, ndims ) in self.variableList: 
                    if ndims == 3: 
                        varCombo.addItem( getVariableSelectionLabel( var, ndims ) )
                        if not firstVar: firstVar = var
                self.varCombos[input] = varCombo
                self.connect( varCombo, SIGNAL("currentIndexChanged(QString)"), self.updateOutputs ) 
                inputs_layout.addLayout(input_selection_layout)
                if self.inputMap:
                    ( varValue, ndim ) = self.inputMap.get( input, ( None, None ) )
                    if varValue:
                        varLabel = getVariableSelectionLabel( varValue, ndim )
                        currentIndex = varCombo.findText( varLabel )
                        varCombo.setCurrentIndex( currentIndex )
                        if not inputVar: inputVar = varValue
            if not inputVar: inputVar = firstVar
            
            outputs_layout = QVBoxLayout()
            outputsTab.setLayout( outputs_layout ) 
            outputs_layout.setMargin(10)
            outputs_layout.setSpacing(10)
            self.outputNames = {}
            for output in taskClass.outputs:
                output_selection_layout = QHBoxLayout()
                
                output_selection_label = QLabel( "%s:" % str(output) )
                output_selection_layout.addWidget( output_selection_label ) 
        
                outputEdit =  QLineEdit ( self.parent() )
                output_selection_label.setBuddy( outputEdit )
                output_selection_layout.addWidget( outputEdit  )
                self.outputNames[output] = outputEdit
                outputs_layout.addLayout(output_selection_layout)
                outputValue = self.outputMap.get( output, None )
                if inputVar:
                    if not outputValue:
                        inputVarData = inputVar.split('*') 
                        outputValue = "%s.%s.%s" % ( inputVarData[-1], taskName, output ) if inputVar else "%s.%s" % ( taskName, output )
                        self.outputMap[output] = outputValue
                    outputEdit.setText( outputValue )
                self.connect( outputEdit, SIGNAL("editingFinished()"), self.stateChanged )
                 
            self.stateChanged()
        else:
            print>>sys.stderr, "Error, class undefined for task %s" % taskName