Exemplo n.º 1
0
    def createNewWorkflow(self):
        """ createnewWorkflow(filename: str)

        createNewWorkflow is called when the user selects a new file. It makes
        a new workflow and appends it to the workflow list.
        """
        if self.workflows == []:
            api.get_current_controller().change_selected_version(0)
        
        self.currentWorkflow = Workflow()
        self.workflows.append(self.currentWorkflow)
Exemplo n.º 2
0
    def createNewWorkflow(self):
        """ createnewWorkflow(filename: str)

        createNewWorkflow is called when the user selects a new file. It makes
        a new workflow and appends it to the workflow list.
        """
        if self.workflows == []:
            api.get_current_controller().change_selected_version(0)

        self.currentWorkflow = Workflow()
        self.workflows.append(self.currentWorkflow)
Exemplo n.º 3
0
    def updateModuleOps(self, name, args):
        """ updateModule(name: str, args: list)

        updateModule updates the vistrail module given the module name and a
        list of tuples where each tuple = (input port name, value)
        """
        if name not in list(self.modules):
            return
        
        module = self.modules[name]
        for portName, value in args:
            api.get_current_controller().update_function(module, portName,
                                                         [value])
Exemplo n.º 4
0
    def updateModuleOps(self, name, args):
        """ updateModule(name: str, args: list)

        updateModule updates the vistrail module given the module name and a
        list of tuples where each tuple = (input port name, value)
        """
        if name not in list(self.modules):
            return

        module = self.modules[name]
        for portName, value in args:
            api.get_current_controller().update_function(
                module, portName, [value])
Exemplo n.º 5
0
    def updateModule(self, name, portName, value):
        """ updateModule(name: str, portName: str, value: *)

        updateModule updates the vistrail module given the module name, input
        port name, and value
        """
        if name not in list(self.modules):
            return

        # Set the filename associated w/ this workflow
        if name == open_name:
            self.filename = value

        module = self.modules[name]
        api.get_current_controller().update_function(module, portName, [value])
Exemplo n.º 6
0
    def updateModule(self, name, portName, value):
        """ updateModule(name: str, portName: str, value: *)

        updateModule updates the vistrail module given the module name, input
        port name, and value
        """
        if name not in list(self.modules):
            return

        # Set the filename associated w/ this workflow
        if name == open_name:
            self.filename = value
        
        module = self.modules[name]
        api.get_current_controller().update_function(module, portName, [value])
Exemplo n.º 7
0
    def getRedoVersion(self):
        """looks at all child versions, and returns that which has the most
        recent uvcdat-last-visit annotation, if any """
        try:
            vistrail = api.get_current_controller().vistrail
        except api.NoVistrail:
            return None

        graph = vistrail.tree.getVersionTree()

        maxes = [datetime.min, None]  #time, version

        def _findMostRecent(version):
            children = graph.edges_from(version)
            for (child, _) in children:
                annotation = vistrail.get_action_annotation(
                    child, 'uvcdat-last-visit')
                if annotation is not None:
                    time = datetime.strptime(annotation.value,
                                             ControllerCell.DATE_FORMAT)
                    if time > maxes[0]:
                        maxes[0] = time
                        maxes[1] = child
                else:
                    _findMostRecent(child)

        _findMostRecent(self.current_parent_version)
        #        if maxes[1]:
        #            print "Found redo version: %d" % maxes[1]
        return maxes[1]
Exemplo n.º 8
0
def printPersistentModuleMap(label, controller=None):
    if controller == None:
        import api
        controller = api.get_current_controller()
    vistrails_interpreter = getDefaultInterpreter()
    object_map = vistrails_interpreter.find_persistent_entities(
        controller.current_pipeline)[0]
Exemplo n.º 9
0
def getWorkflowObjectMap(controller=None):
    if controller == None:
        import api

        controller = api.get_current_controller()
    vistrails_interpreter = getDefaultInterpreter()
    return vistrails_interpreter.find_persistent_entities(controller.current_pipeline)[0]
Exemplo n.º 10
0
def getWorkflowObjectMap(controller=None):
    if controller == None:
        import api
        controller = api.get_current_controller()
    vistrails_interpreter = getDefaultInterpreter()
    return vistrails_interpreter.find_persistent_entities(
        controller.current_pipeline)[0]
Exemplo n.º 11
0
def getFunctionList(mid, controller=None):
    if controller == None:
        import api

        controller = api.get_current_controller()
    module = controller.current_pipeline.modules[mid]
    return module.functions if module.functions else []
Exemplo n.º 12
0
def getModuleClass( mid ):
    import api
    registry = get_module_registry()
    controller = api.get_current_controller() 
    reg_module = controller.current_pipeline.modules[ mid ]
    descriptor = registry.get_descriptor_by_name( reg_module.package, reg_module.name, reg_module.namespace )
    return descriptor.module
Exemplo n.º 13
0
    def activateFromCell(self, canvas):
        self.activeCanvas = canvas
        self.setColorsFromCanvas()

        self.controller = api.get_current_controller()
        self.version = self.controller.current_version
        self.pipeline = self.controller.vistrail.getPipeline(self.version)
        self.plots = CDMSPipelineHelper.find_plot_modules(self.pipeline)

        #set up plot combo box
        #        self.plotCb.clear()
        #        for i in range(len(self.plots)):
        #            found = False
        #            for func in self.plots[i].functions:
        #                if func.name == 'graphicsMethodName':
        #                    self.plotCb.addItem(self.plots[i].module_descriptor.module.plot_type \
        #                        + '_' + func.params[0].strValue, userData=i)
        #                    found = True
        #            if not found:
        #                self.plotCb.addItem(self.plots[i].module_descriptor.module.plot_type, userData=i)
        #        self.plotCb.setCurrentIndex(0)

        self.mapNameChanged = False
        self.cellsDirty = False
        self.show()
Exemplo n.º 14
0
    def __init__( self, mid, **args ):
        import api
        PersistentVisualizationModule.__init__( self, mid, **args )
        self.primaryInputPorts = [ 'volume', 'contours' ]
        self.addConfigurableLevelingFunction( 'colorScale', 'C', label='Colormap Scale', units='data', setLevel=self.scaleColormap, getLevel=self.getDataRangeBounds, layerDependent=True, adjustRangeInput=0 )
        self.addConfigurableLevelingFunction( 'opacity', 'O', label='Slice Plane Opacity', rangeBounds=[ 0.0, 1.0 ],  setLevel=self.setOpacity, activeBound='min',  getLevel=self.getOpacity, isDataValue=False, layerDependent=True, bound = False )
        self.addConfigurableLevelingFunction( 'zScale', 'z', label='Vertical Scale', setLevel=self.setZScale, activeBound='max', getLevel=self.getScaleBounds, windowing=False, sensitivity=(10.0,10.0), initRange=[ 2.0, 2.0, 1 ] )
        self.addConfigurableLevelingFunction( 'contourDensity', 'g', label='Contour Density', activeBound='max', setLevel=self.setContourDensity, getLevel=self.getContourDensity, layerDependent=True, windowing=False, rangeBounds=[ 3.0, 30.0, 1 ], bound=False, isValid=self.hasContours )
        self.addConfigurableLevelingFunction( 'contourColorScale', 'S', label='Contour Colormap Scale', units='data', setLevel=self.scaleContourColormap, getLevel=lambda:self.getDataRangeBounds(1), layerDependent=True, adjustRangeInput=1, isValid=self.hasContours )
        self.addConfigurableMethod('Show Outline Map', self.toogleOutlineMap, 'm' )

        self.addUVCDATConfigGuiFunction( 'contourColormap', ColormapConfigurationDialog, 'K', label='Choose Contour Colormap', setValue=lambda data: self.setColormap(data,1) , getValue=lambda: self.getColormap(1), layerDependent=True, isValid=self.hasContours )
        self.sliceOutputShape = args.get( 'slice_shape', [ 100, 50 ] )
        self.opacity = [ 1.0, 1.0 ]
        self.iOrientation = 0
        self.updatingPlacement = False
        self.isSlicing = False
        self.planeWidgetX = None
        self.planeWidgetY = None
        self.planeWidgetZ = None
        self.opacityUpdateCount = 0
        self.generateContours = False
        self.contourLineActors = {}
        self.contourLineMapperer = None
        self.contours = None
        self.NumContours = 10.0
        self.showOutlineMap = True
        try:
            controller = api.get_current_controller()
