Пример #1
0
 def checkedProject(self, b):
     txt = str(b.text())
     if b.checkState(
     ) == QtCore.Qt.Unchecked:  # unchecked because when it gets here state hasn't changed yet
         if not txt in self.it.projects:
             self.it.projects.append(txt)
             proj = self.root.get_current_project_controller().name
             if txt == str(proj):
                 self.it.setHidden(False)
             _app = get_vistrails_application()
             controller = _app.uvcdatWindow.get_project_controller_by_name(
                 txt)
             controller.add_defined_variable(self.it.cdmsVar)
     else:
         if txt in self.it.projects:
             bsum = 0
             for a in self.b.buttons():
                 bsum += int(a.checkState())
             if bsum != QtCore.Qt.Checked:  # ok ifwe have morethan one (one would the one we want to remove)
                 self.it.projects.remove(txt)
                 proj = self.root.get_current_project_controller().name
                 if txt == str(proj):
                     self.it.setHidden(True)
                 _app = get_vistrails_application()
                 controller = _app.uvcdatWindow.get_project_controller_by_name(
                     txt)
                 controller.remove_defined_variable(self.it.varName)
Пример #2
0
def switch_to_pipeline_view():
    """switch_to_pipeline_view():

    Changes current viewing mode to pipeline view in the builder window.

    """
    get_vistrails_application().builderWindow.qactions['pipeline'].trigger()
Пример #3
0
    def clicked_on_login(self):
        """
        Attempts to log into web repository
        stores auth cookie for session
        """
        from gui.application import get_vistrails_application

        params = urllib.urlencode({
            'username': self.dialog.loginUser.text(),
            'password': self.loginPassword.text()
        })
        self.dialog.cookiejar = cookielib.CookieJar()

        # set base url used for cookie
        self.dialog.cookie_url = self.config.webRepositoryURL

        self.loginOpener = urllib2.build_opener(
            urllib2.HTTPCookieProcessor(self.dialog.cookiejar))

        # FIXME doesn't use https
        login_url = "%s/account/login/" % self.config.webRepositoryURL
        request = urllib2.Request(login_url, params)
        url = self.loginOpener.open(request)

        # login failed
        if not 'sessionid' in [
                cookie.name for cookie in self.dialog.cookiejar
        ]:
            self._login_status = "incorrect username or password"

        else:  # login successful
            self._login_status = "login successful"

            self.dialog.loginUser.setEnabled(False)
            self.loginPassword.setEnabled(False)
            self._login_button.setEnabled(False)
            self.saveLogin.setEnabled(False)
            self._logout_button.setEnabled(True)

            # add association between VisTrails user and web repository user
            if self.saveLogin.checkState():
                if not (self.config.check('webRepositoryLogin')
                        and self.config.webRepositoryLogin
                        == self.dialog.loginUser.text()):
                    self.config.webRepositoryLogin = str(
                        self.dialog.loginUser.text())
                    pers_config = get_vistrails_persistent_configuration()
                    pers_config.webRepositoryLogin = self.config.webRepositoryLogin
                    get_vistrails_application().save_configuration()

            # remove assiciation between VisTrails user and web repository user
            else:
                if self.config.check('webRepositoryLogin'
                                     ) and self.config.webRepositoryLogin:
                    self.config.webRepositoryLogin = ""
                    pers_config = get_vistrails_persistent_configuration()
                    pers_config.webRepositoryLogin = ""
                    get_vistrails_application().save_configuration()

        self.show_login_information()
Пример #4
0
def switch_to_query_view():
    """switch_to_query_view():

    Changes current viewing mode to query view in the builder window.

    """
    get_vistrails_application().builderWindow.qactions['search'].trigger()
def switch_to_query_view():
    """switch_to_query_view():

    Changes current viewing mode to query view in the builder window.

    """
    get_vistrails_application().builderWindow.qactions['search'].trigger()
def switch_to_pipeline_view():
    """switch_to_pipeline_view():

    Changes current viewing mode to pipeline view in the builder window.

    """
    get_vistrails_application().builderWindow.qactions['pipeline'].trigger()
 def copyAll(self):
     """ copy selected message to clipboard """
     texts = []
     for i in range(self.list.count()):
         texts.append(str(self.list.item(i).data(32).toString()))
     text = '\n'.join(texts)
     get_vistrails_application().clipboard().setText(text)
Пример #8
0
 def copyAll(self):
     """ copy selected message to clipboard """
     texts = []
     for i in range(self.list.count()):
         texts.append(str(self.list.item(i).data(32).toString()))
     text = '\n'.join(texts)
     get_vistrails_application().clipboard().setText(text)
    def clicked_on_login(self):
        """
        Attempts to log into web repository
        stores auth cookie for session
        """
        from gui.application import get_vistrails_application

        params = urllib.urlencode({'username':self.dialog.loginUser.text(),
                                   'password':self.loginPassword.text()})
        self.dialog.cookiejar = cookielib.CookieJar()

        # set base url used for cookie
        self.dialog.cookie_url = self.config.webRepositoryURL

        self.loginOpener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.dialog.cookiejar))

        # FIXME doesn't use https
        login_url = "%s/account/login/" % self.config.webRepositoryURL
        request = urllib2.Request(login_url, params)
        url = self.loginOpener.open(request)

        # login failed
        if not 'sessionid' in [cookie.name for cookie in self.dialog.cookiejar]:
            self._login_status = "incorrect username or password"

        else: # login successful
            self._login_status = "login successful"

            self.dialog.loginUser.setEnabled(False)
            self.loginPassword.setEnabled(False)
            self._login_button.setEnabled(False)
            self.saveLogin.setEnabled(False)
            self._logout_button.setEnabled(True)

            # add association between VisTrails user and web repository user
            if self.saveLogin.checkState():
                if not (self.config.check('webRepositoryLogin') and self.config.webRepositoryLogin == self.dialog.loginUser.text()):
                    self.config.webRepositoryLogin = str(self.dialog.loginUser.text())
                    pers_config = get_vistrails_persistent_configuration()
                    pers_config.webRepositoryLogin = self.config.webRepositoryLogin
                    get_vistrails_application().save_configuration()

            # remove assiciation between VisTrails user and web repository user
            else:
                if self.config.check('webRepositoryLogin') and self.config.webRepositoryLogin:
                    self.config.webRepositoryLogin = ""
                    pers_config = get_vistrails_persistent_configuration()
                    pers_config.webRepositoryLogin = ""
                    get_vistrails_application().save_configuration()

        self.show_login_information()
