Exemplo n.º 1
0
 def sendError(self):
     data = {}
     data['platform'] = platform.uname()[0]
     data['platform_version'] = platform.uname()[2]
     data['hashed_hostname'] = hashlib.sha1(platform.uname()[1]).hexdigest()
     data['hashed_username'] = hashlib.sha1(os.getlogin()).hexdigest()
     data['source'] = 'UV-CDAT'
     data['source_version'] = '1.2.1'
     data['description'] = self.getDescription()
     data['stack_trace'] = self.errorDetails.toPlainText()
     data['severity'] = 'FATAL'
     data['comments'] = self.userComments.toPlainText()
     
     if get_vistrails_configuration().output != '':
         fname = get_vistrails_configuration().output
         # read at most last 5000 chars from output log
         with open(fname, "r") as f:
             f.seek (0, 2)           # Seek @ EOF
             fsize = f.tell()        # Get Size
             f.seek (max (fsize-5000, 0), 0) # Set pos @ last n chars
             data['execution_log'] = f.read()
     print urlencode(data)
     print "http://uvcdat.llnl.gov/UVCDATUsage/log/add/error/"
     result = urlopen("http://uvcdat.llnl.gov/UVCDATUsage/log/add/error/", 
                      urlencode(data))
     
Exemplo n.º 2
0
def py_import(module_name, dependency_dictionary, store_in_config=False):
    """Tries to import a python module, installing if necessary.

    If the import doesn't succeed, we guess which system we are running on and
    install the corresponding package from the dictionary. We then run the
    import again.
    If the installation fails, we won't try to install that same module again
    for the session.
    """
    try:
        result = _vanilla_import(module_name)
        return result
    except ImportError:
        if not getattr(get_vistrails_configuration(), 'installBundles'):
            raise

    if module_name in _previously_failed_pkgs:
        raise PyImportException("Import of Python module '%s' failed again, "
                                "not triggering installation" % module_name)
    if store_in_config:
        ignored_packages_list = getattr(get_vistrails_configuration(),
                                        'bundleDeclinedList',
                                        None)
        if ignored_packages_list:
            ignored_packages = set(ignored_packages_list.split(';'))
        else:
            ignored_packages = set()
        if module_name in ignored_packages:
            raise PyImportException("Import of Python module '%s' failed "
                                    "again, installation disabled by "
                                    "configuration" % module_name)
    debug.warning("Import of python module '%s' failed. "
                  "Will try to install bundle." % module_name)

    success = vistrails.core.bundles.installbundle.install(
            dependency_dictionary)

    if store_in_config:
        if bool(success):
            ignored_packages.discard(module_name)
        else:
            ignored_packages.add(module_name)
        setattr(get_vistrails_configuration(),
                'bundleDeclinedList',
                ';'.join(sorted(ignored_packages)))
        setattr(get_vistrails_persistent_configuration(),
                'bundleDeclinedList',
                ';'.join(sorted(ignored_packages)))

    if not success:
        _previously_failed_pkgs.add(module_name)
        raise PyImportException("Installation of Python module '%s' failed." %
                                module_name)
    try:
        result = _vanilla_import(module_name)
        return result
    except ImportError, e:
        _previously_failed_pkgs.add(module_name)
        raise PyImportBug("Installation of package '%s' succeeded, but import "
                          "still fails." % module_name)
Exemplo n.º 3
0
    def adjust_version_colors(self, controller):
        """ adjust_version_colors(controller: VistrailController) -> None
        Based on the controller to set version colors
        
        """
        currentUser = controller.vistrail.getUser()
        ranks = {}
        ourMaxRank = 0
        otherMaxRank = 0
        am = controller.vistrail.actionMap
        for nodeId in sorted(self.versions.keys()):
            if nodeId!=0:
                nodeUser = am[nodeId].user
                if nodeUser==currentUser:
                    ranks[nodeId] = ourMaxRank
                    ourMaxRank += 1
                else:
                    ranks[nodeId] = otherMaxRank
                    otherMaxRank += 1
        for (nodeId, item) in self.versions.iteritems():
            if nodeId == 0:
                item.setGhosted(True)
                continue
            nodeUser = am[nodeId].user
            if controller.search and nodeId!=0:
                action = am[nodeId]
                if getattr(get_vistrails_configuration(), 'hideUpgrades',
                           True):
                    # Use upgraded version to match
                    action = am[controller.vistrail.get_upgrade(nodeId, False)]
                ghosted = not controller.search.match(controller, action)
            else:
                ghosted = False
                
            #item.setGhosted(ghosted) # we won't set it now so we can check if
                                      # the state changed in update_color
            if nodeUser==currentUser:
                max_rank = ourMaxRank
            else:
                max_rank = otherMaxRank
#             max_rank = ourMaxRank if nodeUser==currentUser else otherMaxRank
            configuration = get_vistrails_configuration()
            if configuration.check('customVersionColors'):
                custom_color = controller.vistrail.get_action_annotation(
                    nodeId,
                    custom_color_key)
                if custom_color is not None:
                    try:
                        custom_color = parse_custom_color(custom_color.value)
                    except ValueError, e:
                        debug.warning("Version %r has invalid color annotation "
                                      "(%s)" % (nodeId, e))
                        custom_color = None
            else:
                custom_color = None
            ####
            item.update_color(nodeUser==currentUser,
                              ranks[nodeId],
                              max_rank, ghosted, custom_color)
    def __init__(self):
        d = {"prefix": "vt_tmp"}
        if get_vistrails_configuration().check("temporaryDirectory"):
            dir = get_vistrails_configuration().temporaryDirectory
            if os.path.exists(dir):
                d["dir"] = dir
            else:
                debug.critical("Temporary directory does not exist: %s" % dir)

        self.directory = tempfile.mkdtemp(**d)
        self.files = {}
Exemplo n.º 5
0
 def tab_changed(self, index):
     """ tab_changed(index: int) -> None
     Keep general and advanced configurations in sync
     
     """
     self._configuration_tab.configuration_changed(
                                    get_vistrails_persistent_configuration(),
                                    get_vistrails_configuration())
     self._general_tab.update_state(
                                    get_vistrails_persistent_configuration(),
                                    get_vistrails_configuration())
Exemplo n.º 6
0
    def __init__(self):
        d = {'prefix':'vt_tmp'}
        if get_vistrails_configuration().check('temporaryDir'):
            dir = get_vistrails_configuration().temporaryDir
            if os.path.exists(dir):
                d['dir'] = dir
            else:
                debug.critical("Temporary directory does not exist: %s" % dir)

        self.directory = tempfile.mkdtemp(**d)
        self.files = {}