#            print " Volume Slicer init, id = %x " % id(self)
            VolumeSlicerModules[mid] = self
        except api.NoVistrail:
            pass
Exemplo n.º 15
0
    def getRedoVersion(self):
        """looks at all child versions, and returns that which has the most
        recent uvcdat-last-visit annotation, if any """
        try:
            vistrail = api.get_current_controller().vistrail
        except api.NoVistrail:
            return None
        
        graph = vistrail.tree.getVersionTree()
        
        maxes = [datetime.min, None] #time, version
        def _findMostRecent(version):
            children = graph.edges_from(version)
            for (child, _) in children:
                annotation = vistrail.get_action_annotation(child,
                        'uvcdat-last-visit')
                if annotation is not None:
                    time = datetime.strptime(annotation.value, 
                                             ControllerCell.DATE_FORMAT)
                    if time > maxes[0]:
                        maxes[0] = time
                        maxes[1] = child
                else:
                    _findMostRecent(child)
        
        _findMostRecent(self.current_parent_version)
#        if maxes[1]:
#            print "Found redo version: %d" % maxes[1]
        return maxes[1]
Exemplo n.º 16
0
    def activateFromCell(self,canvas):
        self.activeCanvas = canvas
        self.setColorsFromCanvas()
        
        self.controller = api.get_current_controller()
        self.version = self.controller.current_version
        self.pipeline = self.controller.vistrail.getPipeline(self.version)
        self.plots = CDMSPipelineHelper.find_plot_modules(self.pipeline)
        
        #set up plot combo box
#        self.plotCb.clear()
#        for i in range(len(self.plots)):
#            found = False
#            for func in self.plots[i].functions:
#                if func.name == 'graphicsMethodName':
#                    self.plotCb.addItem(self.plots[i].module_descriptor.module.plot_type \
#                        + '_' + func.params[0].strValue, userData=i)
#                    found = True                
#            if not found:
#                self.plotCb.addItem(self.plots[i].module_descriptor.module.plot_type, userData=i)                
#        self.plotCb.setCurrentIndex(0)
        
        self.mapNameChanged = False
        self.cellsDirty = False
        self.show()        
Exemplo n.º 17
0
def printPersistentModuleMap(label, controller=None):
    if controller == None:
        import api

        controller = api.get_current_controller()
    vistrails_interpreter = getDefaultInterpreter()
    object_map = vistrails_interpreter.find_persistent_entities(controller.current_pipeline)[0]
Exemplo n.º 18
0
 def pushUndoVersion(self, version = None):
     """adds timestamp annotation to mark this version as an undo point"""
     if version is None:
         version = self.current_parent_version
     controller = api.get_current_controller()
     controller.vistrail.set_action_annotation(version, 'uvcdat-last-visit',
            datetime.strftime(datetime.now(), ControllerCell.DATE_FORMAT))
Exemplo n.º 19
0
 def pushUndoVersion(self, version=None):
     """adds timestamp annotation to mark this version as an undo point"""
     if version is None:
         version = self.current_parent_version
     controller = api.get_current_controller()
     controller.vistrail.set_action_annotation(
         version, 'uvcdat-last-visit',
         datetime.strftime(datetime.now(), ControllerCell.DATE_FORMAT))
Exemplo n.º 20
0
    def save(self):
        self.email = str(self.usernameEdit.text())
	vt_filepath = api.get_current_controller().get_locator().name

	url="http://einstein.sv.cmu.edu/estimator?email='"+self.email+"'&vfile='"+vt_filepath+"'"
	print >> sys.stderr, url
	webbrowser.open_new(url)
        self.hide()
Exemplo n.º 21
0
def getTaggedVersionNumber(tag, controller=None):
    tagged_version_number = -1
    if tag <> None:
        if controller == None:
            import api
            controller = api.get_current_controller()
        if controller.vistrail.hasTag(tag):
            tagged_version_number = controller.vistrail.get_version_number(tag)
    return tagged_version_number
Exemplo n.º 22
0
def getTaggedVersionNumber( tag, controller = None ):
    tagged_version_number = -1
    if tag <> None: 
        if controller == None: 
            import api
            controller = api.get_current_controller()
        if controller.vistrail.hasTag( tag ):
            tagged_version_number = controller.vistrail.get_version_number( tag )
    return tagged_version_number
Exemplo n.º 23
0
def getModuleClass(mid):
    import api
    registry = get_module_registry()
    controller = api.get_current_controller()
    reg_module = controller.current_pipeline.modules[mid]
    descriptor = registry.get_descriptor_by_name(reg_module.package,
                                                 reg_module.name,
                                                 reg_module.namespace)
    return descriptor.module
Exemplo n.º 24
0
 def updateLabel( self, recreate = False ):
     if self.isClient: return
     module = self.getRegisteredModule()
     if module.has_annotation_with_key('__desc__'):
         import api
         controller = api.get_current_controller()
         label = module.get_annotation_by_key('__desc__').value.strip()
         controller.add_annotation( ('__desc__', str(label)), module.id ) 
         if recreate: controller.current_pipeline_view.recreate_module( controller.current_pipeline, module.id )
Exemplo n.º 25
0
 def update_functions(self, module_name, functions):
     #// @todo: Check with Ben if this is the right way to do it:        
     import api            
     controller = api.get_current_controller()
     module = PlotPipelineHelper.find_module_by_name(controller.current_pipeline, module_name)            
     action = controller.update_functions(module, functions)        
     if action is not None:
         window = get_vistrails_application().uvcdatWindow
         window.get_current_project_controller().cell_was_changed(action)
Exemplo n.º 26
0
    def writePipelineToCurrentVistrail(self, aliases):
        """writePipelineToVistrail(aliases: dict) -> list of actions
        It will compute necessary actions and add to the current vistrail, 
        starting at self.parent_version. In the case self.parent_version
        does not contain a valid workflow, we will start from the root with
        a new pipeline.
        
        """
        actions = []
        #print self.current_controller
        if self.current_controller is None:
            self.current_controller = api.get_current_controller()
            self.current_parent_version = 0L
        else:
            if self.current_parent_version > 0L:
                pipeline = self.current_controller.vistrail.getPipeline(self.current_parent_version)
                if (len(pipeline.aliases) >= len(self.workflow.aliases) and
                    self.checkIfWorkflowsAreCompatible()):
                    paliases = set(pipeline.aliases.keys())
                    waliases = set(self.workflow.aliases.keys())
                    if len(waliases - paliases) != 0:
                        actions.append(self.resetWorkflow())
        # print "writePipelineToCurrentVistrail: controller ", self.current_controller
        #print "version ", self.current_parent_version 
        pipeline = self.current_controller.vistrail.getPipeline(self.current_parent_version)
        if len(pipeline.module_list) == 0:
            #create actions and paste them in current vistrail
            vistrail = self.current_controller.vistrail
            if vistrail:
                action = self.addPipelineAction(self.workflow,
                                               self.current_controller,
                                               vistrail, 
                                               self.current_parent_version)
                actions.append(action)
                newid = action.id
                #no tagging for now