Пример #10
0
def start_uvcdat_application(optionsDict):
    """Initializes the application singleton."""
    VistrailsApplication = get_vistrails_application()
    if VistrailsApplication:
        debug.critical("Application already started.")
        return
    hw_role = optionsDict.get( "hw_role", 'global')
    spawn = optionsDict.get( "spawn", True )
    isClient = ( hw_role == 'hw_client' )
    VistrailsApplication = vtDV3DApplicationSingleton( isClient )
    set_vistrails_application( VistrailsApplication )
    if VistrailsApplication.is_running():
        debug.critical("Found another instance of VisTrails running")
        msg = str(sys.argv[1:])
        debug.critical("Will send parameters to main instance %s" % msg)
        res = VistrailsApplication.send_message(msg)
        if res:
            sys.exit(0)
        else:
            sys.exit(1)
    try:
        check_all_vistrails_requirements()
    except MissingRequirement, e:
        msg = ("VisTrails requires %s to properly run.\n" %
               e.requirement)
        debug.critical("Missing requirement", msg)
        sys.exit(1)
Пример #11
0
 def write(self, s):
     """write(s) -> None
     adds the string s to the message list and displays it
     """
     # adds the string s to the list and
     s = str(s).strip()
     msgs = s.split('\n')
     text = msgs[3] if len(msgs) > 2 else ''
     item = QtGui.QListWidgetItem(text)
     item.setData(32, s)
     item.setFlags(item.flags() & ~QtCore.Qt.ItemIsEditable)
     self.list.addItem(item)
     if msgs[0] == "INFO":
         item.setForeground(QtGui.QBrush(CurrentTheme.DEBUG_INFO_COLOR))
         self.list.setItemHidden(item, not self.infoFilter.isChecked())
     elif msgs[0] == "WARNING":
         item.setForeground(QtGui.QBrush(CurrentTheme.DEBUG_WARNING_COLOR))
         self.list.setItemHidden(item, not self.warningFilter.isChecked())
     elif msgs[0] == "CRITICAL":
         item.setForeground(QtGui.QBrush(CurrentTheme.DEBUG_CRITICAL_COLOR))
         self.list.setItemHidden(item, not self.criticalFilter.isChecked())
     if not get_vistrails_configuration().noDebugPopups:
         if self.isVisible() and not \
           getattr(get_vistrails_configuration(),'alwaysShowDebugPopup',False):
             self.raise_()
             self.activateWindow()
             modal = get_vistrails_application().activeModalWidget()
             if modal:
                 # need to beat modal window
                 self.showMessageBox(item)
         else:
             self.showMessageBox(item)
Пример #12
0
    def addAxAttribute(self):
        axName = str(self.axisComboBox.currentText())
        ax = self.var.getAxis(self.var.getAxisIndex(axName))
        newName = str(self.newAxAttributeName.text()).strip()
        if len(newName) == 0:
            return
        atts = sorted(list(set((ax.attributes.keys() + [
            'id',
        ]))))
        if newName in atts:
            return
        setattr(ax, newName, "newAttribute")
        atts = sorted(list(set((ax.attributes.keys() + [
            'id',
        ]))))
        for i in range(len(atts)):
            if atts[i] != str(self.axComboBox.itemText(i)):
                self.axComboBox.insertItem(i, newName)
                break
        self.axComboBox.setCurrentIndex(i)
        self.root.record(
            "## Adding a new attribute to axis %s of variable: %s" %
            (ax.id, self.var.id))
        self.root.record("ax = %s.getAxis(%s.getAxisIndex('%s'))" %
                         (self.var.id, self.var.id, axName))
        self.root.record("ax.%s = 'newAttribute'" % (newName))

        #provenance calls
        _app = get_vistrails_application()
        controller = _app.uvcdatWindow.get_current_project_controller()
        controller.change_defined_variable_axis_attribute(
            self.var.id, axName, newName, "newAttribute")
Пример #13
0
    def modAxAttribute(self):
        axName = str(self.axisComboBox.currentText())
        ax = self.var.getAxis(self.var.getAxisIndex(axName))
        attName = str(self.axComboBox.currentText())
        try:
            attValue = eval(str(self.axAttributeValue.text()).strip())
        except:
            attValue = str(self.axAttributeValue.text()).strip()

        setattr(ax, attName, attValue)
        tit = str(self.title.text()).split("(Modified)")[0]
        self.title.setText(tit)
        self.parent.setWindowTitle(tit)

        self.root.record("## Modify attribute %s on axis %s of variable %s" %
                         (attName, ax.id, self.var.id))
        self.root.record("ax = %s.getAxis(%s.getAxisIndex('%s'))" %
                         (self.var.id, self.var.id, axName))
        self.root.record("ax.%s = %s" % (attName, repr(attValue)))

        #provenance calls
        _app = get_vistrails_application()
        controller = _app.uvcdatWindow.get_current_project_controller()
        controller.change_defined_variable_axis_attribute(
            self.var.id, axName, attName, attValue)
Пример #14
0
    def modVarAttribute(self):
        attName = str(self.varComboBox.currentText())
        try:
            attValue = eval(str(self.varAttributeValue.text()).strip())
        except:
            attValue = str(self.varAttributeValue.text()).strip()
        #in case the attribute is the variable id, storing the original one to
        #change it later in vistrails
        var_id = self.var.id
        setattr(self.var, attName, attValue)
        tit = str(self.title.text()).split("(Modified)")[0]
        self.title.setText(tit)
        self.parent.setWindowTitle(tit)
        self.root.record("## Modify attribute %s on variable %s" %
                         (attName, self.var.id))
        self.root.record("%s.%s = %s" % (self.var.id, attName, repr(attValue)))

        self.root.dockVariable.widget().updateVars()

        #provenance calls
        _app = get_vistrails_application()
        controller = _app.uvcdatWindow.get_current_project_controller()
        controller.change_defined_variable_attribute(var_id, attName, attValue)
        #if attName is id we need also to rename the var in the project controller
        if attName == 'id':
            controller.rename_defined_variable(var_id, attValue)