Exemplo n.º 7
0
    def __init__(self, parent):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle('VisTrails Preferences')
        layout = QtGui.QHBoxLayout(self)
        layout.setMargin(0)
        layout.setSpacing(0)
        self.setLayout(layout)

        f = QtGui.QFrame()
        layout.addWidget(f)
        
        l = QtGui.QVBoxLayout(f)
        f.setLayout(l)
        
        self._tab_widget = QtGui.QTabWidget(f)
        l.addWidget(self._tab_widget)
        self._tab_widget.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)

        tabs = [("General", ["General", "Packages"]),
                ("Interface", ["Interface", "Startup"]),
                ("Paths && URLs", ["Paths", "Web Sharing"]),
                ("Advanced", ["Upgrades", "Thumbnails", "Advanced"]),
                ]
        for (tab_name, categories) in tabs:
            tab = QConfigurationPane(self, 
                                     get_vistrails_persistent_configuration(),
                                     get_vistrails_configuration(),
                                     [(c, base_config[c]) for c in categories])
            self._tab_widget.addTab(tab, tab_name)

        output_tab = QOutputConfigurationPane(self,
                                    get_vistrails_persistent_configuration(), 
                                    get_vistrails_configuration())
        self._tab_widget.addTab(output_tab, "Output")

        self._packages_tab = self.create_packages_tab()
        self._tab_widget.addTab(self._packages_tab, 'Packages')
        
        self._configuration_tab = self.create_configuration_tab()
        self._tab_widget.addTab(self._configuration_tab, 'Expert')

        self.connect(self._tab_widget,
                     QtCore.SIGNAL('currentChanged(int)'),
                     self.tab_changed)

        self.connect(self._configuration_tab._tree.treeWidget,
                     QtCore.SIGNAL('configuration_changed'),
                     self.configuration_changed)
Exemplo n.º 8
0
    def __init__(self, parent):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle('VisTrails Preferences')
        layout = QtGui.QHBoxLayout(self)
        layout.setMargin(0)
        layout.setSpacing(0)
        self.setLayout(layout)

        f = QtGui.QFrame()
        layout.addWidget(f)

        l = QtGui.QVBoxLayout(f)
        f.setLayout(l)

        self._tab_widget = QtGui.QTabWidget(f)
        l.addWidget(self._tab_widget)
        self._tab_widget.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)

        tabs = [
            ("General", ["General", "Packages"]),
            ("Interface", ["Interface", "Startup"]),
            ("Paths && URLs", ["Paths", "Web Sharing"]),
            ("Advanced", ["Upgrades", "Thumbnails", "Advanced"]),
        ]
        for (tab_name, categories) in tabs:
            tab = QConfigurationPane(self,
                                     get_vistrails_persistent_configuration(),
                                     get_vistrails_configuration(),
                                     [(c, base_config[c]) for c in categories])
            self._tab_widget.addTab(tab, tab_name)

        output_tab = QOutputConfigurationPane(
            self, get_vistrails_persistent_configuration(),
            get_vistrails_configuration())
        self._tab_widget.addTab(output_tab, "Output")

        self._packages_tab = self.create_packages_tab()
        self._tab_widget.addTab(self._packages_tab, 'Packages')

        self._configuration_tab = self.create_configuration_tab()
        self._tab_widget.addTab(self._configuration_tab, 'Expert')

        self.connect(self._tab_widget, QtCore.SIGNAL('currentChanged(int)'),
                     self.tab_changed)

        self.connect(self._configuration_tab._tree.treeWidget,
                     QtCore.SIGNAL('configuration_changed'),
                     self.configuration_changed)
 def load_running_jobs(self):
     conf = configuration.get_vistrails_configuration()
     if conf.has('runningJobsList') and conf.runningJobsList:
         for url in conf.runningJobsList.split(';'):
             loc, version = url.split('?')
             locator = BaseLocator.from_url(loc)
             msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Question,
                                        "Running Job Found",
                                        "Running Job Found:\n    %s\n"
                                        "Continue now?" % url)
             msgBox.addButton("Later", msgBox.ActionRole)
             delete = msgBox.addButton("Delete", msgBox.ActionRole)
             yes = msgBox.addButton("Yes", msgBox.ActionRole)
             msgBox.exec_()
             if msgBox.clickedButton() == yes:
                 from vistrails.gui.vistrails_window import _app
                 _app.open_vistrail_without_prompt(locator,
                                                int(version.split('=')[1]))
                 _app.get_current_view().execute()
             if msgBox.clickedButton() == delete:
                 conf_jobs = conf.runningJobsList.split(';')
                 conf_jobs.remove(url)
                 conf.runningJobsList = ';'.join(conf_jobs)
                 configuration.get_vistrails_persistent_configuration(
                                   ).runningJobsList = conf.runningJobsList
     else:
         conf.runningJobsList = ''
         configuration.get_vistrails_persistent_configuration(
                                   ).runningJobsList = conf.runningJobsList
Exemplo n.º 10
0
    def checkJob(self, module, id, handle):
        """ checkJob(module: VistrailsModule, id: str, handle: object) -> None
            Starts monitoring the job for the current running workflow
            module - the module to suspend
            id - the job identifier
            handle - an object following the JobHandle interface, i.e. with a
                finished method for checking if the job has completed

        """
        if not self.currentWorkflow():
            if not handle or not self.isDone(handle):
                raise ModuleSuspended(module, 'Job is running', handle=handle)
        job = self.getJob(id)
        if self.callback:
            self.callback.checkJob(module, id, handle)
            return

        conf = get_vistrails_configuration()
        interval = conf.jobCheckInterval
        if interval and not conf.jobAutorun:
            if handle:
                # wait for module to complete
                try:
                    while not self.isDone(handle):
                        time.sleep(interval)
                        print("Waiting for job: %s,"
                              "press Ctrl+C to suspend") % job.name
                except KeyboardInterrupt:
                    raise ModuleSuspended(module, 'Interrupted by user, job'
                                          ' is still running',
                                          handle=handle)
        else:
            if not handle or not self.isDone(handle):
                raise ModuleSuspended(module, 'Job is running', handle=handle)
Exemplo n.º 11
0
 def create_thumbs_tab(self):
     """ create_thumbs_tab() -> QThumbnailConfiguration
     
     """
     return QThumbnailConfiguration(self,
                                    get_vistrails_persistent_configuration(),
                                    get_vistrails_configuration())
Exemplo n.º 12
0
 def create_general_tab(self):
     """ create_general_tab() -> QGeneralConfiguration
     
     """
     return QGeneralConfiguration(self,
                                  get_vistrails_persistent_configuration(),
                                  get_vistrails_configuration())
Exemplo n.º 13
0
    def theFunction(src, dst):
        global Variant_desc, InputPort_desc
        if Variant_desc is None:
            reg = get_module_registry()
            Variant_desc = reg.get_descriptor_by_name(
                    'org.vistrails.vistrails.basic', 'Variant')
            InputPort_desc = reg.get_descriptor_by_name(
                    'org.vistrails.vistrails.basic', 'InputPort')

        iport = conn.destination.name
        oport = conn.source.name
        src.enableOutputPort(oport)
        conf = get_vistrails_configuration()
        error_on_others = getattr(conf, 'errorOnConnectionTypeerror')
        error_on_variant = (error_on_others or
                            getattr(conf, 'errorOnVariantTypeerror'))
        errors = [error_on_others, error_on_variant]
        if isinstance(src, InputPort_desc.module):
            typecheck = [False]
        else:
            typecheck = [errors[desc is Variant_desc]
                         for desc in conn.source.spec.descriptors()]
        dst.set_input_port(
                iport,
                ModuleConnector(src, oport, conn.destination.spec, typecheck))