#                newtag = self.name
#                count = 1
#                while vistrail.hasTag(newtag):
#                    newtag = "%s %s"%(self.name, count)
#                    count += 1 
#                vistrail.addTag(newtag, newid)
                self.current_parent_version = newid
                
        #now we update pipeline with current parameter values
        pipeline = self.current_controller.vistrail.getPipeline(self.current_parent_version)
        print " @@ Pipeline aliases: ", str( pipeline.aliases )
        self.addMergedAliases( aliases, pipeline )
        action = self.addParameterChangesFromAliasesAction(pipeline, 
                                        self.current_controller, 
                                        self.current_controller.vistrail, 
                                        self.current_parent_version, aliases)
        actions.append(action)
        if action:
            self.current_parent_version = action.id
        return actions
Exemplo n.º 27
0
 def updateLabel(self, recreate=False):
     if self.isClient: return
     module = self.getRegisteredModule()
     if module.has_annotation_with_key('__desc__'):
         import api
         controller = api.get_current_controller()
         label = module.get_annotation_by_key('__desc__').value.strip()
         controller.add_annotation(('__desc__', str(label)), module.id)
         if recreate:
             controller.current_pipeline_view.recreate_module(
                 controller.current_pipeline, module.id)
Exemplo n.º 28
0
    def activateFromCell(self, canvas):
        self.activeCanvas = canvas
        self.setColorsFromCanvas()

        self.controller = api.get_current_controller()
        self.version = self.controller.current_version
        self.pipeline = self.controller.vistrail.getPipeline(self.version)
        self.plots = CDMSPipelineHelper.find_plot_modules(self.pipeline)
        self.mapNameChanged = False
        self.cellsDirty = False
        self.show()
Exemplo n.º 29
0
 def getUndoVersion(self):
     """returns first ancestor that has uvcdat-last-visit annotation"""
     try:
         vistrail = api.get_current_controller().vistrail
     except api.NoVistrail:
         return None
         
     def _getParent(version):
         if version != 0:
             try:
                 return vistrail.actionMap[version].parent
             except KeyError, e:
                 return None
         return None
Exemplo n.º 30
0
    def getUndoVersion(self):
        """returns first ancestor that has uvcdat-last-visit annotation"""
        try:
            vistrail = api.get_current_controller().vistrail
        except api.NoVistrail:
            return None

        def _getParent(version):
            if version != 0:
                try:
                    return vistrail.actionMap[version].parent
                except KeyError, e:
                    return None
            return None
Exemplo n.º 31
0
    def writePipelineToCurrentVistrail(self, aliases):
        """writePipelineToVistrail(aliases: dict) -> None 
        It will compute necessary actions and add to the current vistrail, 
        starting at self.parent_version. In the case self.parent_version
        does not contain a valid workflow, we will start from the root with
        a new pipeline.
        
        """
        #print self.current_controller
        if self.current_controller is None:
            self.current_controller = api.get_current_controller()
            self.current_parent_version = 0L
        else:
            if self.current_parent_version > 0L:
                pipeline = self.current_controller.vistrail.getPipeline(
                    self.current_parent_version)
                if len(pipeline.aliases) >= len(self.workflow.aliases):
                    paliases = set(pipeline.aliases.keys())
                    waliases = set(self.workflow.aliases.keys())
                    if len(waliases - paliases) != 0:
                        self.current_parent_version = 0
        # print "writePipelineToCurrentVistrail: controller ", self.current_controller
        #print "version ", self.current_parent_version
        if self.current_parent_version == 0L:
            #create actions and paste them in current vistrail
            vistrail = self.current_controller.vistrail
            if vistrail:
                newid = self.addPipelineAction(self.workflow,
                                               self.current_controller,
                                               vistrail,
                                               self.current_parent_version)
                newtag = self.name
                count = 1
                while vistrail.hasTag(newtag):
                    newtag = "%s %s" % (self.name, count)
                    count += 1
                vistrail.addTag(newtag, newid)
                self.current_parent_version = newid

        #now we update pipeline with current parameter values
        pipeline = self.current_controller.vistrail.getPipeline(
            self.current_parent_version)
        self.addMergedAliases(aliases, pipeline)
        newid = self.addParameterChangesFromAliasesAction(
            pipeline, self.current_controller,
            self.current_controller.vistrail, self.current_parent_version,
            aliases)
        self.current_parent_version = newid
Exemplo n.º 32
0
def getDownstreamModules(mid):
    import api

    controller = api.get_current_controller()
    pipeline = controller.current_pipeline
    current_module = pipeline.modules[mid]
    test_modules = [current_module]
    downstream_modules = []
    while len(test_modules):
        test_mod = test_modules.pop()
        output_port_specs = test_mod.output_port_specs
        for output_port in output_port_specs:
            out_modules = pipeline.get_outputPort_modules(test_mod.id, output_port.name)
            downstream_modules.extend(out_modules)
            test_modules.extend(out_modules)
    return downstream_modules
Exemplo n.º 33
0
def tagCurrentVersion( tag ):
    if tag: 
        import api
        ctrl = api.get_current_controller()
        vistrail = ctrl.vistrail
        tagged_version_number = -1
        if tag <> None: 
            if vistrail.hasTag( tag ):
                tagged_version_number = vistrail.get_version_number( tag )
                vistrail.changeTag( None, tagged_version_number )
            try:
                vistrail.addTag( tag, ctrl.current_version )
                print "  --- Tagging version %d as %s" % ( ctrl.current_version, tag )
            except VersionAlreadyTagged, err:
                curr_tag = vistrail.get_tag( ctrl.current_version ) 
                print>>sys.stderr, " !! Version %d already tagged as %s, applying tag %s, prev tagged version: %d" % ( ctrl.current_version, tag, curr_tag, tagged_version_number )
Exemplo n.º 34
0
def getWorkflowModule( mid, forceGet = True, controller = None  ):    
    if controller == None: 
        import api
        controller = api.get_current_controller()
    vistrails_interpreter = getDefaultInterpreter()
    object_map = vistrails_interpreter.find_persistent_entities( controller.current_pipeline )[0]
    module_instance = object_map.get( mid, None )
    if (module_instance == None) and forceGet:
        current_version = controller.current_version
        min_version = current_version - 3 if current_version > 3 else 0
        for version in range( current_version-1, min_version, -1 ):
            pipeline =  controller.vistrail.getPipeline( version )
            object_map = vistrails_interpreter.find_persistent_entities( pipeline )[0]
            module_instance = object_map.get( mid, None )
            if module_instance <> None: return module_instance
    return module_instance
Exemplo n.º 35
0
def getDownstreamModules(mid):
    import api
    controller = api.get_current_controller()
    pipeline = controller.current_pipeline
    current_module = pipeline.modules[mid]
    test_modules = [current_module]
    downstream_modules = []
    while len(test_modules):
        test_mod = test_modules.pop()
        output_port_specs = test_mod.output_port_specs
        for output_port in output_port_specs:
            out_modules = pipeline.get_outputPort_modules(
                test_mod.id, output_port.name)
            downstream_modules.extend(out_modules)
            test_modules.extend(out_modules)
    return downstream_modules