Пример #15
0
    def addVarAttribute(self):
        newName = str(self.newVarAttributeName.text()).strip()
        if len(newName) == 0:
            return
        atts = sorted(list(set((self.var.listattributes() + [
            'id',
        ]))))
        if newName in atts:
            return
        setattr(self.var, newName, "newAttribute")
        atts = sorted(list(set((self.var.listattributes() + [
            'id',
        ]))))
        self.root.record("## Adding a new attribute to variable: %s" %
                         self.var.id)
        self.root.record("%s.%s = 'newAttribute'" % (self.var.id, newName))

        for i in range(len(atts)):
            if atts[i] != str(self.varComboBox.itemText(i)):
                self.varComboBox.insertItem(i, newName)
                break
        self.varComboBox.setCurrentIndex(i)

        #provenance calls
        _app = get_vistrails_application()
        controller = _app.uvcdatWindow.get_current_project_controller()
        controller.change_defined_variable_attribute(self.var.id, newName,
                                                     "newAttribute")
Пример #16
0
 def modVarAttribute(self):
     attName = str(self.varComboBox.currentText())
     try:
         attValue=eval(str(self.varAttributeValue.text()).strip())
     except:
         attValue=str(self.varAttributeValue.text()).strip()
     #in case the attribute is the variable id, storing the original one to
     #change it later in vistrails
     var_id = self.var.id
     setattr(self.var,attName,attValue)
     tit = str(self.title.text()).split("(Modified)")[0]
     self.title.setText(tit)
     self.parent.setWindowTitle(tit)
     self.root.record("## Modify attribute %s on variable %s" % (attName,self.var.id))
     self.root.record("%s.%s = %s" % (self.var.id,attName,repr(attValue)))
     
     self.root.dockVariable.widget().updateVars()
     
     #provenance calls
     _app = get_vistrails_application()
     controller = _app.uvcdatWindow.get_current_project_controller()
     controller.change_defined_variable_attribute(var_id, attName, attValue)
     #if attName is id we need also to rename the var in the project controller
     if attName == 'id':
         controller.rename_defined_variable(var_id, attValue)
 def write(self, s):
     """write(s) -> None
     adds the string s to the message list and displays it
     """
     # adds the string s to the list and 
     s = str(s).strip()
     msgs = s.split('\n')
     text = msgs[3] if len(msgs)>2 else ''
     item = QtGui.QListWidgetItem(text)
     item.setData(32, s)
     item.setFlags(item.flags()&~QtCore.Qt.ItemIsEditable)
     self.list.addItem(item)
     if msgs[0] == "INFO":
         item.setForeground(QtGui.QBrush(CurrentTheme.DEBUG_INFO_COLOR))
         self.list.setItemHidden(item, not self.infoFilter.isChecked())
     elif msgs[0] == "WARNING":
         item.setForeground(QtGui.QBrush(CurrentTheme.DEBUG_WARNING_COLOR))
         self.list.setItemHidden(item, not self.warningFilter.isChecked())
     elif msgs[0] == "CRITICAL":
         item.setForeground(QtGui.QBrush(CurrentTheme.DEBUG_CRITICAL_COLOR))
         self.list.setItemHidden(item, not self.criticalFilter.isChecked())
     if self.isVisible() and not \
       getattr(get_vistrails_configuration(),'alwaysShowDebugPopup',False):
         self.raise_()
         self.activateWindow()
         modal = get_vistrails_application().activeModalWidget()
         if modal:
             # need to beat modal window
             self.showMessageBox(item)
     else:
         self.showMessageBox(item)
Пример #18
0
    def applyEditsClicked(self):
        varname = self.varEditArea.widget().var.id
        self.getUpdatedVar(varname)

        _app = get_vistrails_application()
        controller = _app.uvcdatWindow.get_current_project_controller()

        controller.variableEdited(varname)
Пример #19
0
 def applyEditsClicked(self):
     varname = self.varEditArea.widget().var.id
     self.getUpdatedVar(varname)
     
     _app = get_vistrails_application()
     controller = _app.uvcdatWindow.get_current_project_controller()
     
     controller.variableEdited(varname)
Пример #20
0
def executeVistrail( *args, **kwargs ):
    disable_lion_restore()
    check_pyqt4()
    optionsDict = kwargs.get( 'options', None )

    try:
        v = start_uvcdat_application( optionsDict )
        if v != 0:
            app = get_vistrails_application()
            if app:
                app.finishSession()
            sys.exit(v)
        app = get_vistrails_application()
    except SystemExit, e:
        app = get_vistrails_application()
        if app:
            app.finishSession()
        sys.exit(e)
Пример #21
0
    def regridFunc(self, regridTool, regridMethod):
        """
        Run the regrid method from selected variables and store on the 
        command line
        @param regridTool ESMF, LibCF, Regrid2
        @param regridMethod Conserve, Linear, Patch
        """
        import systemCommands
        import __main__
        from gui.application import get_vistrails_application
        from api import get_current_project_controller
        _app = get_vistrails_application()

        QText = QtGui.QTextEdit()
        QLine = QtGui.QLineEdit()
        prj_controller = get_current_project_controller()

        useVars=self.root.dockVariable.widget().getSelectedDefinedVariables()
        sV = self.root.dockVariable.widget().varList.selectedItems()

        if len(useVars) > 2:
            print "\nOnly two variables can be selected to regrid"
            return

        argsStr = "regridTool = %s, regridMethod = %s" % (regridTool, regridMethod)
        # Get the variables
        vSrc = sV[0]
        vDst = sV[1]
        vSrcName = vSrc.varName
        vDstName = vDst.varName
        useSrc = useVars.pop(0)
        useDst = useVars.pop(0)
        varname = "regrid_%s_%s" % (vSrcName, vDstName)