Exemplo n.º 14
0
    def checkJob(self, module, id, monitor):
        """ checkJob(module: VistrailsModule, id: str, monitor: instance) -> None
            Starts monitoring the job for the current running workflow
            module - the module to suspend
            id - the job identifier
            monitor - a class instance with a finished method for 
                      checking if the job has completed

        """
        if not self.currentWorkflow():
            if not monitor or not self.isDone(monitor):
                raise ModuleSuspended(module, 'Job is running', queue=monitor,
                                      job_id=id)
        job = self.getJob(id)
        if self.callback:
            self.callback.checkJob(module, id, monitor)
            return

        conf = get_vistrails_configuration()
        interval = conf.jobCheckInterval
        if interval and not conf.jobAutorun:
            if monitor:
                # wait for module to complete
                try:
                    while not self.isDone(monitor):
                        time.sleep(interval)
                        print ("Waiting for job: %s," 
                               "press Ctrl+C to suspend") % job.name
                except KeyboardInterrupt, e:
                    raise ModuleSuspended(module, 'Interrupted by user, job'
                                           ' is still running', queue=monitor,
                                           job_id=id)
Exemplo n.º 15
0
    def compute(self):
        vt_configuration = get_vistrails_configuration()
        if not getattr(vt_configuration, 'interactiveMode', False):
            self.set_output('result', True)
            return

        cell = self.get_input('cell')
        label = self.force_get_input('label', None)

        # FIXME : This should be done via the spreadsheet, removing it properly
        # and then sending a new DisplayCellEvent
        # However, there is currently no facility to remove the widget from
        # wherever it is
        oldparent = cell.parent()
        assert isinstance(oldparent, QCellContainer)
        ncell = oldparent.takeWidget()
        assert ncell == cell
        dialog = PromptWindow(cell, label)
        result = dialog.exec_() == QtGui.QDialog.Accepted
        oldparent.setWidget(cell)

        self.set_output('result', result)

        if not result and not self.get_input('carry_on'):
            raise ModuleError(self, "Execution aborted")
Exemplo n.º 16
0
def current_dot_vistrails():
    """ current_dot_vistrails() -> str
    Returns the VisTrails per-user directory.

    """
    from vistrails.core.configuration import get_vistrails_configuration
    return get_vistrails_configuration().dotVistrails
Exemplo n.º 17
0
    def checkJob(self, module, id, handle):
        """ checkJob(module: VistrailsModule, id: str, handle: object)
        Callback, checks if job has completed.
        """
        workflow = self.jobMonitor.currentWorkflow()
        if not workflow:
            if not handle or not self.jobMonitor.isDone(handle):
                raise ModuleSuspended(module, 'Job is running', handle=handle)
        workflow_item = self.workflowItems[workflow.id]
        item = workflow_item.jobs.get(id, None)
        item.setText(0, item.job.name)
        # we should check the status using the JobHandle and show dialog
        # get current view progress bar and hijack it
        if handle:
            item.handle = handle
        workflow = self.jobMonitor.currentWorkflow()
        workflow_item = self.workflowItems.get(workflow.id, None)
        workflow_item.updateJobs()
        progress = self.controller.progress

        conf = configuration.get_vistrails_configuration()
        interval = conf.jobCheckInterval
        if interval and not conf.jobAutorun and not progress.suspended:
            # we should keep checking the job
            if handle:
                # wait for module to complete
                labelText = (("Running external job %s\n"
                              "Started %s\n"
                              "Press Cancel to suspend") %
                             (item.job.name, item.job.start))
                progress.setLabelText(labelText)
                while not self.jobMonitor.isDone(handle):
                    i = 0
                    while i < interval:
                        i += 1
                        time.sleep(1)
                        QtCore.QCoreApplication.processEvents()
                        if progress.wasCanceled():
                            # this does not work, need to create a new progress dialog
                            #progress.goOn()
                            new_progress = progress.__class__(
                                progress.parent())
                            new_progress.setMaximum(progress.maximum())
                            new_progress.setValue(progress.value())
                            new_progress.setLabelText(labelText)
                            new_progress.setMinimumDuration(0)
                            new_progress.suspended = True
                            self.controller.progress = new_progress
                            progress.hide()
                            progress.deleteLater()
                            progress = new_progress
                            progress.show()
                            QtCore.QCoreApplication.processEvents()
                            raise ModuleSuspended(module,
                                                  'Interrupted by user, job'
                                                  ' is still running',
                                                  handle=handle)
                return
        if not handle or not self.jobMonitor.isDone(handle):
            raise ModuleSuspended(module, 'Job is running', handle=handle)
Exemplo n.º 18
0
def py_import(module_name, dependency_dictionary):
    """Tries to import a python module, installing if necessary.

    If the import doesn't succeed, we guess which system we are running on and
    install the corresponding package from the dictionary. We then run the
    import again.
    If the installation fails, we won't try to install that same module again
    for the session.
    """
    try:
        result = _vanilla_import(module_name)
        return result
    except ImportError:
        if not getattr(get_vistrails_configuration(), 'installBundles'):
            raise

    if module_name in _previously_failed_pkgs:
        raise PyImportException("Import of Python module '%s' failed again, "
                                "not triggering installation" % module_name)
    debug.warning("Import of python module '%s' failed. "
                  "Will try to install bundle." % module_name)

    success = vistrails.core.bundles.installbundle.install(dependency_dictionary)

    if not success:
        _previously_failed_pkgs.add(module_name)
        raise PyImportException("Installation of Python module '%s' failed." %
                                module_name)
    try:
        result = _vanilla_import(module_name)
        return result
    except ImportError, e:
        _previously_failed_pkgs.add(module_name)
        raise PyImportBug("Installation of package '%s' succeeded, but import "
                          "still fails." % module_name)
Exemplo n.º 19
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 = s.strip()
        msgs = s.split('\n')

        if len(msgs) <= 3:
            msgs.append('Error logging message: invalid log format')
            s += '\n' + msgs[3]
        if not len(msgs[3].strip()):
            msgs[3] = "Unknown Error"
            s = '\n'.join(msgs)
        text = msgs[3]
        item = QtGui.QListWidgetItem(text)
        item.setData(32, s)
        item.setFlags(item.flags() & ~QtCore.Qt.ItemIsEditable)
        self.list.addItem(item)
        item.setForeground(CurrentTheme.DEBUG_COLORS[msgs[0]])
        self.list.setItemHidden(item, not self.levels[msgs[0]].isChecked())
        alwaysShowDebugPopup = getattr(get_vistrails_configuration(),
                                       'showDebugPopups', False)
        if msgs[0] == 'CRITICAL':
            if self.isVisible() and not alwaysShowDebugPopup:
                self.raise_()
                self.activateWindow()
                modal = get_vistrails_application().activeModalWidget()
                if modal:
                    # need to beat modal window
                    self.showMessageBox(item)
            else:
                self.showMessageBox(item)