Exemplo n.º 36
0
 def writePipelineToCurrentVistrail(self, aliases):
     """writePipelineToVistrail(aliases: dict) -> None 
     It will compute necessary actions and add to the current vistrail, 
     starting at self.parent_version. In the case self.parent_version
     does not contain a valid workflow, we will start from the root with
     a new pipeline.
     
     """
     #print self.current_controller
     if self.current_controller is None:
         self.current_controller = api.get_current_controller()
         self.current_parent_version = 0L
     else:
         if self.current_parent_version > 0L:
             pipeline = self.current_controller.vistrail.getPipeline(self.current_parent_version)
             if len(pipeline.aliases) >= len(self.workflow.aliases):
                 paliases = set(pipeline.aliases.keys())
                 waliases = set(self.workflow.aliases.keys())
                 if len(waliases - paliases) != 0:
                     self.current_parent_version = 0
     # print "writePipelineToCurrentVistrail: controller ", self.current_controller
     #print "version ", self.current_parent_version 
     if self.current_parent_version == 0L:
         #create actions and paste them in current vistrail
         vistrail = self.current_controller.vistrail
         if vistrail:
             newid = self.addPipelineAction(self.workflow,
                                            self.current_controller,
                                            vistrail, 
                                            self.current_parent_version)
             newtag = self.name
             count = 1
             while vistrail.hasTag(newtag):
                 newtag = "%s %s"%(self.name, count)
                 count += 1 
             vistrail.addTag(newtag, newid)
             self.current_parent_version = newid
             
     #now we update pipeline with current parameter values
     pipeline = self.current_controller.vistrail.getPipeline(self.current_parent_version)
     self.addMergedAliases( aliases, pipeline )
     newid = self.addParameterChangesFromAliasesAction(pipeline, 
                                     self.current_controller, 
                                     self.current_controller.vistrail, 
                                     self.current_parent_version, aliases)
     self.current_parent_version = newid
Exemplo n.º 37
0
def tagCurrentVersion(tag):
    if tag:
        import api
        ctrl = api.get_current_controller()
        vistrail = ctrl.vistrail
        tagged_version_number = -1
        if tag <> None:
            if vistrail.hasTag(tag):
                tagged_version_number = vistrail.get_version_number(tag)
                vistrail.changeTag(None, tagged_version_number)
            try:
                vistrail.addTag(tag, ctrl.current_version)
                print "  --- Tagging version %d as %s" % (ctrl.current_version,
                                                          tag)
            except VersionAlreadyTagged, err:
                curr_tag = vistrail.get_tag(ctrl.current_version)
                print >> sys.stderr, " !! Version %d already tagged as %s, applying tag %s, prev tagged version: %d" % (
                    ctrl.current_version, tag, curr_tag, tagged_version_number)
Exemplo n.º 38
0
def getWorkflowModule(mid, forceGet=True, controller=None):
    if controller == None:
        import api
        controller = api.get_current_controller()
    vistrails_interpreter = getDefaultInterpreter()
    object_map = vistrails_interpreter.find_persistent_entities(
        controller.current_pipeline)[0]
    module_instance = object_map.get(mid, None)
    if (module_instance == None) and forceGet:
        current_version = controller.current_version
        min_version = current_version - 3 if current_version > 3 else 0
        for version in range(current_version - 1, min_version, -1):
            pipeline = controller.vistrail.getPipeline(version)
            object_map = vistrails_interpreter.find_persistent_entities(
                pipeline)[0]
            module_instance = object_map.get(mid, None)
            if module_instance <> None: return module_instance
    return module_instance
Exemplo n.º 39
0
    def createModule(self):
        """ createModule() -> None
        Collect parameters, values and operator, and create a
        PythonCalc module to the current pipeline using the API
        provided in vistrails.api.

        """
        pythoncalc = "edu.utah.sci.vistrails.pythoncalc"
        module = api.add_module(0, 0, pythoncalc, 'PythonCalc', '')
        api.get_current_controller().update_function(
            module, 'value1', [str(self.value1Edit.text())])
        api.get_current_controller().update_function(
            module, 'value2', [str(self.value2Edit.text())])
        api.get_current_controller().update_function(
            module, 'op', [str(self.opCombo.currentText())])
        api.switch_to_pipeline_view()
Exemplo n.º 40
0
    def createModule(self):
        """ createModule() -> None
        Collect parameters, values and operator, and create a
        PythonCalc module to the current pipeline using the API
        provided in vistrails.api.

        """
        pythoncalc = "edu.utah.sci.vistrails.pythoncalc"
        module = api.add_module(0, 0, pythoncalc, 'PythonCalc', '')
        api.get_current_controller().update_function(module, 'value1',
                                                     [str(self.value1Edit.text())])
        api.get_current_controller().update_function(module, 'value2',
                                                     [str(self.value2Edit.text())])
        api.get_current_controller().update_function(module, 'op',
                                                     [str(self.opCombo.currentText())])
        api.switch_to_pipeline_view()
Exemplo n.º 41
0
    def send(self):
    
        # this line prints out the latest workflow name which we can leverage later
        #workflow_name = api.get_available_versions()[1][api.get_available_versions()[0][-1]]
	workflow_name="tmp"
        
        # login info
        username = loginWindow.username
        password = loginWindow.password
        
        vt_filepath = api.get_current_controller().get_locator().name
	print >> sys.stderr, "##### vt_filepath: "+vt_filepath
        remote_filename = username + "_" + str(uuid.uuid4()) + "_" + vt_filepath.split('/')[-1][:-3]

        # spawn the scp pexpect thread and login
        config_text = "email: "+str(self.emailEdit.text())+"\\nworkflow_name: "+str(workflow_name)+"\\nscheduling: "
        config_text += "\\n    type: "+str(self.prefCombo.itemData(self.prefCombo.currentIndex()).toString())
        """
        config_text += "\\n    ncpus: "+str(self.ncpusEdit.text())
        config_text += "\\n    node: "+str(self.nodeCombo.itemData(self.nodeCombo.currentIndex()).toString())
        config_text += "\\n    select: "+str(self.selectEdit.text())
        """
	print >> sys.stderr, "##### config_text: "+config_text

	#look at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html
	command=ssh_command_pre+" \"echo -ne '"+config_text+"' >> ~/hecc/Server/config/"+remote_filename+".yml" + "\""

	print >> sys.stderr, "##### ssh_command: "+command
	os.system(command)

	#Sample: scp -i ~/Downloads/gonghankey.pem test.py [email protected]:~/hecc/job_queue

	destination="~/hecc/Server/job_queue/"+remote_filename+".vt"
	command=scp_command_pre+" "+vt_filepath+" ubuntu@"+public_dns+":"+destination
	print >> sys.stderr, "##### scp_command: "+command
	os.system(command)

        self.hide()