#        varname = "regridVar"
        rhsCommand = "%s.regrid(%s.getGrid(), %s)" % \
                          (vSrcName, vDstName, argsStr)
        pycommand = "%s = %s" % (varname, rhsCommand)
        QLine.setText(QtCore.QString(pycommand.strip()))
        QText.setTextColor(QtGui.QColor(0,0,0))
        commandLine = ">>> " + pycommand + "\n"
        QText.insertPlainText(commandLine)
        systemCommands.commandHistory.append(pycommand)
        systemCommands.command_num = 0

        exec( "import MV2,genutil,cdms2,vcs,cdutil,numpy", __main__.__dict__ )
        regridVar = eval(rhsCommand, __main__.__dict__)
        res = self.root.stick_main_dict_into_defvar(None)
        regridVar.id = varname

        _app.uvcdatWindow.dockVariable.widget().addVariable(regridVar)

        self.root.record("## Regrid command sent from PCMDITools->Regridding->%s>%s" % \
                                (regridTool, regridMethod))
        self.root.record(pycommand)
        prj_controller.process_typed_calculator_command(varname, rhsCommand)
        prj_controller.calculator_command(sV, "REGRID", varname, rhsCommand.strip())
        QLine.setFocus()
 def test_new_vistrail_button_states(self):
     assert get_vistrails_application().builderWindow.qactions['newVistrail'].isEnabled()
     assert not get_vistrails_application().builderWindow.qactions['closeVistrail'].isEnabled()
     assert not get_vistrails_application().builderWindow.qactions['saveFile'].isEnabled()
     assert not get_vistrails_application().builderWindow.qactions['saveFileAs'].isEnabled()
     view = new_vistrail()
     assert get_vistrails_application().builderWindow.qactions['newVistrail'].isEnabled()
     assert get_vistrails_application().builderWindow.qactions['closeVistrail'].isEnabled()
     self.assertEqual(get_vistrails_application().builderWindow.qactions['saveFile'].isEnabled(),
                      view.has_changes())
     assert get_vistrails_application().builderWindow.qactions['saveFileAs'].isEnabled()
Пример #23
0
 def checkBounds( self, bounds, dataset ):
     from gui.application import get_vistrails_application
     values = sorted( self.axisValues )
     if ( bounds[0] < values[0] ) or ( bounds[1] > values[-1] ):
         bounds[0] = max( bounds[0], values[0]  )
         bounds[1] = min( bounds[1], values[-1] )
         parent = get_vistrails_application().uvcdatWindow.varProp.roiSelector
         if dataset == None: QtGui.QMessageBox.warning( parent, "UVCDAT Warning", "Selected bounds are out of range for the transient variable. Please reaccess this variable from the dataset.")
         else:               QtGui.QMessageBox.warning( parent, "UVCDAT Warning", "Selected bounds are out of range for the dataset.")
     return bounds
def get_current_vistrail_view():
    """get_current_vistrail():

    Returns the currently selected vistrail view.

    """
    view = get_vistrails_application().builderWindow.get_current_view()
    if view is None:
        raise NoVistrail
    return view    
Пример #25
0
 def connectSignals(self):
     if not self.connected:
         try:
             buildWin = get_vistrails_application().builderWindow
             buildWin.connect( buildWin.viewToolBar.executeAction(), QtCore.SIGNAL('triggered(bool)'), onExecute )
             buildWin.connect( buildWin.executeCurrentWorkflowAction, QtCore.SIGNAL('triggered(bool)'), onExecute )
             self.connected = True
             print " Hyperwall Manager connected to control signals "
         except:
             pass
Пример #26
0
def get_current_vistrail_view():
    """get_current_vistrail():

    Returns the currently selected vistrail view.

    """
    view = get_vistrails_application().builderWindow.get_current_view()
    if view is None:
        raise NoVistrail
    return view
def get_builder_window():
    """get_builder_window():

    returns the main VisTrails GUI window

    raises NoGUI.

    """
    try:
        return get_vistrails_application().builderWindow
    except AttributeError:
        raise NoGUI
def get_current_controller():
    """get_current_controller():

    returns the VistrailController of the currently selected vistrail.

    raises NoVistrail.

    """
    try:
        return get_vistrails_application().builderWindow.get_current_controller()
    except AttributeError:
        raise NoVistrail
Пример #29
0
 def connectSignals(self):
     if not self.connected:
         try:
             buildWin = get_vistrails_application().builderWindow
             buildWin.connect(buildWin.viewToolBar.executeAction(),
                              QtCore.SIGNAL('triggered(bool)'), onExecute)
             buildWin.connect(buildWin.executeCurrentWorkflowAction,
                              QtCore.SIGNAL('triggered(bool)'), onExecute)
             self.connected = True
             print " Hyperwall Manager connected to control signals "
         except:
             pass
 def uvcdatAutoExecuteActionTriggered(self, checked):
     """uvcdatAutoExecuteActionTriggered(checked: boolean) -> None 
     When the check state changes the configuration needs to be updated.
     
     """
     from core.configuration import get_vistrails_persistent_configuration,\
         get_vistrails_configuration
     from gui.application import get_vistrails_application
     _app = get_vistrails_application()
     get_vistrails_persistent_configuration().uvcdat.autoExecute = checked
     get_vistrails_configuration().uvcdat.autoExecute = checked
     _app.save_configuration()
Пример #31
0
    def uvcdatAutoExecuteActionTriggered(self, checked):
        """uvcdatAutoExecuteActionTriggered(checked: boolean) -> None
        When the check state changes the configuration needs to be updated.

        """
        from core.configuration import get_vistrails_persistent_configuration,\
            get_vistrails_configuration
        from gui.application import get_vistrails_application
        _app = get_vistrails_application()
        get_vistrails_persistent_configuration().uvcdat.autoExecute = checked
        get_vistrails_configuration().uvcdat.autoExecute = checked
        _app.save_configuration()