Exemplo n.º 20
0
    def addButtonsToToolbar(self):
        # button for toggling executions
        eye_open_icon = \
            QtGui.QIcon(os.path.join(vistrails_root_directory(),
                                 'gui/resources/images/eye.png'))

        self.portVisibilityAction = QtGui.QAction(
            eye_open_icon,
            "Show/hide port visibility toggle buttons",
            None,
            triggered=self.showPortVisibility)
        self.portVisibilityAction.setCheckable(True)
        self.portVisibilityAction.setChecked(True)
        self.toolWindow().toolbar.insertAction(self.toolWindow().pinAction,
                                               self.portVisibilityAction)
        self.showTypesAction = QtGui.QAction(letterIcon('T'),
                                             "Show/hide type information",
                                             None,
                                             triggered=self.showTypes)
        self.showTypesAction.setCheckable(True)
        self.showTypesAction.setChecked(True)
        self.toolWindow().toolbar.insertAction(self.toolWindow().pinAction,
                                               self.showTypesAction)
        self.showEditsAction = QtGui.QAction(QtGui.QIcon(
            os.path.join(vistrails_root_directory(),
                         'gui/resources/images/pencil.png')),
                                             "Show/hide parameter widgets",
                                             None,
                                             triggered=self.showEdits)
        self.showEditsAction.setCheckable(True)
        self.showEditsAction.setChecked(
            get_vistrails_configuration().check('showInlineParameterWidgets'))
        self.toolWindow().toolbar.insertAction(self.toolWindow().pinAction,
                                               self.showEditsAction)
Exemplo n.º 21
0
    def checkJob(self, module, id, handle):
        """ checkJob(module: VistrailsModule, id: str, handle: object) -> None
            Starts monitoring the job for the current running workflow
            module - the module to suspend
            id - the job identifier
            handle - an object following the JobHandle interface, i.e. with a
                finished method for checking if the job has completed

        """
        if not self.currentWorkflow():
            if not handle or not self.isDone(handle):
                raise ModuleSuspended(module, 'Job is running',
                                      handle=handle)
        job = self.getJob(id)
        if self.callback:
            self.callback.checkJob(module, id, handle)
            return

        conf = get_vistrails_configuration()
        interval = conf.jobCheckInterval
        if interval and not conf.jobAutorun:
            if handle:
                # wait for module to complete
                try:
                    while not self.isDone(handle):
                        time.sleep(interval)
                        print ("Waiting for job: %s,"
                               "press Ctrl+C to suspend") % job.name
                except KeyboardInterrupt:
                    raise ModuleSuspended(module, 'Interrupted by user, job'
                                          ' is still running', handle=handle)
        else:
            if not handle or not self.isDone(handle):
                raise ModuleSuspended(module, 'Job is running',
                                      handle=handle)
Exemplo n.º 22
0
    def getResultEntity(self, controller, versions_to_check):
        from vistrails.core.collection.vistrail import VistrailEntity

        vistrail_entity = None
        for version in versions_to_check:
            if version in controller.vistrail.actionMap:
                action = controller.vistrail.actionMap[version]
                if getattr(get_vistrails_configuration(), 'hideUpgrades',
                           True):
                    # Use upgraded version to match
                    action = controller.vistrail.actionMap[
                            controller.vistrail.get_upgrade(action.id, False)]
                if self.match(controller, action):
                    # have a match, get vistrail entity
                    if vistrail_entity is None:
                        vistrail_entity = VistrailEntity()
                        # don't want to add all workflows, executions
                        vistrail_entity.set_vistrail(controller.vistrail)
                    # only tagged versions should be displayed in the workspace
                    tagged_version = controller.get_tagged_version(version)
                    vistrail_entity.add_workflow_entity(tagged_version)
                    # FIXME this is not done at the low level but in
                    # Collection class, probably should be reworked
                    vistrail_entity.wf_entity_map[tagged_version].parent = \
                        vistrail_entity
        return vistrail_entity
Exemplo n.º 23
0
    def compute(self):
        vt_configuration = get_vistrails_configuration()
        if not getattr(vt_configuration, 'interactiveMode', False):
            self.set_output('result', True)
            return

        cell = self.get_input('cell')
        label = self.force_get_input('label', None)

        # FIXME : This should be done via the spreadsheet, removing it properly
        # and then sending a new DisplayCellEvent
        # However, there is currently no facility to remove the widget from
        # wherever it is
        oldparent = cell.parent()
        assert isinstance(oldparent, QCellContainer)
        ncell = oldparent.takeWidget()
        assert ncell == cell
        dialog = PromptWindow(cell, label)
        result = dialog.exec_() == QtGui.QDialog.Accepted
        oldparent.setWidget(cell)

        self.set_output('result', result)

        if not result and not self.get_input('carry_on'):
            raise ModuleError(self, "Execution aborted")
Exemplo n.º 24
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 = s.strip()
        msgs = s.split("\n")

        if len(msgs) <= 3:
            msgs.append("Error logging message: invalid log format")
            s += "\n" + msgs[3]
        if not len(msgs[3].strip()):
            msgs[3] = "Unknown Error"
            s = "\n".join(msgs)
        text = msgs[3]
        item = QtGui.QListWidgetItem(text)
        item.setData(32, s)
        item.setFlags(item.flags() & ~QtCore.Qt.ItemIsEditable)
        self.list.addItem(item)
        item.setForeground(CurrentTheme.DEBUG_COLORS[msgs[0]])
        self.list.setItemHidden(item, not self.levels[msgs[0]].isChecked())
        alwaysShowDebugPopup = getattr(get_vistrails_configuration(), "alwaysShowDebugPopup", False)
        if msgs[0] == "CRITICAL":
            if self.isVisible() and not alwaysShowDebugPopup:
                self.raise_()
                self.activateWindow()
                modal = get_vistrails_application().activeModalWidget()
                if modal:
                    # need to beat modal window
                    self.showMessageBox(item)
            else:
                self.showMessageBox(item)
Exemplo n.º 25
0
    def checkJob(self, module, id, monitor):
        """ checkJob(module: VistrailsModule, id: str, monitor: instance)
        Callback, checks if job has completed.
        """
        workflow = self.jobMonitor.currentWorkflow()
        if not workflow:
            if not monitor or not self.jobMonitor.isDone(monitor):
                raise ModuleSuspended(module, 'Job is running',
                                      monitor=monitor)
        workflow_item = self.workflowItems[workflow.id]
        item = workflow_item.jobs.get(id, None)
        item.setText(0, item.job.name)
        # we should check the status using monitor and show dialog
        # get current view progress bar and hijack it
        if monitor:
            item.monitor = monitor
        workflow = self.jobMonitor.currentWorkflow()
        workflow_item = self.workflowItems.get(workflow.id, None)
        workflow_item.updateJobs()
        progress = self.controller.progress

        conf = configuration.get_vistrails_configuration()
        interval = conf.jobCheckInterval
        if interval and not conf.jobAutorun and not progress.suspended:
            # we should keep checking the job
            if monitor:
                # wait for module to complete
                labelText = (("Running external job %s\n"
                                       "Started %s\n"
                                       "Press Cancel to suspend")
                                       % (item.job.name,
                                          item.job.start))
                progress.setLabelText(labelText)
                while not self.jobMonitor.isDone(monitor):
                    i = 0
                    while i < interval:
                        i += 1
                        time.sleep(1)
                        QtCore.QCoreApplication.processEvents()
                        if progress.wasCanceled():
                            # this does not work, need to create a new progress dialog
                            #progress.goOn()
                            new_progress = progress.__class__(progress.parent())
                            new_progress.setMaximum(progress.maximum())
                            new_progress.setValue(progress.value())
                            new_progress.setLabelText(labelText)
                            new_progress.setMinimumDuration(0)
                            new_progress.suspended = True
                            self.controller.progress = new_progress
                            progress.hide()
                            progress.deleteLater()
                            progress = new_progress
                            progress.show()
                            QtCore.QCoreApplication.processEvents()
                            raise ModuleSuspended(module,
                                       'Interrupted by user, job'
                                       ' is still running', monitor=monitor)
                return
        if not monitor or not self.jobMonitor.isDone(monitor):
            raise ModuleSuspended(module, 'Job is running', monitor=monitor)