Exemplo n.º 42
0
    def build_plot_pipeline_action(controller, version, var_modules, plots,row, col):
        # FIXME want to make sure that nothing changes if var_module
        # or plot_module do not change
        #plot_type = plots[0].parent
        #plot_gm = plots[0].name

        if controller is None:
            controller = api.get_current_controller()
            version = 0L

        reg = get_module_registry()
        ops = []
        cell_module = None

        pipeline = controller.vistrail.getPipeline(version)

        var_module = var_modules[0]

        try:
            temp_var_module = pipeline.get_module_by_id(var_module.id)
        except KeyError:
            temp_var_module = None

        if temp_var_module is not None:
            var_module = temp_var_module
        else:
            ops.append(('add',var_module))

        for plot in plots:

            plot_type = plot.parent
            plot_gm = plot.name

            import re
            plotname = re.sub(r'\s', '', plot_gm)

            plot_module = PlotPipelineHelper.find_module_by_name(pipeline, plotname)
            if plot_module is not None:
                continue

            plot_descriptor = reg.get_descriptor_by_name('gov.lbl.visit', 'VisItCell')
            plot_module = controller.create_module_from_descriptor(plot_descriptor)

            ops.append(('add',plot_module))

            #if cell_module is None:
            #    cell_module = PlotPipelineHelper.find_module_by_name(pipeline, "VisItCell")

            if cell_module is None:
                #cell_desc = reg.get_descriptor_by_name('gov.lbl.visit', "VisItCell")
                #cell_module = controller.create_module_from_descriptor(cell_desc)
                #ops.append(('add', cell_module))
                cell_module = plot_module

                if issubclass(var_modules[0].module_descriptor.module, CDMSVariable):
                    conn = controller.create_connection(var_module, 'self',
                                                        plot_module, 'variable')
                else:
                    conn = controller.create_connection(var_module, 'self',
                                                        cell_module, 'variable')
                ops.append(('add', conn))
                #print 'connection source id is ', conn.sourceId
                #print 'connection dest id is ', conn.destinationId

                loc_module = controller.create_module_from_descriptor(
                    reg.get_descriptor_by_name('edu.utah.sci.vistrails.spreadsheet',
                                               'CellLocation'))
                functions = controller.create_functions(loc_module,
                    [('Row', [str(row+1)]), ('Column', [str(col+1)])])
                for f in functions:
                    loc_module.add_function(f)

                loc_conn = controller.create_connection(loc_module, 'self',
                                                        cell_module, 'Location')
                ops.extend([('add', loc_module),
                            ('add', loc_conn)])

                type_of_plot = str(plot_gm)
                param_module = controller.create_module_from_descriptor(
                    reg.get_descriptor_by_name('gov.lbl.visit', 'VisItParams'))

                functions = controller.create_functions(param_module,
                    [('renderType', [type_of_plot])])
                for f in functions:
                    param_module.add_function(f)

                param_conn = controller.create_connection(param_module, 'self',
                                                        plot_module, 'visitparams')
                ops.extend([('add', param_module),
                            ('add', param_conn)])

            # Create connection between the cell and the representation
            #conn = controller.create_connection(plot_module, 'self',
            #                                    cell_module, 'representation')

            # Add the connection to the pipeline operations
            #ops.append(('add', conn))

        action = core.db.action.create_action(ops)
        controller.change_selected_version(version)
        controller.add_new_action(action)
        controller.perform_action(action)
        return action
Exemplo n.º 43
0
    def check_dependencies(self, index):
        """
        determines if current VisTrail will be
        supported by the repository's VisTrail server
        """

        if not index: return

        self._unrunnable_wfs = {}

        # are we logged in?
        if not self.dialog.cookiejar:
            self._repository_status['support_status'] = "Please login"
            self._repository_status['details'] = ""
            self.update_push_information()
            self._push_button.setEnabled(False)
            self._branch_button.hide()
        else:
            self.repository_supports_vt = True
            # get packages supported by VisTrails repository
            server = self.serverCombo.itemData(index).toList()[1].toString()
            packages_url = "%s/packages/supported_packages/%s" % \
                    (self.config.webRepositoryURL, server)

            try:
                get_supported_packages = urllib2.urlopen(url=packages_url)
            except urllib2.HTTPError, e:
                self._repository_status['support_status'] = ""
                self._repository_status['details'] = ""
                if e.code == 500:
                    self._repository_status['support_status'] = \
                            ("Error connecting to repository (server side issues)")
                else:
                    debug.critical(str(e))

                self._push_button.setEnabled(False)
                self.update_push_information()
                self.populate_table()
                return
            server_packages = json.loads(get_supported_packages.read())

            # get local packages and local data modules
            local_packages = []

            self.local_data_modules = ['File', 'FileSink', 'Path']
            self.unavailable_data = set()
            self.unsupported_packages = set()
            has_python_source = False

            vistrail = api.get_current_vistrail()

            for version_id in vistrail.get_tagMap():
                pipeline = vistrail.getPipeline(version_id)
                tag = vistrail.get_tagMap()[version_id]
                workflow_packages = []
                for module in pipeline.module_list:
                    # count modules that use data unavailable to web repository
                    on_repo = False
                    if module.name[-6:] == 'Reader' or \
                       module.name in self.local_data_modules:
                        for edge in pipeline.graph.edges_to(module.id):
                            if pipeline.modules[edge[0]].name in [
                                    'HTTPFile', 'RepoSync'
                            ]:
                                on_repo = True

                        if not on_repo:
                            if tag not in self._unrunnable_wfs.keys():
                                self._unrunnable_wfs[tag] = []
                            self._unrunnable_wfs[tag].append(module.name)
                            self.unavailable_data.add(module.name)

                    if module.name == "PythonSource":
                        if tag not in self._unrunnable_wfs.keys():
                            self._unrunnable_wfs[tag] = []
                        self._unrunnable_wfs[tag].append(module.name)
                        has_python_source = True

                    # get all packages used in tagged versions of this workflow
                    if module.package not in workflow_packages:
                        workflow_packages.append(module.package)

                # find unsupported packages
                wf_unsupported_packages = filter((lambda p: p not in \
                                                  server_packages),
                                                 workflow_packages)
                if wf_unsupported_packages:
                    if tag not in self._unrunnable_wfs.keys():
                        self._unrunnable_wfs[tag] = []
                    for package in wf_unsupported_packages:
                        self._unrunnable_wfs[tag].append(package)
                        self.unsupported_packages.add(package)

            # display unsupported packages
            self._repository_status['details'] = "Details:\n"
            if self.unsupported_packages:
                self.repository_supports_vt = False
                self._repository_status['details'] += \
                        "Packages incompatible with web repository: %s\n\n" % \
                        (', '.join(self.unsupported_packages)[:-2])

            # display unsupported data modules
            if len(self.unavailable_data):
                self.repository_supports_vt = False
                self._repository_status['details'] += \
                        "Data sources not available on web repository: %s\n"%\
                        (', '.join(self.unavailable_data)[:-2])

            if has_python_source:
                self.repository_supports_vt = False
                self._repository_status['details'] += \
                        ("This Vistrail contains PythonSource module(s) and "
                         "will have to be verified by admins before it can be "
                         "run on the web repository. You will be notified when"
                         " your workflows have been verfied")

            self._repository_status['support_status'] = ""
            controller = api.get_current_controller()
            if controller.vistrail.get_annotation('repository_vt_id'):
                # Since repository_vt_id doesn't mirror crowdlabs vt id
                # get the crowdlabs vt id for linkage
                vt_url = "%s/vistrails/details/%s" % \
                        (self.config.webRepositoryURL,
                         controller.vistrail.get_annotation('repository_vt_id').value)
                try:
                    request = urllib2.urlopen(url=vt_url)
                    # TODO: check project that vistrail is part of and notify user
                    # that branching will add it to a different project
                    if request.code == 200:
                        # the vistrail exists on the repository, setup merge settings
                        self.permission_gb.setTitle(
                            ("Default Global Permissions "
                             "(only applicable to branching):"))
                        self._push_button.setText("Commit changes")
                        self._branch_button.setEnabled(True)
                        self._branch_button.show()

                        vistrail_link = "%s/vistrails/details/%s" % \
                                (self.config.webRepositoryURL,
                                 controller.vistrail.get_annotation('repository_vt_id').value)

                        self._repository_status['support_status'] = \
                                ("You are attempting to update this vistrail: "
                                 "<a href='%s'>%s</a>. This will possibly update your local version with changes from the web repository<br><br>") % \
                                (vistrail_link, vistrail_link)

                except urllib2.HTTPError:
                    # the vistrail has *probably* been deleted or doesn't exist
                    # remove repository_vt_id annotation
                    repo_annotation = controller.vistrail.get_annotation(
                        'repository_vt_id')
                    if repo_annotation:
                        controller.vistrail.db_delete_annotation(
                            repo_annotation)

            if self.repository_supports_vt:
                self._repository_status['support_status'] += \
                        ("All of this VisTrail's tagged versions are supported"
                         " on the VisTrails Repository.")
            else:
                self._repository_status['support_status'] += \
                        ("This VisTrail contains packages or modules that are"
                         " not supported by the VisTrails Repository.<br>"
                         "You may still upload the VisTrail but it will "
                         "not be run by the Repository.")

            self._push_button.setEnabled(True)

            self.update_push_information()
            self.populate_table()