Пример #32
0
def get_builder_window():
    """get_builder_window():

    returns the main VisTrails GUI window

    raises NoGUI.

    """
    try:
        return get_vistrails_application().builderWindow
    except AttributeError:
        raise NoGUI
Пример #33
0
def get_current_controller():
    """get_current_controller():

    returns the VistrailController of the currently selected vistrail.

    raises NoVistrail.

    """
    try:
        return get_vistrails_application(
        ).builderWindow.get_current_controller()
    except AttributeError:
        raise NoVistrail
Пример #34
0
def getConfiguration( defaults ):
    from gui.application import get_vistrails_application
    app = get_vistrails_application()
    appConfig = app.temp_configuration if app else None
    dotVistrails = appConfig.dotVistrails if appConfig else os.path.expanduser("~/.vistrails/")
    datasetConfigFile = os.path.expanduser( os.path.join( dotVistrails, 'dv3d.cfg' )  )
    if not os.path.isfile( datasetConfigFile ):
        defaultConfigFile = os.path.join( resourcePath, 'dv3d.cfg' ) 
        assert os.path.isfile( defaultConfigFile ), "Error, default dv3d Config File does not exist at %s!" % defaultConfigFile
        shutil.copy( defaultConfigFile, appConfig.dotVistrails )            
    datasetConfig = ConfigParser.ConfigParser( defaults )
    datasetConfig.read( datasetConfigFile )  
    return datasetConfig, appConfig
Пример #35
0
 def getAxisValuesEvent(self):
     """ getAxisValuesEvent is called when the user selects 'Get Axis
      Values' from the axis button menu.  This method will create and
     define a new variable / tab with the axis' values
     """        
     varID = self.parent.getVar().id
     _app = get_vistrails_application()
     w=_app.uvcdatWindow.dockCalculator.widget()
     le=w.le
     axisVarid = varID +'_' + self.axis.id + '_axis'
     le.setText("cdmsFile=cdms2.open('%s')" % self.parent.cdmsFile.id)
     w.run_command()
     le.setText("%s = MV2.array(cdmsFile['%s'],axes=[cdmsFile['%s'],],id='%s')" % (axisVarid,self.axis.id,self.axis.id,axisVarid))
     w.run_command()
Пример #36
0
    def window_changed(self, old_window, new_window):
        # if window != self.current_window:
        #     print "NOT CURRENT WINDOW"
        #     self.current_window = window
        #     self.notify('controller_changed', window.get_controller())
        # else:
        #     print "CURRENT WINDOW"

        new_window = get_vistrails_application().activeWindow()
        if isinstance(new_window, QVistrailsWindow):
            if self.current_window != new_window:
                # print "CURRENT WINDOW CHANGED"
                self.current_window = new_window
                self.notify('controller_changed', new_window.get_controller())
 def window_changed(self, old_window, new_window):
     # if window != self.current_window:
     #     print "NOT CURRENT WINDOW"
     #     self.current_window = window
     #     self.notify('controller_changed', window.get_controller())
     # else:
     #     print "CURRENT WINDOW"
     
     new_window = get_vistrails_application().activeWindow()
     if isinstance(new_window, QVistrailsWindow):
         if self.current_window != new_window:
             # print "CURRENT WINDOW CHANGED"
             self.current_window = new_window
             self.notify('controller_changed', new_window.get_controller())
    def uvcdatMinimalThemeActionTriggered(self, checked):
        """uvcdatMinimalThemeActionTriggered(checked: boolean) -> None 
        When the check state changes the configuration needs to be updated.
        
        """

        from core.configuration import get_vistrails_persistent_configuration,\
            get_vistrails_configuration
        from gui.application import get_vistrails_application
        _app = get_vistrails_application()
        get_vistrails_persistent_configuration().uvcdat.theme = "Minimal"
        get_vistrails_configuration().uvcdat.theme = "Minimal"
        _app.save_configuration()
        self.uvcdat_show_changes_message()
Пример #39
0
    def uvcdatMinimalThemeActionTriggered(self, checked):
        """uvcdatMinimalThemeActionTriggered(checked: boolean) -> None
        When the check state changes the configuration needs to be updated.

        """

        from core.configuration import get_vistrails_persistent_configuration,\
            get_vistrails_configuration
        from gui.application import get_vistrails_application
        _app = get_vistrails_application()
        get_vistrails_persistent_configuration().uvcdat.theme = "Minimal"
        get_vistrails_configuration().uvcdat.theme = "Minimal"
        _app.save_configuration()
        self.uvcdat_show_changes_message()
Пример #40
0
 def checkedProject(self,b):
     txt = str(b.text())
     if b.checkState()==QtCore.Qt.Unchecked: # unchecked because when it gets here state hasn't changed yet
         if not txt in self.it.projects:
             self.it.projects.append(txt)
             proj = self.root.get_current_project_controller().name
             if txt == str(proj):
                 self.it.setHidden(False)
             _app = get_vistrails_application()
             controller = _app.uvcdatWindow.get_project_controller_by_name(txt)
             controller.add_defined_variable(self.it.cdmsVar)    
     else:
         if txt in self.it.projects:
             bsum=0
             for a in self.b.buttons():
                 bsum+=int(a.checkState())
             if bsum!=QtCore.Qt.Checked: # ok ifwe have morethan one (one would the one we want to remove)
                 self.it.projects.remove(txt)
                 proj = self.root.get_current_project_controller().name
                 if txt == str(proj):
                     self.it.setHidden(True)
                 _app = get_vistrails_application()
                 controller = _app.uvcdatWindow.get_project_controller_by_name(txt)
                 controller.remove_defined_variable(self.it.varName) 