Exemplo n.º 26
0
    def addButtonsToToolbar(self):
        # button for toggling executions
        eye_open_icon = \
            QtGui.QIcon(os.path.join(vistrails_root_directory(),
                                 'gui/resources/images/eye.png'))

        self.portVisibilityAction = QtGui.QAction(eye_open_icon,
                                        "Show/hide port visibility toggle buttons",
                                        None,
                                        triggered=self.showPortVisibility)
        self.portVisibilityAction.setCheckable(True)
        self.portVisibilityAction.setChecked(True)
        self.toolWindow().toolbar.insertAction(self.toolWindow().pinAction,
                                               self.portVisibilityAction)
        self.showTypesAction = QtGui.QAction(letterIcon('T'),
                                        "Show/hide type information",
                                        None,
                                        triggered=self.showTypes)
        self.showTypesAction.setCheckable(True)
        self.showTypesAction.setChecked(True)
        self.toolWindow().toolbar.insertAction(self.toolWindow().pinAction,
                                               self.showTypesAction)
        self.showEditsAction = QtGui.QAction(
                 QtGui.QIcon(os.path.join(vistrails_root_directory(),
                                          'gui/resources/images/pencil.png')),
                 "Show/hide parameter widgets",
                 None,
                 triggered=self.showEdits)
        self.showEditsAction.setCheckable(True)
        self.showEditsAction.setChecked(
            get_vistrails_configuration().check('showInlineParameterWidgets'))
        self.toolWindow().toolbar.insertAction(self.toolWindow().pinAction,
                                               self.showEditsAction)
Exemplo n.º 27
0
    def __init__(self, registry, startup):
        """__init__(configuration: ConfigurationObject) -> PackageManager
        configuration is the persistent configuration object of the application.
        
        """
        global _package_manager
        if _package_manager:
            m = "Package manager can only be constructed once."
            raise VistrailsInternalError(m)
        _package_manager = self

        self._registry = registry
        self._startup = startup

        # Contains packages that have not yet been enabled, but exist on the
        # filesystem
        self._available_packages = {}  # codepath: str -> Package
        # These other lists contain enabled packages
        self._package_list = {}  # codepath: str -> Package
        self._package_versions = {}  # identifier: str -> version -> Package
        self._old_identifier_map = {}  # old_id: str -> new_id: str
        self._dependency_graph = vistrails.core.data_structures.graph.Graph()
        self._default_prefix_dict = {
            "basic_modules": "vistrails.core.modules.",
            "abstraction": "vistrails.core.modules.",
        }

        self._userpackages = None
        self._packages = None
        self._abstraction_pkg = None
        self._currently_importing_package = None

        # Setup a global __import__ hook that calls Package#import_override()
        # for all imports executed from that package
        import __builtin__

        self._orig_import = __builtin__.__import__
        __builtin__.__import__ = self._import_override

        # Compute the list of available packages, _available_packages
        self.build_available_package_names_list()

        if get_vistrails_configuration().loadPackages:
            for pkg in self._startup.enabled_packages.itervalues():
                self.add_package(pkg.name, prefix=pkg.prefix)
        else:
            try:
                basic_pkg = self._startup.enabled_packages["basic_modules"]
            except KeyError:
                pass
            else:
                self.add_package(basic_pkg.name, prefix=basic_pkg.prefix)

            try:
                abs_pkg = self._startup.enabled_packages["abstraction"]
            except KeyError:
                pass
            else:
                self.add_package(abs_pkg.name, prefix=abs_pkg.prefix)
Exemplo n.º 28
0
 def __init__(self):
     self.elements = {}
     self.vtelements = {}
     self.conf = None
     conf = get_vistrails_configuration()
     if conf.has('thumbs'):
         self.conf = conf.thumbs
     self.init_cache()
Exemplo n.º 29
0
 def update_controller(self):
     # FIXME Need to figure out how to deal with this !!!
     self.vt_controller.set_vistrail(self.controller.vistrail, None,
                                     set_log_on_vt=False)
     hide_upgrades = getattr(get_vistrails_configuration(),
                                     'hideUpgrades', True)
     self.vt_controller.change_selected_version(self.controller.current_version,
                                                hide_upgrades, hide_upgrades)
Exemplo n.º 30
0
    def __init__(self, registry, startup):
        """__init__(configuration: ConfigurationObject) -> PackageManager
        configuration is the persistent configuration object of the application.
        
        """
        global _package_manager
        if _package_manager:
            m = "Package manager can only be constructed once."
            raise VistrailsInternalError(m)
        _package_manager = self

        self._registry = registry
        self._startup = startup

        # Contains packages that have not yet been enabled, but exist on the
        # filesystem
        self._available_packages = {}  # codepath: str -> Package
        # These other lists contain enabled packages
        self._package_list = {}  # codepath: str -> Package
        self._package_versions = {}  # identifier: str -> version -> Package
        self._old_identifier_map = {}  # old_id: str -> new_id: str
        self._dependency_graph = vistrails.core.data_structures.graph.Graph()
        self._default_prefix_dict = \
                                {'basic_modules': 'vistrails.core.modules.',
                                 'abstraction': 'vistrails.core.modules.'}

        self._userpackages = None
        self._packages = None
        self._abstraction_pkg = None
        self._currently_importing_package = None

        # Setup a global __import__ hook that calls Package#import_override()
        # for all imports executed from that package
        import __builtin__
        self._orig_import = __builtin__.__import__
        __builtin__.__import__ = self._import_override

        # Compute the list of available packages, _available_packages
        self.build_available_package_names_list()

        if get_vistrails_configuration().loadPackages:
            for pkg in self._startup.enabled_packages.itervalues():
                self.add_package(pkg.name, prefix=pkg.prefix)
        else:
            try:
                basic_pkg = self._startup.enabled_packages['basic_modules']
            except KeyError:
                pass
            else:
                self.add_package(basic_pkg.name, prefix=basic_pkg.prefix)

            try:
                abs_pkg = self._startup.enabled_packages['abstraction']
            except KeyError:
                pass
            else:
                self.add_package(abs_pkg.name, prefix=abs_pkg.prefix)
Exemplo n.º 31
0
 def update_controller(self):
     # FIXME Need to figure out how to deal with this !!!
     self.vt_controller.set_vistrail(self.controller.vistrail,
                                     None,
                                     set_log_on_vt=False)
     hide_upgrades = getattr(get_vistrails_configuration(), 'hideUpgrades',
                             True)
     self.vt_controller.change_selected_version(
         self.controller.current_version, hide_upgrades, hide_upgrades)