Exemplo n.º 44
0
def executeWorkflow():
    import api

    controller = api.get_current_controller()
    controller.execute_current_workflow()
Exemplo n.º 45
0
def updateScene():
    import api

    controller = api.get_current_controller()
    controller.current_pipeline_view.setupScene(controller.current_pipeline)
Exemplo n.º 46
0
 def setupSaveConfigurations():
     import api
     ctrl = api.get_current_controller()
     scene = ctrl.current_pipeline_view
     scene.connect( scene, SIGNAL('moduleSelected'), VisItConfigurationWidget.saveConfigurations )
Exemplo n.º 47
0
    def send(self):
    
        # [The LOGIN function is directly copied from remoteLogin package] 
        # LOGIN -- handle the login with all its odd 'expected' cases of
        # failure/success.  returns a boolean indicating the ability to
        # login to the prompt with the given username and password
        def login( thePrompt, password ):
            theResult = thePrompt.expect( ['continue connecting',
                                           'assword:',
                                           pexpect.EOF] )

            # check if this is the first time we have tried to login to the server
            if theResult==0:
                print >> sys.stderr," [scpModule] login -- first time fingerprint"
                thePrompt.sendline( 'yes' )
                theResult = thePrompt.expect( ['continue connecting',
                                               'assword:',
                                               pexpect.EOF] )

            # respond to the result after potential fingerprint acceptance
            if theResult==0:
                print >> sys.stderr," [scpModule] login -- sanity failure -- first time fingerprint again"
                raise RuntimeError, "sanity failure -- fingerprint double check"
            elif theResult==2:
                print >> sys.stderr," [scpModule] login -- received EOF signal"
                raise RuntimeError, "login failure -- early EOF received"

            # otherwise process the password prompt
            elif theResult==1:
                print >> sys.stderr," [scpModule] login -- received password prompt"
                thePrompt.sendline( password )
                theResult = thePrompt.expect( ['assword:',pexpect.EOF] )

                # check the responses
                if theResult==0:
                    print >> sys.stderr," [scpModule] login -- failure denied password"
                    raise RuntimeError,"login failure -- denied username/password"
                else:
                    print >> sys.stderr," [scpModule] successful login..."

    
        # this line prints out the latest workflow name which we can leverage later
        workflow_name = api.get_available_versions()[1][api.get_available_versions()[0][-1]]
        
        # login info
        username = loginWindow.username
        password = loginWindow.password
        
        vt_filepath = api.get_current_controller().get_locator().name
        remote_filename = username + "_" + str(uuid.uuid4()) + "_" + vt_filepath.split('/')[-1][:-3]

        # spawn the scp pexpect thread and login
        config_text = "email: "+str(self.emailEdit.text())+"\\nworkflow_name: "+str(workflow_name)+"\\nscheduling: "
        config_text += "\\n    type: "+str(self.prefCombo.itemData(self.prefCombo.currentIndex()).toString())
        """
        config_text += "\\n    ncpus: "+str(self.ncpusEdit.text())
        config_text += "\\n    node: "+str(self.nodeCombo.itemData(self.nodeCombo.currentIndex()).toString())
        config_text += "\\n    select: "+str(self.selectEdit.text())
        """
        #print >> sys.stderr, config_text

        spawnLine_cfg = "ssh " + username + "@ok.freya.cc \"" + "echo -ne '"+config_text+"' >> /home/hecc/config/"+remote_filename+".yml" + "\""
        #print >> sys.stderr, spawnLine_cfg
        thePrompt_cfg = pexpect.spawn( spawnLine_cfg )
        login( thePrompt_cfg, password )

        spawnLine = "scp " + vt_filepath + " " + username + "@ok.freya.cc:/home/hecc/job_queue/" + remote_filename + ".vt"
        #print >> sys.stderr," [scp Module] scp spawning line: (" + spawnLine + ")"
        thePrompt = pexpect.spawn( spawnLine )
        login( thePrompt, password )

        self.hide()
Exemplo n.º 48
0
    def build_plot_pipeline_action(controller, version, var_modules, plots,
                                   row, col):
        # FIXME want to make sure that nothing changes if var_module
        # or plot_module do not change
        #plot_type = plots[0].parent
        #plot_gm = plots[0].name

        if controller is None:
            controller = api.get_current_controller()
            version = 0L

        reg = get_module_registry()
        ops = []
        cell_module = None

        pipeline = controller.vistrail.getPipeline(version)

        var_module = var_modules[0]

        try:
            temp_var_module = pipeline.get_module_by_id(var_module.id)
        except KeyError:
            temp_var_module = None

        if temp_var_module is not None:
            var_module = temp_var_module
        else:
            ops.append(('add', var_module))

        for plot in plots:

            plot_type = plot.parent
            plot_gm = plot.name

            import re
            plotname = re.sub(r'\s', '', plot_gm)

            plot_module = PlotPipelineHelper.find_module_by_name(
                pipeline, plotname)
            if plot_module is not None:
                continue

            plot_descriptor = reg.get_descriptor_by_name(
                'gov.lbl.visit', 'VisItCell')
            plot_module = controller.create_module_from_descriptor(
                plot_descriptor)

            ops.append(('add', plot_module))

            #if cell_module is None:
            #    cell_module = PlotPipelineHelper.find_module_by_name(pipeline, "VisItCell")

            if cell_module is None:
                #cell_desc = reg.get_descriptor_by_name('gov.lbl.visit', "VisItCell")
                #cell_module = controller.create_module_from_descriptor(cell_desc)
                #ops.append(('add', cell_module))
                cell_module = plot_module

                if issubclass(var_modules[0].module_descriptor.module,
                              CDMSVariable):
                    conn = controller.create_connection(
                        var_module, 'self', plot_module, 'variable')
                else:
                    conn = controller.create_connection(
                        var_module, 'self', cell_module, 'variable')
                ops.append(('add', conn))
                #print 'connection source id is ', conn.sourceId
                #print 'connection dest id is ', conn.destinationId

                loc_module = controller.create_module_from_descriptor(
                    reg.get_descriptor_by_name(
                        'edu.utah.sci.vistrails.spreadsheet', 'CellLocation'))
                functions = controller.create_functions(
                    loc_module, [('Row', [str(row + 1)]),
                                 ('Column', [str(col + 1)])])
                for f in functions:
                    loc_module.add_function(f)

                loc_conn = controller.create_connection(
                    loc_module, 'self', cell_module, 'Location')
                ops.extend([('add', loc_module), ('add', loc_conn)])

                type_of_plot = str(plot_gm)
                param_module = controller.create_module_from_descriptor(
                    reg.get_descriptor_by_name('gov.lbl.visit', 'VisItParams'))

                functions = controller.create_functions(
                    param_module, [('renderType', [type_of_plot])])
                for f in functions:
                    param_module.add_function(f)

                param_conn = controller.create_connection(
                    param_module, 'self', plot_module, 'visitparams')
                ops.extend([('add', param_module), ('add', param_conn)])

            # Create connection between the cell and the representation
            #conn = controller.create_connection(plot_module, 'self',
            #                                    cell_module, 'representation')

            # Add the connection to the pipeline operations
            #ops.append(('add', conn))

        action = core.db.action.create_action(ops)
        controller.change_selected_version(version)
        controller.add_new_action(action)
        controller.perform_action(action)
        return action