Пример #41
0
def getConfiguration(defaults):
    from gui.application import get_vistrails_application
    app = get_vistrails_application()
    appConfig = app.temp_configuration if app else None
    dotVistrails = appConfig.dotVistrails if appConfig else os.path.expanduser(
        "~/.vistrails/")
    datasetConfigFile = os.path.expanduser(
        os.path.join(dotVistrails, 'dv3d.cfg'))
    if not os.path.isfile(datasetConfigFile):
        defaultConfigFile = os.path.join(resourcePath, 'dv3d.cfg')
        assert os.path.isfile(
            defaultConfigFile
        ), "Error, default dv3d Config File does not exist at %s!" % defaultConfigFile
        shutil.copy(defaultConfigFile, appConfig.dotVistrails)
    datasetConfig = ConfigParser.ConfigParser(defaults)
    datasetConfig.read(datasetConfigFile)
    return datasetConfig, appConfig
    def __init__(self, parent=None, f=QtCore.Qt.WindowFlags()):
        global _app
        QtGui.QMainWindow.__init__(self, parent, f)
        self.windows = []
        self.palette_containers = []
        self.current_window = None
        self.notifications = {}
        self.dbDefault = False

        # FIXME not the best way to assign the global
        _app = self

        self.init_palettes()
        self.create_menus()
        self.connect(get_vistrails_application(), 
                     QtCore.SIGNAL('focusChanged(QWidget*, QWidget*)'),
                     self.window_changed)
Пример #43
0
    def __init__(self, parent=None, f=QtCore.Qt.WindowFlags()):
        global _app
        QtGui.QMainWindow.__init__(self, parent, f)
        self.windows = []
        self.palette_containers = []
        self.current_window = None
        self.notifications = {}
        self.dbDefault = False

        # FIXME not the best way to assign the global
        _app = self

        self.init_palettes()
        self.create_menus()
        self.connect(get_vistrails_application(),
                     QtCore.SIGNAL('focusChanged(QWidget*, QWidget*)'),
                     self.window_changed)
Пример #44
0
 def test_new_vistrail_button_states(self):
     assert get_vistrails_application(
     ).builderWindow.qactions['newVistrail'].isEnabled()
     assert not get_vistrails_application(
     ).builderWindow.qactions['closeVistrail'].isEnabled()
     assert not get_vistrails_application(
     ).builderWindow.qactions['saveFile'].isEnabled()
     assert not get_vistrails_application(
     ).builderWindow.qactions['saveFileAs'].isEnabled()
     view = new_vistrail()
     assert get_vistrails_application(
     ).builderWindow.qactions['newVistrail'].isEnabled()
     assert get_vistrails_application(
     ).builderWindow.qactions['closeVistrail'].isEnabled()
     self.assertEqual(
         get_vistrails_application().builderWindow.qactions['saveFile'].
         isEnabled(), view.has_changes())
     assert get_vistrails_application(
     ).builderWindow.qactions['saveFileAs'].isEnabled()
Пример #45
0
    def show_provenance(self, sheetName, row, col):
        """show_provenance(sheetName: str, row: int, col: int)  -> None
        Will display pipeline for current item.
        """
        if sheetName not in self.sheet_to_item:
            return

        sheetItem = self.sheet_to_item[sheetName]
        if (row, col) not in sheetItem.pos_to_item:
            return

        from gui.application import get_vistrails_application
        _app = get_vistrails_application()
        _app.uvcdatWindow.showBuilderWindowActTriggered()

        item = sheetItem.pos_to_item[(row, col)]
        version = item.workflowVersion
        self.view.version_selected(version, True, double_click=True)
Пример #46
0
 def show_provenance(self, sheetName, row, col):
     """show_provenance(sheetName: str, row: int, col: int)  -> None
     Will display pipeline for current item.
     """
     if sheetName not in self.sheet_to_item:
         return
     
     sheetItem = self.sheet_to_item[sheetName]
     if (row, col) not in sheetItem.pos_to_item:
         return
     
     from gui.application import get_vistrails_application
     _app = get_vistrails_application()
     _app.uvcdatWindow.showBuilderWindowActTriggered()
     
     item = sheetItem.pos_to_item[(row, col)]
     version = item.workflowVersion
     self.view.version_selected(version, True, double_click=True)
Пример #47
0
    def delVarAttribute(self):
        newName = str(self.newVarAttributeName.text()).strip()
        if len(newName) == 0:
            return
        atts = self.var.listattributes()
        if not newName in atts:
            return
        delattr(self.var, newName)

        for i in range(self.varComboBox.count()):
            if str(self.varComboBox.itemText(i)) == newName:
                self.varComboBox.removeItem(i)
                break
        self.varComboBox.setCurrentIndex(0)
        #provenance calls
        _app = get_vistrails_application()
        controller = _app.uvcdatWindow.get_current_project_controller()
        controller.remove_defined_variable_attribute(self.var.id, newName)
Пример #48
0
    def delVarAttribute(self):
        newName=str(self.newVarAttributeName.text()).strip()
        if len(newName)==0:
            return
        atts = self.var.listattributes()
        if not newName in atts:
            return
        delattr(self.var,newName)

        for i in range(self.varComboBox.count()):
            if str(self.varComboBox.itemText(i)) == newName:
                self.varComboBox.removeItem(i)
                break
        self.varComboBox.setCurrentIndex(0)
        #provenance calls
        _app = get_vistrails_application()
        controller = _app.uvcdatWindow.get_current_project_controller()
        controller.remove_defined_variable_attribute(self.var.id, newName)
Пример #49
0
    def getAxisWeightValuesEvent(self):
        """ getAxisWeightValuesEvent is called when the user selects 'Get Axis
        Weight Values' from the axis button menu.  This method will create and
        define a new variable / tab with the axis' weight values
        """
        var = self.parent.getVar()
        _app = get_vistrails_application()
        w=_app.uvcdatWindow.dockCalculator.widget()
        le=w.le
        #axisVar = genutil.getAxisWeightByName(var, self.axis.id)
        axisVarid = var.id +'_' + self.axis.id + '_weight'

        # Generate teaching command string
        fileID = self.parent.cdmsFile.id
        le.setText("cdmsFile=cdms2.open('%s')" % fileID)
        w.run_command()
        le.setText("%s = genutil.getAxisWeightByName(cdmsFile[\"%s\"], \"%s\")\n" % (axisVarid, var.id, self.axis.id))
        w.run_command()
        le.setText( "%s.id = \"%s\"\n" % (axisVarid, axisVarid) )
        w.run_command()