Exemplo n.º 32
0
 def __init__(self):
     self._temp_directory = None
     self.elements = {}
     self.vtelements = {}
     self.conf = None
     conf = get_vistrails_configuration()
     if conf.has('thumbs'):
         self.conf = conf.thumbs
     self.init_cache()
Exemplo n.º 33
0
def require_python_module(module_name, dep_dict=None):
    exists = python_module_exists(module_name)
    if (not exists and
            dep_dict and
            getattr(get_vistrails_configuration(), 'installBundles')):
        vistrails.core.bundles.installbundle.install(dep_dict)
        exists = python_module_exists(module_name)
    if not exists:
        raise MissingRequirement(module_name)
Exemplo n.º 34
0
def current_dot_vistrails(conf=None):
    """ current_dot_vistrails() -> str
    Returns the VisTrails per-user directory.

    """
    if conf is None:
        from vistrails.core.configuration import get_vistrails_configuration
        conf = get_vistrails_configuration()
    return conf.dotVistrails
Exemplo n.º 35
0
def current_dot_vistrails(conf=None):
    """ current_dot_vistrails() -> str
    Returns the VisTrails per-user directory.

    """
    if conf is None:
        from vistrails.core.configuration import get_vistrails_configuration
        conf = get_vistrails_configuration()
    return conf.dotVistrails
Exemplo n.º 36
0
    def tab_changed(self, index):
        """ tab_changed(index: int) -> None
        Keep general and advanced configurations in sync
        
        """

        # FIXME Need to fix this
        self._configuration_tab.configuration_changed(
                                       get_vistrails_persistent_configuration(),
                                       get_vistrails_configuration())
Exemplo n.º 37
0
    def tab_changed(self, index):
        """ tab_changed(index: int) -> None
        Keep general and advanced configurations in sync
        
        """

        # FIXME Need to fix this
        self._configuration_tab.configuration_changed(
            get_vistrails_persistent_configuration(),
            get_vistrails_configuration())
Exemplo n.º 38
0
 def unload(self):
     for path in self.py_dependencies:
         if path not in sys.modules:
             pass
         elif not getattr(get_vistrails_configuration(),
                          'dontUnloadModules', False):
             debug.debug("deleting from sys.modules: %s" % path)
             del sys.modules[path]
     self.py_dependencies.clear()
     self._loaded = False
Exemplo n.º 39
0
    def checkJob(self, module, id, handle):
        """ checkJob(module: VistrailsModule, id: str, handle: object)
        Callback, checks if job has completed.
        """
        workflow = self.jobMonitor.currentWorkflow()
        if not workflow:
            if not self.jobMonitor.isDone(handle):
                raise ModuleSuspended(module, 'Job is running',
                                      handle=handle)
        workflow_item = self.workflowItems[workflow.id]
        item = workflow_item.jobs.get(id, None)
        item.setText(0, item.job.name)
        # we should check the status using the JobHandle and show dialog
        # get current view progress bar and hijack it
        item.handle = handle
        workflow = self.jobMonitor.currentWorkflow()
        workflow_item = self.workflowItems.get(workflow.id, None)
        workflow_item.updateJobs()
        progress = self.controller.progress

        conf = get_vistrails_configuration()
        interval = conf.jobCheckInterval
        if interval and not conf.jobAutorun and not progress.suspended:
            # wait for module to complete
            labelText = (("Running external job %s\n"
                                   "Started %s\n"
                                   "Press Cancel to suspend")
                                   % (item.job.name,
                                      item.job.start))
            progress.setLabelText(labelText)
            while not self.jobMonitor.isDone(handle):
                dieTime = QtCore.QDateTime.currentDateTime().addSecs(interval)
                while QtCore.QDateTime.currentDateTime() < dieTime:
                    QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 100)
                    if progress.wasCanceled():
                        # this does not work, need to create a new progress dialog
                        #progress.goOn()
                        new_progress = progress.__class__(progress.parent())
                        new_progress.setMaximum(progress.maximum())
                        new_progress.setValue(progress.value())
                        new_progress.setLabelText(labelText)
                        new_progress.setMinimumDuration(0)
                        new_progress.suspended = True
                        self.controller.progress = new_progress
                        progress.hide()
                        progress.deleteLater()
                        progress = new_progress
                        progress.show()
                        QtCore.QCoreApplication.processEvents()
                        raise ModuleSuspended(module,
                                   'Interrupted by user, job'
                                   ' is still running', handle=handle)
            return
        if not self.jobMonitor.isDone(handle):
            raise ModuleSuspended(module, 'Job is running', handle=handle)
Exemplo n.º 40
0
    def adjust_version_colors(self, controller):
        """ adjust_version_colors(controller: VistrailController) -> None
        Based on the controller to set version colors
        
        """
        currentUser = controller.vistrail.getUser()
        ranks = {}
        ourMaxRank = 0
        otherMaxRank = 0
        am = controller.vistrail.actionMap
        for nodeId in sorted(self.versions.keys()):
            if nodeId!=0:
                nodeUser = am[nodeId].user
                if nodeUser==currentUser:
                    ranks[nodeId] = ourMaxRank
                    ourMaxRank += 1
                else:
                    ranks[nodeId] = otherMaxRank
                    otherMaxRank += 1
        for (nodeId, item) in self.versions.iteritems():
            if nodeId == 0:
                item.setGhosted(True)
                continue
            nodeUser = am[nodeId].user
            if controller.search and nodeId!=0:
                ghosted = not controller.search.match(controller.vistrail, 
                                                      am[nodeId])
            else:
                ghosted = False
                
            #item.setGhosted(ghosted) # we won't set it now so we can check if
                                      # the state changed in update_color
            if nodeUser==currentUser:
                max_rank = ourMaxRank
            else:
                max_rank = otherMaxRank
#             max_rank = ourMaxRank if nodeUser==currentUser else otherMaxRank
            configuration = get_vistrails_configuration()
            if configuration.check('enableCustomVersionColors'):
                custom_color = controller.vistrail.get_action_annotation(
                    nodeId,
                    custom_color_key)
                if custom_color is not None:
                    try:
                        custom_color = parse_custom_color(custom_color.value)
                    except ValueError, e:
                        debug.warning("Version %r has invalid color annotation "
                                      "(%s)" % (nodeId, e))
                        custom_color = None
            else:
                custom_color = None
            ####
            item.update_color(nodeUser==currentUser,
                              ranks[nodeId],
                              max_rank, ghosted, custom_color)
Exemplo n.º 41
0
 def unload(self):
     for path in self.py_dependencies:
         if path not in sys.modules:
             pass
         elif not getattr(get_vistrails_configuration(),
                          'dontUnloadModules',
                          False):
             debug.debug("deleting from sys.modules: %s" % path)
             del sys.modules[path]
     self.py_dependencies.clear()
     self._loaded = False
 def createDetachedViews(self):
     """ createDetachedViews() -> None
     Create a set of QStackedWidget for displaying detached views
     based on the input configuration
     
     """
     if getattr(get_vistrails_configuration(), 'detachHistoryView'):
         self.historyView = QDetachedView('History View')
         self.historyView.show()
     else:
         self.historyView = None