Exemplo n.º 49
0
def executeWorkflow():
    import api
    controller = api.get_current_controller()
    controller.execute_current_workflow()
Exemplo n.º 50
0
    def __init__(self, mid, **args):
        import api
        PersistentVisualizationModule.__init__(self, mid, **args)
        self.primaryInputPorts = ['volume', 'contours']

        self.addConfigurableLevelingFunction('colorScale',
                                             'C',
                                             label='Colormap Scale',
                                             units='data',
                                             setLevel=self.scaleColormap,
                                             getLevel=self.getDataRangeBounds,
                                             layerDependent=True,
                                             adjustRangeInput=0,
                                             group=ConfigGroup.Color)
        self.addConfigurableLevelingFunction('opacity',
                                             'O',
                                             label='Slice Plane Opacity',
                                             rangeBounds=[0.0, 1.0],
                                             setLevel=self.setOpacity,
                                             activeBound='min',
                                             getLevel=self.getOpacity,
                                             isDataValue=False,
                                             layerDependent=True,
                                             bound=False,
                                             group=ConfigGroup.Rendering)
        self.addConfigurableLevelingFunction('zScale',
                                             'z',
                                             label='Vertical Scale',
                                             setLevel=self.setZScale,
                                             activeBound='max',
                                             getLevel=self.getScaleBounds,
                                             windowing=False,
                                             sensitivity=(10.0, 10.0),
                                             initRange=[2.0, 2.0, 1],
                                             group=ConfigGroup.Display)
        self.addConfigurableLevelingFunction('contourDensity',
                                             'g',
                                             label='Contour Density',
                                             activeBound='max',
                                             setLevel=self.setContourDensity,
                                             getLevel=self.getContourDensity,
                                             layerDependent=True,
                                             windowing=False,
                                             rangeBounds=[3.0, 30.0, 1],
                                             bound=False,
                                             isValid=self.hasContours,
                                             group=ConfigGroup.Rendering)
        self.addConfigurableLevelingFunction(
            'contourColorScale',
            'S',
            label='Contour Colormap Scale',
            units='data',
            setLevel=self.scaleContourColormap,
            getLevel=lambda: self.getDataRangeBounds(1),
            layerDependent=True,
            adjustRangeInput=1,
            isValid=self.hasContours,
            group=ConfigGroup.Color)
        self.addConfigurableLevelingFunction(
            'coastlines_Line',
            'm0',
            label='Coastline Line',
            setLevel=self.setBasemapCoastlineLineSpecs,
            getLevel=self.getBasemapCoastlineLineSpecs,
            sliderLabels=['Thickness', 'Density'],
            layerDependent=False,
            rangeBounds=[0.0, 3.49],
            initRange=[1.0, 1.0, 1],
            group=ConfigGroup.BaseMap)
        self.addConfigurableLevelingFunction(
            'countries_Line',
            'm1',
            label='Countries Line',
            setLevel=self.setBasemapCountriesLineSpecs,
            getLevel=self.getBasemapCountriesLineSpecs,
            sliderLabels=['Thickness', 'Density'],
            layerDependent=False,
            rangeBounds=[0.0, 3.49],
            initRange=[0.0, 1.0, 0],
            group=ConfigGroup.BaseMap)
        self.addConfigurableLevelingFunction(
            'states_Line',
            'm2',
            label='States Line',
            setLevel=self.setBasemapStatesLineSpecs,
            getLevel=self.getBasemapStatesLineSpecs,
            sliderLabels=['Thickness', 'Density'],
            layerDependent=False,
            rangeBounds=[0.0, 3.49],
            initRange=[0.0, 1.0, 0],
            group=ConfigGroup.BaseMap)
        self.addConfigurableLevelingFunction(
            'lakes_Line',
            'm3',
            label='Lakes Line',
            setLevel=self.setBasemapLakesLineSpecs,
            getLevel=self.getBasemapLakesLineSpecs,
            sliderLabels=['Thickness', 'Density'],
            layerDependent=False,
            rangeBounds=[0.0, 3.49],
            initRange=[0.0, 1.0, 0],
            group=ConfigGroup.BaseMap)
        self.addUVCDATConfigGuiFunction(
            'contourColormap',
            ColormapConfigurationDialog,
            'K',
            label='Choose Contour Colormap',
            setValue=lambda data: self.setColormap(data, 1),
            getValue=lambda: self.getColormap(1),
            layerDependent=True,
            isValid=self.hasContours,
            group=ConfigGroup.Color)
        self.sliceOutputShape = args.get('slice_shape', [100, 50])
        self.polygonActor = None
        self.opacity = [1.0, 1.0]
        self.iOrientation = 0
        self.updatingPlacement = False
        self.isSlicing = False
        self.planeWidgetX = None
        self.planeWidgetY = None
        self.planeWidgetZ = None
        self.opacityUpdateCount = 0
        self.generateContours = False
        self.contourLineActors = {}
        self.contourLineMapperer = None
        self.shapefilePolylineActors = {}
        self.basemapLineSpecs = {}
        self.contours = None
        self.NumContours = 10.0
        self.showOutlineMap = True
        try:
            controller = api.get_current_controller()
            #            print " Volume Slicer init, id = %x " % id(self)
            VolumeSlicerModules[mid] = self
        except api.NoVistrail:
            pass
Exemplo n.º 51
0
def updateScene():
    import api
    controller = api.get_current_controller()
    controller.current_pipeline_view.setupScene(controller.current_pipeline)
Exemplo n.º 52
0
    def setupSaveConfigurations():
        import api

        ctrl = api.get_current_controller()
        scene = ctrl.current_pipeline_view
        scene.connect(scene, SIGNAL("moduleSelected"), PVClimateConfigurationWidget.saveConfigurations)