Пример #50
0
 def acceptsVariable(self, varname):
     """Checks whether the passed variable is plottable by this plot
     """
     
     from gui.application import get_vistrails_application
     _app = get_vistrails_application()
     definedVariableWidget = _app.uvcdatWindow.dockVariable.widget()
     variable = definedVariableWidget.getVariable(varname)
     
     package1D = ['VCS']
     parent1D = ['Isofill', 'Isoline', 'Outfill','Outline']
     
     if variable is not None and self.package in package1D:
         if self.parent in parent1D:
             if len(variable.shape) < 2:
                 fmt = "%s - %s cannot plot 1D variables"
                 msg = fmt % (self.package, self.parent)
                 _app.uvcdatWindow.warning(msg)
                 return False
     
     return True
Пример #51
0
 def addVarAttribute(self):
     newName=str(self.newVarAttributeName.text()).strip()
     if len(newName)==0:
         return
     atts = sorted(list(set((self.var.listattributes()+['id',]))))
     if newName in atts:
         return
     setattr(self.var,newName,"newAttribute")
     atts = sorted(list(set((self.var.listattributes()+['id',]))))
     self.root.record("## Adding a new attribute to variable: %s" % self.var.id)
     self.root.record("%s.%s = 'newAttribute'" % (self.var.id,newName))
     
     for i in range(len(atts)):
         if atts[i] != str(self.varComboBox.itemText(i)):
             self.varComboBox.insertItem(i,newName)
             break
     self.varComboBox.setCurrentIndex(i)
     
     #provenance calls
     _app = get_vistrails_application()
     controller = _app.uvcdatWindow.get_current_project_controller()
     controller.change_defined_variable_attribute(self.var.id, newName, "newAttribute")
Пример #52
0
    def modAxAttribute(self):
        axName = str(self.axisComboBox.currentText())
        ax = self.var.getAxis(self.var.getAxisIndex(axName))
        attName = str(self.axComboBox.currentText())
        try:
            attValue=eval(str(self.axAttributeValue.text()).strip())
        except:
            attValue=str(self.axAttributeValue.text()).strip()

        setattr(ax,attName,attValue)
        tit = str(self.title.text()).split("(Modified)")[0]
        self.title.setText(tit)
        self.parent.setWindowTitle(tit)
        
        self.root.record("## Modify attribute %s on axis %s of variable %s" % (attName,ax.id,self.var.id))
        self.root.record("ax = %s.getAxis(%s.getAxisIndex('%s'))" % (self.var.id,self.var.id,axName))
        self.root.record("ax.%s = %s" % (attName,repr(attValue)))
        
        #provenance calls
        _app = get_vistrails_application()
        controller = _app.uvcdatWindow.get_current_project_controller()
        controller.change_defined_variable_axis_attribute(self.var.id, axName, attName, attValue)
Пример #53
0
 def addAxAttribute(self):
     axName = str(self.axisComboBox.currentText())
     ax = self.var.getAxis(self.var.getAxisIndex(axName))
     newName=str(self.newAxAttributeName.text()).strip()
     if len(newName)==0:
         return
     atts = sorted(list(set((ax.attributes.keys()+['id',]))))
     if newName in atts:
         return
     setattr(ax,newName,"newAttribute")
     atts = sorted(list(set((ax.attributes.keys()+['id',]))))
     for i in range(len(atts)):
         if atts[i] != str(self.axComboBox.itemText(i)):
             self.axComboBox.insertItem(i,newName)
             break
     self.axComboBox.setCurrentIndex(i)
     self.root.record("## Adding a new attribute to axis %s of variable: %s" % (ax.id,self.var.id))
     self.root.record("ax = %s.getAxis(%s.getAxisIndex('%s'))" % (self.var.id,self.var.id,axName))
     self.root.record("ax.%s = 'newAttribute'" % (newName))
     
     #provenance calls
     _app = get_vistrails_application()
     controller = _app.uvcdatWindow.get_current_project_controller()
     controller.change_defined_variable_axis_attribute(self.var.id, axName, newName, "newAttribute")
Пример #54
0
    def regridFunc(self, regridTool, regridMethod):
        """
        Run the regrid method from selected variables and store on the 
        command line
        @param regridTool ESMF, LibCF, Regrid2
        @param regridMethod Conserve, Linear, Patch
        """
        import systemCommands
        import __main__
        from gui.application import get_vistrails_application
        from api import get_current_project_controller
        _app = get_vistrails_application()

        QText = QtGui.QTextEdit()
        QLine = QtGui.QLineEdit()
        prj_controller = get_current_project_controller()

        useVars=self.root.dockVariable.widget().getSelectedDefinedVariables()
        sV = self.root.dockVariable.widget().varList.selectedItems()

        if len(useVars) > 2:
            print "\nOnly two variables can be selected to regrid"
            return

        argsStr = "regridTool = %s, regridMethod = %s" % (regridTool, regridMethod)
        # Get the variables
        vSrc = sV[0]
        vDst = sV[1]
        vSrcName = vSrc.varName
        vDstName = vDst.varName
        useSrc = useVars.pop(0)
        useDst = useVars.pop(0)
        varname = "regrid_%s_%s" % (vSrcName, vDstName)