Exemplo n.º 43
0
def get_vistrails_directory(config_key, conf=None):
    if conf is None:
        from vistrails.core.configuration import get_vistrails_configuration
        conf = get_vistrails_configuration()
    if conf.has_deep_value(config_key):
        d = conf.get_deep_value(config_key)
        if os.path.isabs(d):
            return d
        else:
            return os.path.join(current_dot_vistrails(conf), d)
    return None
Exemplo n.º 44
0
def get_vistrails_directory(config_key, conf=None):
    if conf is None:
        from vistrails.core.configuration import get_vistrails_configuration
        conf = get_vistrails_configuration()
    if conf.has_deep_value(config_key):
        d = conf.get_deep_value(config_key)
        if os.path.isabs(d):
            return d
        else:
            return os.path.join(current_dot_vistrails(conf), d)
    return None
Exemplo n.º 45
0
def get_save_file_locator_from_gui(parent, obj_type, locator=None):
    # Ignore current locator for now
    # In the future, use locator to guide GUI for better starting directory

    suffixes = "*" + " *".join(suffix_map[obj_type])
    fileName = QtGui.QFileDialog.getSaveFileName(
        parent,
        "Save Vistrail...",
        vistrails.core.system.vistrails_file_directory(),
        filter="VisTrails files (%s)" % suffixes, # filetypes.strip()
        options=QtGui.QFileDialog.DontConfirmOverwrite)
    if not fileName:
        return None
    f = str(QtCore.QFile.encodeName(fileName))

    # check for proper suffix
    found_suffix = False
    for suffix in suffix_map[obj_type]:
        if f.endswith(suffix):
            found_suffix = True
            break
    if not found_suffix:
        if obj_type == 'vistrail':
            f += get_vistrails_configuration().defaultFileType
        else:
            f += suffix_map[obj_type][0]

    if os.path.isfile(f):
        msg = QtGui.QMessageBox(QtGui.QMessageBox.Question,
                                "VisTrails",
                                "File exists. Overwrite?",
                                (QtGui.QMessageBox.Yes |
                                 QtGui.QMessageBox.No),
                                parent)
        if msg.exec_() == QtGui.QMessageBox.No:
            return None
    dirName = os.path.dirname(f)
    setattr(get_vistrails_persistent_configuration(), 'fileDir', dirName)
    setattr(get_vistrails_configuration(), 'fileDir', dirName)
    vistrails.core.system.set_vistrails_file_directory(dirName)
    return FileLocator(f)
Exemplo n.º 46
0
 def match(self, controller, action):
     version = action.timestep
     from vistrails.core.configuration import get_vistrails_configuration
     hide_upgrades = getattr(get_vistrails_configuration(), 'hideUpgrades',
                             True)
     if hide_upgrades:
         version = controller.create_upgrade(version, delay_update=True)
     p = controller.get_pipeline(version, do_validate=False)
     for module in p.modules.itervalues():
         if self._content_matches(module.name):
             return True
     return False
Exemplo n.º 47
0
    def setUpClass(cls):
        get_vistrails_configuration().jobAutorun = True
        get_vistrails_persistent_configuration().jobAutorun = True
        QJobView.instance().set_refresh()
        cls.filename = (vistrails.core.system.vistrails_root_directory() +
                        '/tests/resources/jobs.vt')

        pm = vistrails.core.packagemanager.get_package_manager()
        if pm.has_package('org.vistrails.vistrails.myjobs'):
            return
        d = {'myjob': 'vistrails.tests.resources.'}
        pm.late_enable_package('myjob', d)
Exemplo n.º 48
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.timer_id = None
        self.updating_now = False
        self.widgets = {}

        self.layout = QtGui.QVBoxLayout()

        buttonsLayout = QtGui.QHBoxLayout()
        run_now = QDockPushButton("Check selected")
        run_now.setToolTip("Check selected job now")
        run_now.clicked.connect(self.check_selected_job)
        buttonsLayout.addWidget(run_now)
        run_all = QDockPushButton("Check all")
        run_all.setToolTip("Check all jobs now")
        run_all.clicked.connect(self.timerEvent)
        buttonsLayout.addWidget(run_all)
        label = QtGui.QLabel('Refresh interval (seconds):')
        buttonsLayout.addWidget(label)

        self.interval = QtGui.QComboBox()
        for text, seconds in refresh_states:
            self.interval.addItem(text, seconds)
        self.interval.setCompleter(None)
        self.interval.setEditable(True)
        self.interval.editTextChanged.connect(self.set_refresh)
        self.interval.setValidator(QNumberValidator())
        conf = get_vistrails_configuration()
        self.interval.setEditText(str(conf.jobCheckInterval))
        buttonsLayout.addWidget(self.interval)

        self.autorun = QtGui.QCheckBox("Automatic re-execution")
        self.autorun.setToolTip("Automatically re-execute workflow when jobs "
                                "complete")
        self.connect(self.autorun, QtCore.SIGNAL('toggled(bool)'),
                     self.autorunToggled)
        self.autorun.setChecked(conf.jobAutorun)
        buttonsLayout.addWidget(self.autorun)

        buttonsLayout.addStretch(1)
        self.layout.addLayout(buttonsLayout)

        self.jobView = QJobTree()
        self.jobView.itemDoubleClicked.connect(self.item_clicked)
        self.layout.addWidget(self.jobView)

        self.setLayout(self.layout)

        self.setWindowTitle('Running Jobs')
        self.resize(QtCore.QSize(800, 600))
Exemplo n.º 49
0
    def run(self, controller, name):
        reportusage.record_feature('visualquery', controller)
        result = []
        self.tupleLength = 2
        for version in self.versions_to_check:
            from vistrails.core.configuration import get_vistrails_configuration
            hide_upgrades = getattr(get_vistrails_configuration(),
                                    'hideUpgrades', True)
            if hide_upgrades:
                version = controller.create_upgrade(version, delay_update=True)
            p = controller.get_pipeline(version, do_validate=False)

            matches = set()
            queryModuleNameIndex = {}
            for moduleId, module in p.modules.iteritems():
                append_to_dict_of_lists(queryModuleNameIndex, module.name,
                                        moduleId)
            for querySourceId in self.queryPipeline.graph.sources():
                querySourceName = self.queryPipeline.modules[
                    querySourceId].name
                if not queryModuleNameIndex.has_key(querySourceName):
                    # need to reset matches here!
                    matches = set()
                    continue
                candidates = queryModuleNameIndex[querySourceName]
                atLeastOneMatch = False
                for candidateSourceId in candidates:
                    querySource = self.queryPipeline.modules[querySourceId]
                    candidateSource = p.modules[candidateSourceId]
                    if not self.matchQueryModule(candidateSource, querySource):
                        continue
                    (match, targetIds) = self.heuristicDAGIsomorphism \
                                             (template = self.queryPipeline,
                                              target = p,
                                              template_ids = [querySourceId],
                                              target_ids = [candidateSourceId])
                    if match:
                        atLeastOneMatch = True
                        matches.update(targetIds)

                # We always perform AND operation
                if not atLeastOneMatch:
                    matches = set()
                    break

            for m in matches:
                result.append((version, m))

        self.queryResult = result
        self.computeIndices()
        return result