Exemplo n.º 53
0
    def push_vistrail_to_repository(self, branching=False):
        """ uploads current VisTrail to web repository """

        self._repository_status['details'] = "Pushing to repository..."
        self._push_button.setEnabled(False)
        self._branch_button.setEnabled(False)
        self.update_push_information()
        try:
            # create temp file
            self.directory = tempfile.mkdtemp(prefix='vt_tmp')
            (fd, filename) = tempfile.mkstemp(suffix='.vt',
                                              prefix='vt_tmp',
                                              dir=self.directory)
            os.close(fd)

            # writing tmp vt and switching back to orginal vt
            locator = ZIPFileLocator(filename)
            controller = api.get_current_controller()
            tmp_controller = VistrailController()
            tmp_controller.set_vistrail(controller.vistrail.do_copy(), locator)
            tmp_controller.changed = True
            tmp_controller.write_vistrail(locator)

            # check if this vt is from the repository
            if controller.vistrail.get_annotation('repository_vt_id'):
                repository_vt_id = controller.vistrail.get_annotation(
                    'repository_vt_id').value
            else:
                repository_vt_id = -1

            # upload vistrail temp file to repository
            register_openers(cookiejar=self.dialog.cookiejar)
            project = self.serverCombo.itemData(
                self.serverCombo.currentIndex()).toList()[0].toString()
            if project == "Default": project = ""

            params = {'vistrail_file': open(filename, 'rb'),
                      'action': 'upload',
                      'name': controller.locator.short_name,
                      'repository_vt_id': repository_vt_id if not branching else -1,
                      'is_runnable': not bool(len(self.unsupported_packages)+ \
                                              len(self.local_data_modules)),
                      'vt_id': 0,
                      'branched_from': "" if not branching else repository_vt_id,
                      'project': project,
                      'everyone_can_view': self.perm_view.checkState(),
                      'everyone_can_edit': self.perm_edit.checkState(),
                      'everyone_can_download': self.perm_download.checkState()
                     }

            upload_url = "%s/vistrails/remote_upload/" % \
                    self.config.webRepositoryURL

            datagen, headers = multipart_encode(params)
            request = urllib2.Request(upload_url, datagen, headers)
            result = urllib2.urlopen(request)
            updated_response = result.read()

            os.unlink(filename)

            if updated_response[:6] == "upload":
                # No update, just upload
                if result.code != 200:
                    self._repository_status['details'] = \
                            "Push to repository failed"
                else:
                    repository_vt_id = int(updated_response[8:])
                    controller.vistrail.set_annotation('repository_vt_id',
                                                       repository_vt_id)
                    controller.vistrail.set_annotation(
                        'repository_creator', self.dialog.loginUser.text())
                    # ensure that the annotations get saved
                    controller.set_changed(True)
                    self._repository_status['details'] = \
                            "Push to repository was successful"
            else:
                # update, load updated vistrail
                if result.code != 200:
                    self._repository_status['details'] = "Update Failed"
                else:
                    debug.log("getting version from web")
                    # request file to download
                    download_url = "%s/vistrails/download/%s/" % \
                            (self.config.webRepositoryURL, updated_response)

                    request = urllib2.Request(download_url)
                    result = urllib2.urlopen(request)
                    updated_file = result.read()

                    # create temp file of updated vistrail
                    self.directory = tempfile.mkdtemp(prefix='vt_tmp')
                    (fd,
                     updated_filename) = tempfile.mkstemp(suffix='.vtl',
                                                          prefix='vtl_tmp',
                                                          dir=self.directory)
                    os.close(fd)
                    updated_vt = open(updated_filename, 'w')
                    updated_vt.write(updated_file)
                    updated_vt.close()

                    # switch vistrails to updated one
                    controller = api.get_current_controller()

                    updated_locator = FileLocator(updated_filename)

                    (up_vistrail, abstractions, thumbnails, mashups) = \
                            load_vistrail(updated_locator)

                    controller.set_vistrail(up_vistrail,
                                            controller.vistrail.locator,
                                            abstractions, thumbnails, mashups)

                    # update version tree drawing
                    controller.recompute_terse_graph()
                    controller.invalidate_version_tree()

                    os.remove(updated_filename)
                    os.remove(updated_filename[:-1])
                    os.rmdir(self.directory)

                    self._repository_status['details'] = \
                            "Update to repository was successful"

        except Exception, e:
            debug.critical(str(e))
            self._repository_status['details'] = "An error occurred"
Exemplo n.º 54
0
    def build_plot_pipeline_action(controller, version, var_modules, plots,row, col, template=None):
        #// @todo: want to make sure that nothing changes if var_module
        #// or plot_module do not change

        # Get controller
        if controller is None:
            controller = api.get_current_controller()
            version = 0L

        # Get module registry
        reg = get_module_registry()
        ops = []
        cell_module = None

        #// First get the pipeline
        pipeline = controller.vistrail.getPipeline(version)

        #// @todo: Add support for multiple variables per plot
        #// Use only the first var module for now
        var_module = var_modules[0]

        #// @Aashish: As of now, very first time var module is being added to the pipeline by the project controller
        #// but second time on the same cell, it gets removed and hence we needed to add var module again to pipeline.
        #// I need to put this code under try catch because as of now looking for an id that does not exists
        #// results in exception.
        try:
            temp_var_module = pipeline.get_module_by_id(var_module.id)
        except KeyError:
            temp_var_module = None

        if temp_var_module is not None:
            var_module = temp_var_module
        else:
            # This time we need to add var module to the pipeline
            ops.append(('add', var_module))

        for plot in plots:
            plot_gm = plot.name

            #// Create plot module from the descriptor
            #// Is there a better way? I looked around and found none
            import re
            plotUsableName = re.sub(r'\s', '', plot_gm)
            plot_module = PlotPipelineHelper.find_module_by_name(pipeline, plotUsableName)
            if plot_module is not None:
                continue

            plot_descriptor = reg.get_descriptor_by_name('com.kitware.pvclimate', plotUsableName)

            #// @Aashish: Looks like the pipeline is using the cached representation
            plot_module = controller.create_module_from_descriptor(plot_descriptor)
            ops.append(('add', plot_module))

            #// @Aashish: This is no longer required as of this commit
            #// e13bb034ceb302afe3aad3caf20153e1525586db
            #// I am not sure though why we still need to add plot module
            #ops.append(('add', var_modules[0]))

            #// Create cell - representation linkage
            #// Check to see if a cell already exits, if yes then set the input (representation on it) or else
            #// create a new one and then set the representation on it.
            if cell_module is None:
                cell_module = PlotPipelineHelper.find_module_by_name(pipeline, "PVGenericCell")

            #// If cell module is None, then create a new one
            if cell_module is None:
                cell_desc = reg.get_descriptor_by_name('com.kitware.pvclimate', "PVGenericCell")
                cell_module = controller.create_module_from_descriptor(cell_desc)
                ops.append(('add', cell_module))

                #// Create a connection between the cell and the variable
                #// @Aashish: I am expecting that every time we drop a variable, we will get a
                #// pipeline that does not have modules from the previous execution. I need to verify
                #// this but for now this assumption seems to hold.
                
                oport = CDMSPipelineHelper.get_output_port_name(
                        var_module.module_descriptor.module)
                conn = controller.create_connection(var_module, oport,
                                                    plot_module, 'cdms_variable')
                ops.append(('add', conn))

                loc_module = controller.create_module_from_descriptor(
                    reg.get_descriptor_by_name('edu.utah.sci.vistrails.spreadsheet',
                                               'CellLocation'))
                functions = controller.create_functions(loc_module,
                    [('Row', [str(row+1)]), ('Column', [str(col+1)])])
                for f in functions:
                    loc_module.add_function(f)
                loc_conn = controller.create_connection(loc_module, 'self',
                                                        cell_module, 'Location')
                ops.extend([('add', loc_module),
                            ('add', loc_conn)])

            #// Create connection between the cell and the representation
            conn = controller.create_connection(plot_module, 'self',
                                                cell_module, 'representation')

            #// Add the connection to the pipeline operations
            ops.append(('add', conn))

        action = core.db.action.create_action(ops)
        controller.change_selected_version(version)
        controller.add_new_action(action)
        controller.perform_action(action)
        return action
Exemplo n.º 55
0
 def plot(self, var1, var2):
     """ Connect / disconnect the necessary ports and exec workflow -> plot
     into the cell
     """
     self.currentWorkflow.updatePorts(var1, var2)
     api.get_current_controller().execute_current_workflow()
Exemplo n.º 56
0
 def plot(self, var1, var2):
     """ Connect / disconnect the necessary ports and exec workflow -> plot
     into the cell
     """
     self.currentWorkflow.updatePorts(var1, var2)
     api.get_current_controller().execute_current_workflow()