#        varname = "regridVar"
        rhsCommand = "%s.regrid(%s.getGrid(), %s)" % \
                          (vSrcName, vDstName, argsStr)
        pycommand = "%s = %s" % (varname, rhsCommand)
        QLine.setText(QtCore.QString(pycommand.strip()))
        QText.setTextColor(QtGui.QColor(0,0,0))
        commandLine = ">>> " + pycommand + "\n"
        QText.insertPlainText(commandLine)
        systemCommands.commandHistory.append(pycommand)
        systemCommands.command_num = 0

        #exec( "import MV2,genutil,cdms2,vcs,cdutil,numpy", __main__.__dict__ )
        #regridVar = eval(rhsCommand, __main__.__dict__)
        #res = self.root.stick_main_dict_into_defvar(None)
        #regridVar.id = varname

        #_app.uvcdatWindow.dockVariable.widget().addVariable(regridVar)

        self.root.record("## Regrid command sent from PCMDITools->Regridding->%s>%s" % \
                                (regridTool, regridMethod))
        self.root.record(pycommand)
        prj_controller.process_typed_calculator_command(varname, rhsCommand)
        prj_controller.calculator_command(sV, "REGRID", varname, rhsCommand.strip())
        QLine.setFocus()
            
        tmp = prj_controller.create_exec_new_variable_pipeline(varname)
        if tmp is not None:
            tmp.id = varname
            _app.uvcdatWindow.dockVariable.widget().addVariable(tmp)
Пример #55
0
    def getUpdatedVar(self, targetId):
        if self.updatingFile:
            self.updatingFile = False
            return
        axisList = self.dimsLayout.itemAt(0).widget()
        kwargs = self.generateKwArgs()
        # Here we try to remove useless keywords as we record them
        cmds = ""
        for k in kwargs:
            if k == 'order':
                o = kwargs[k]
                skip = True
                for i in range(len(o)):
                    if int(o[i]) != i:
                        skip = False
                        break
                if skip:
                    continue
            cmds += "%s=%s," % (k, repr(kwargs[k]))
        cmds = cmds[:-1]
        #        uvar=axisList.getVar()
        #        if isinstance(uvar,cdms2.axis.FileAxis):
        #            updatedVar = cdms2.MV2.array(uvar)
        #        else:
        #            updatedVar = uvar(**kwargs)

        # Get the variable after carrying out the: def, sum, avg... operations
        #        updatedVar = axisList.execAxesOperations(updatedVar)
        updatedVar = axisList.getVar()
        self.root.record("## Defining variable in memory")

        if axisList.cdmsFile is None:
            oid = updatedVar.id
        else:
            oid = "cdmsFileVariable"
        if self.varNameInFile is not None:
            original_id = self.varNameInFile
            computed_var = False
        else:
            original_id = updatedVar.id
            computed_var = True

        #this used to be an actual transientvariable, now it's just a filevariable
        #updatedVar.id = targetId

        self.root.record("%s = %s(%s)" % (targetId, oid, cmds))
        ## Squeeze?
        if updatedVar.rank() != 0:
            if self.root.preferences.squeeze.isChecked():
                #updatedVar=updatedVar(squeeze=1)
                self.root.record("%s = %s(squeeze=1)" % (targetId, targetId))
                kwargs['squeeze'] = 1
        else:
            val = QtGui.QMessageBox()
            val.setText("%s = %f" % (updatedVar.id, float(updatedVar)))
            val.exec_()

        # Send information to controller so the Variable can be reconstructed
        # later. The best way is by emitting a signal to be processed by the
        # main window. When this panel becomes a global panel, then we will do
        # that. For now I will talk to the main window directly.

        _app = get_vistrails_application()
        controller = _app.uvcdatWindow.get_current_project_controller()

        def get_kwargs_str(kwargs_dict):
            kwargs_str = ""
            for k, v in kwargs_dict.iteritems():
                if k == 'order':
                    o = kwargs_dict[k]
                    skip = True
                    for i in range(len(o)):
                        if int(o[i]) != i:
                            skip = False
                            break
                    if skip:
                        continue
                kwargs_str += "%s=%s," % (k, repr(v))
            return kwargs_str

        axes_ops_dict = axisList.getAxesOperations()
        url = None
        if hasattr(self.cdmsFile, "uri"):
            url = self.cdmsFile.uri
        cdmsVar = None
        if not computed_var:
            cdmsVar = CDMSVariable(filename=self.cdmsFile.id,
                                   url=url,
                                   name=targetId,
                                   varNameInFile=original_id,
                                   axes=get_kwargs_str(kwargs),
                                   axesOperations=str(axes_ops_dict))
            controller.add_defined_variable(cdmsVar)
        else:
            controller.copy_computed_variable(
                original_id,
                targetId,
                axes=get_kwargs_str(kwargs),
                axesOperations=str(axes_ops_dict))

        updatedVar = controller.create_exec_new_variable_pipeline(targetId)

        if updatedVar is None:
            return axisList.getVar()

        if not computed_var:
            self.emit(QtCore.SIGNAL('definedVariableEvent'),
                      (updatedVar, cdmsVar))
        else:
            self.emit(QtCore.SIGNAL('definedVariableEvent'), updatedVar)

        if (self.varEditArea.widget()):
            self.varEditArea.widget().var = updatedVar
            axisList.setVar(updatedVar)

        self.updateVarInfo(axisList)
        return updatedVar
Пример #56
0
 def copyMessage(self):
     """ copy selected message to clipboard """
     items = self.list.selectedItems()
     if len(items) > 0:
         text = str(items[0].data(32).toString())
         get_vistrails_application().clipboard().setText(text)
Пример #57
0
    try:
        v = start_uvcdat_application( optionsDict )
        if v != 0:
            app = get_vistrails_application()
            if app:
                app.finishSession()
            sys.exit(v)
        app = get_vistrails_application()
    except SystemExit, e:
        app = get_vistrails_application()
        if app:
            app.finishSession()
        sys.exit(e)
    except Exception, e:
        app = get_vistrails_application()
        if app:
            app.finishSession()
        print "Uncaught exception on initialization: %s" % e
        import traceback
        traceback.print_exc()
        sys.exit(255)
        
    init_hyperwall( optionsDict )
    app.connect( app, QtCore.SIGNAL("aboutToQuit()"), shutdown ) 
    v = app.exec_()
    

if __name__ == '__main__': 
    runType = HWRunType.Server 
    if runType == HWRunType.Desktop: optionsDict = { "hw_role" : 'global', "showBuilder": True, 'spawn': True }   #  'global'   'hw_client'  'hw_server'