Exemplo n.º 50
0
    def change_configuration(self, item, col):
        if item.flags() & QtCore.Qt.ItemIsEditable:
            new_value = self.indexFromItem(item, col).data()
            item.change_value(new_value)
            # option-specific code
            if item._name == 'dbDefault':
                # Update the state of the icons if changing between db and
                # file support
                dbState = getattr(get_vistrails_configuration(), 'dbDefault')
                if new_value != dbState:
                    from vistrails.gui.vistrails_window import _app
                    _app.setDBDefault(dbState)

            self.emit(QtCore.SIGNAL('configuration_changed'), item, new_value)
Exemplo n.º 51
0
def get_load_file_locator_from_gui(parent, obj_type):
    suffixes = "*" + " *".join(suffix_map[obj_type])
    fileName = QtGui.QFileDialog.getOpenFileName(
        parent, "Open %s..." % obj_type.capitalize(),
        vistrails.core.system.vistrails_file_directory(),
        "VisTrails files (%s)\nOther files (*)" % suffixes)
    if not fileName:
        return None
    filename = os.path.abspath(str(QtCore.QFile.encodeName(fileName)))
    dirName = os.path.dirname(filename)
    setattr(get_vistrails_persistent_configuration(), 'fileDir', dirName)
    setattr(get_vistrails_configuration(), 'fileDir', dirName)
    vistrails.core.system.set_vistrails_file_directory(dirName)
    return FileLocator(filename)
Exemplo n.º 52
0
    def updateVersion(self, versionNumber):
        """ updateVersion(versionNumber: int) -> None
        Update the property page of the version
        
        """
        self.versionNumber = versionNumber
        self.versionNotes.updateVersion(versionNumber)
        self.versionThumbs.updateVersion(versionNumber)
        self.versionMashups.updateVersion(versionNumber)
        if self.controller:
            vistrail = self.controller.vistrail
            if self.use_custom_colors:
                custom_color = vistrail.get_action_annotation(
                    versionNumber, custom_color_key)
                if custom_color is not None:
                    try:
                        custom_color = parse_custom_color(custom_color.value)
                        custom_color = QtGui.QColor(*custom_color)
                    except ValueError, e:
                        debug.warning("Version %r has invalid color "
                                      "annotation (%s)" % (versionNumber, e))
                        custom_color = None
                self.customColor.setColor(custom_color)

            if vistrail.actionMap.has_key(versionNumber):
                # Follow upgrades forward to find tag
                tag = self.controller.get_tag(versionNumber)
                if getattr(get_vistrails_configuration(), 'hideUpgrades',
                           True):
                    base_ver = vistrail.get_base_upgrade_version(versionNumber)
                else:
                    base_ver = versionNumber

                action = vistrail.actionMap[base_ver]
                self.tagEdit.setText(tag)
                self.userEdit.setText(action.user)
                self.dateEdit.setText(action.date)
                if base_ver != versionNumber:
                    version_text = '%s (%s)' % (versionNumber, base_ver)
                else:
                    version_text = '%s' % base_ver

                self.idEdit.setText(version_text)
                self.tagEdit.setEnabled(True)
                return
            else:
                self.tagEdit.setEnabled(False)
                self.tagReset.setEnabled(False)
Exemplo n.º 53
0
def unexpected_exception(e, tb=None, frame=None):
    """Marks an exception that we might want to debug.

    Before logging an exception or showing a message (potentially with
    format_exception()), you might want to call this. It's a no-op unless
    debugging is enabled in the configuration, in which case it will start a
    debugger.
    """
    if tb is None:
        tb = sys.exc_info()[2]
    if frame is None:
        tb_it = tb
        while tb_it.tb_next is not None:
            tb_it = tb_it.tb_next
        frame = tb_it.tb_frame

    # Whether to use the debugger
    try:
        from vistrails.core.configuration import get_vistrails_configuration
        debugger = getattr(get_vistrails_configuration(),
                           'developerDebugger',
                           False)
    except Exception:
        debugger = False
    if not debugger:
        return

    # Removes PyQt's input hook
    try:
        from PyQt4 import QtCore
    except ImportError:
        pass
    else:
        QtCore.pyqtRemoveInputHook()

    # Prints the exception and traceback
    print >>sys.stderr, "!!!!!!!!!!"
    print >>sys.stderr, "Got unexpected exception, starting debugger"
    print_exception(None, e, tb, 3, file=sys.stderr)

    # Starts the debugger
    print >>sys.stderr, "!!!!!!!!!!"
    # pdb.post_mortem()
    p = pdb.Pdb()
    p.reset()
    p.interaction(frame, tb)
Exemplo n.º 54
0
def require_python_module(module_name, dep_dict=None):
    """Fail if the given Python module isn't importable and can't be installed.

    This raises `MissingRequirements` and is thus suitable for use in a
    package's `package_requirements()` function. If `dep_dict` is provided, it
    will try to install the requirement before failing, using
    :func:`~vistrails.core.bundles.installbundle.install`.

    :raises MissingRequirement: on error
    """
    exists = python_module_exists(module_name)
    if (not exists and dep_dict
            and getattr(get_vistrails_configuration(), 'installBundles')):
        vistrails.core.bundles.installbundle.install(dep_dict)
        exists = python_module_exists(module_name)
    if not exists:
        raise MissingRequirement(module_name)
Exemplo n.º 55
0
 def result_version_selected(self,
                             version_id,
                             by_click,
                             do_validate=True,
                             from_root=False,
                             double_click=False):
     if by_click:
         hide_upgrades = getattr(get_vistrails_configuration(),
                                 'hideUpgrades', True)
         self.query_controller.search.setCurrentController(
             self.vt_controller)
         self.vt_controller.change_selected_version(version_id,
                                                    hide_upgrades,
                                                    hide_upgrades,
                                                    from_root)
         if double_click:
             self.query_controller.set_level(QueryController.LEVEL_WORKFLOW)
             self.query_controller.show_workflow_matches()
Exemplo n.º 56
0
def package_dependencies():
    import vistrails.core.packagemanager
    manager = vistrails.core.packagemanager.get_package_manager()

    reg = vistrails.core.modules.module_registry.get_module_registry()
    conf = get_vistrails_configuration()

    abstraction_dir = get_vistrails_directory("subworkflowsDir")
    if abstraction_dir is None:
        debug.log("Subworkflows directory unset, cannot add any abstractions")
        return []
    p = re.compile(r".*\.xml")
    all_packages = set()
    for abstraction in os.listdir(abstraction_dir):
        if p.match(abstraction):
            abs_fname = os.path.join(abstraction_dir, abstraction)
            vistrail = read_vistrail(abs_fname)
            try:
                dependencies = get_abstraction_dependencies(vistrail)
            except vistrails.core.modules.module_registry.MissingPackage, e:
                dependencies = {e._identifier: set()}
            add_abstraction = True
            inter_depends = []
            for package, depends in dependencies.iteritems():
                if package != identifier:
                    if not manager.has_package(package):
                        add_abstraction = False
                        break
                else:
                    inter_depends.append(depends)
            if add_abstraction:
                # print 'adding', abstraction[:-4]
                all_packages.update(p for p in dependencies.iterkeys()
                                    if p != identifier)
                my_vistrails[abstraction[:-4]] = \
                    (vistrail, abs_fname, inter_depends)
            else:
                debug.critical(
                    ("Subworkflow '%s' is missing packages it " + "depends on")
                    % abstraction)