Exemplo n.º 1
0
 def persist_configuration(self, no_update=False):
     if self.load_configuration:
         if not no_update:
             self.persistent_configuration.update(self.configuration)
         # make sure startup is updated to reflect changes
         get_vistrails_application().startup.persist_pkg_configuration(
             self.codepath, self.persistent_configuration)
Exemplo n.º 2
0
 def persist_configuration(self, no_update=False):
     if self.load_configuration:
         if not no_update:
             self.persistent_configuration.update(self.configuration)
         # make sure startup is updated to reflect changes
         get_vistrails_application().startup.persist_pkg_configuration(
             self.codepath, self.persistent_configuration)
Exemplo n.º 3
0
 def set_persistent_configuration(self):
     (dom, element) = self.find_own_dom_element()
     child = enter_named_element(element, 'configuration')
     if child:
         element.removeChild(child)
     self.configuration.write_to_dom(dom, element)
     get_vistrails_application().vistrailsStartup.write_startup_dom(dom)
     dom.unlink()
Exemplo n.º 4
0
 def configuration_changed(self, item, new_value):
     """ configuration_changed(item: QTreeWidgetItem *, 
     new_value: QString) -> None
     Write the current session configuration to startup.xml.
     Note:  This is already happening on close to capture configuration
     items that are not set in preferences.  We are doing this here too, so
     we guarantee the changes were saved before VisTrails crashes.
     
     """
     from vistrails.gui.application import get_vistrails_application
     get_vistrails_application().save_configuration()
Exemplo n.º 5
0
 def configuration_changed(self, item, new_value):
     """ configuration_changed(item: QTreeWidgetItem *, 
     new_value: QString) -> None
     Write the current session configuration to startup.xml.
     Note:  This is already happening on close to capture configuration
     items that are not set in preferences.  We are doing this here too, so
     we guarantee the changes were saved before VisTrails crashes.
     
     """
     from vistrails.gui.application import get_vistrails_application
     get_vistrails_application().save_configuration()
Exemplo n.º 6
0
 def _move_package_node(self, dom, where, node):
     doc = dom.documentElement
     packages = enter_named_element(doc, 'packages')
     oldpackages = enter_named_element(doc, 'disabledpackages')
     if where == 'enabled':
         oldpackages.removeChild(node)
         packages.appendChild(node)
     elif where == 'disabled':
         packages.removeChild(node)
         oldpackages.appendChild(node)
     else:
         raise ValueError
     get_vistrails_application().vistrailsStartup.write_startup_dom(dom)
Exemplo n.º 7
0
    def initialize_packages(self, prefix_dictionary={},
                            report_missing_dependencies=True):
        """initialize_packages(prefix_dictionary={}): None

        Initializes all installed packages. If prefix_dictionary is
        not {}, then it should be a dictionary from package names to
        the prefix such that prefix + package_name is a valid python
        import."""

        failed = []
        # import the modules
        app = get_vistrails_application()
        for package in self._package_list.itervalues():
            # print '+ initializing', package.codepath, id(package)
            if package.initialized():
                # print '- already initialized'
                continue
            try:
                prefix = prefix_dictionary.get(package.codepath)
                if prefix is None:
                    prefix = self._default_prefix_dict.get(package.codepath)
                package.load(prefix)
            except Package.LoadFailed, e:
                debug.critical("Package %s failed to load and will be "
                               "disabled" % package.name, e)
                # We disable the package manually to skip over things
                # we know will not be necessary - the only thing needed is
                # the reference in the package list
                self._startup.set_package_to_disabled(package.codepath)
                failed.append(package)
            except MissingRequirement, e:
                debug.critical("Package <codepath %s> is missing a "
                               "requirement: %s" % (
                                   package.codepath, e.requirement),
                               e)
Exemplo n.º 8
0
    def initialize_packages(self,
                            prefix_dictionary={},
                            report_missing_dependencies=True):
        """Initializes all installed packages.

        :param prefix_dictionary: dictionary from package names to the prefix
        such that prefix + package_name is a valid python import.
        :type prefix_dictionary: dict
        """
        failed = []
        # import the modules
        app = get_vistrails_application()
        for package in self._package_list.itervalues():
            # print '+ initializing', package.codepath, id(package)
            if package.initialized():
                # print '- already initialized'
                continue
            try:
                prefix = prefix_dictionary.get(package.codepath)
                if prefix is None:
                    prefix = self._default_prefix_dict.get(package.codepath)
                package.load(prefix)
            except Package.LoadFailed, e:
                debug.critical(
                    "Package %s failed to load and will be disabled" %
                    (package.name or ("<codepath %s>" % package.codepath)), e)
                # We disable the package manually to skip over things
                # we know will not be necessary - the only thing needed is
                # the reference in the package list
                self._startup.set_package_to_disabled(package.codepath)
                failed.append(package)
            except MissingRequirement, e:
                debug.critical(
                    "Package <codepath %s> is missing a "
                    "requirement: %s" % (package.codepath, e.requirement), e)
Exemplo n.º 9
0
 def remove_menu_items(self, pkg):
     """remove_menu_items(pkg: Package) -> None
     Send a signal with the pkg identifier. The builder window should
     catch this signal and remove the package menu items"""
     if pkg.menu_items():
         app = get_vistrails_application()
         app.send_notification("pm_remove_package_menu", pkg.identifier)
Exemplo n.º 10
0
 def remove_menu_items(self, pkg):
     """remove_menu_items(pkg: Package) -> None
     Send a signal with the pkg identifier. The builder window should
     catch this signal and remove the package menu items"""
     if pkg.menu_items():
         app = get_vistrails_application()
         app.send_notification("pm_remove_package_menu", pkg.identifier)
Exemplo n.º 11
0
    def remove_menu_items(self, pkg):
        """Emit the appropriate signal if the package has menu items.

        :type pkg: Package
        """
        if pkg.menu_items():
            app = get_vistrails_application()
            app.send_notification("pm_remove_package_menu", pkg.identifier)
Exemplo n.º 12
0
    def show_error_message(self, pkg, msg):
        """show_error_message(pkg: Package, msg: str) -> None
        Print a message to standard error output and emit a signal to the
        builder so if it is possible, a message box is also shown """

        debug.critical("Package %s (%s) says: %s" % (pkg.name, pkg.identifier, msg))
        app = get_vistrails_application()
        app.send_notification("pm_package_error_message", pkg.identifier, pkg.name, msg)
Exemplo n.º 13
0
    def remove_own_dom_element(self):
        """Moves the node to the <disabledpackages> section.
        """
        dom = get_vistrails_application().vistrailsStartup.startup_dom()

        node, section = self._get_package_node(dom, create='disabled')
        if section == 'enabled':
            self._move_package_node(dom, 'disabled', node)
Exemplo n.º 14
0
 def add_menu_items(self, pkg):
     """add_menu_items(pkg: Package) -> None
     If the package implemented the function menu_items(),
     the package manager will emit a signal with the menu items to
     be added to the builder window """
     items = pkg.menu_items()
     if items:
         app = get_vistrails_application()
         app.send_notification("pm_add_package_menu", pkg.identifier, pkg.name, items)
Exemplo n.º 15
0
 def connect_registry_signals(self):
     app = get_vistrails_application()
     app.register_notification("reg_new_module", self.newModule)
     app.register_notification("reg_new_package", self.newPackage)
     app.register_notification("reg_deleted_module", self.deletedModule)
     app.register_notification("reg_deleted_package", self.deletedPackage)
     app.register_notification("reg_show_module", self.showModule)
     app.register_notification("reg_hide_module", self.hideModule)
     app.register_notification("reg_module_updated", self.switchDescriptors)
Exemplo n.º 16
0
    def remove_menu_items(self, pkg):
        """Emit the appropriate signal if the package has menu items.

        :type pkg: Package
        """
        if pkg.menu_items():
            app = get_vistrails_application()
            app.send_notification("pm_remove_package_menu",
                                   pkg.identifier)
Exemplo n.º 17
0
 def connect_registry_signals(self):
     app = get_vistrails_application()
     app.register_notification("reg_new_module", self.newModule)
     app.register_notification("reg_new_package", self.newPackage)
     app.register_notification("reg_deleted_module", self.deletedModule)
     app.register_notification("reg_deleted_package", self.deletedPackage)
     app.register_notification("reg_show_module", self.showModule)
     app.register_notification("reg_hide_module", self.hideModule)
     app.register_notification("reg_module_updated", self.switchDescriptors)
Exemplo n.º 18
0
 def show_error_message(self, pkg, msg):
     """Print and emit a notification for an error message.
     """
     # TODO: isn't debug enough for the UI?
     debug.critical("Package %s (%s) says: %s" %
                    (pkg.name, pkg.identifier, msg))
     app = get_vistrails_application()
     app.send_notification("pm_package_error_message", pkg.identifier,
                           pkg.name, msg)
Exemplo n.º 19
0
def execute_pipeline(controller, pipeline,
                     reason, locator, version,
                     **kwargs):
    """Execute the pipeline while showing a progress dialog.
    """
    _ = translate('execute_pipeline')

    totalProgress = len(pipeline.modules)
    progress = QtGui.QProgressDialog(_("Executing..."),
                                     None,
                                     0, totalProgress)
    progress.setWindowTitle(_("Pipeline Execution"))
    progress.setWindowModality(QtCore.Qt.WindowModal)
    progress.show()

    def moduleExecuted(objId):
        progress.setValue(progress.value() + 1)
        QtCore.QCoreApplication.processEvents()

    if 'module_executed_hook' in kwargs:
        kwargs['module_executed_hook'].append(moduleExecuted)
    else:
        kwargs['module_executed_hook'] = [moduleExecuted]

    results, changed = controller.execute_workflow_list([(
        locator,        # locator
        version,        # version
        pipeline,       # pipeline
        DummyView(),    # view
        None,           # custom_aliases
        None,           # custom_params
        reason,         # reason
        None,           # sinks
        kwargs)])       # extra_info
    get_vistrails_application().send_notification('execution_updated')
    progress.setValue(totalProgress)
    progress.hide()
    progress.deleteLater()

    if not results[0].errors:
        return None
    else:
        module_id, error = next(results[0].errors.iteritems())
        return str(error)
Exemplo n.º 20
0
 def show_error_message(self, pkg, msg):
     """Print and emit a notification for an error message.
     """
     # TODO: isn't debug enough for the UI?
     debug.critical("Package %s (%s) says: %s"%(pkg.name,
                                                pkg.identifier,
                                                msg))
     app = get_vistrails_application()
     app.send_notification("pm_package_error_message", pkg.identifier,
                           pkg.name, msg)
Exemplo n.º 21
0
 def add_menu_items(self, pkg):
     """add_menu_items(pkg: Package) -> None
     If the package implemented the function menu_items(),
     the package manager will emit a signal with the menu items to
     be added to the builder window """
     items = pkg.menu_items()
     if items:
         app = get_vistrails_application()
         app.send_notification("pm_add_package_menu", pkg.identifier,
                               pkg.name, items)
Exemplo n.º 22
0
    def late_disable_package(self, codepath):
        """Disables a package 'late', i.e. after VisTrails initialization.

        Note that all the reverse dependencies need to already be disabled.
        """
        pkg = self.get_package_by_codepath(codepath)
        self.remove_package(codepath)
        app = get_vistrails_application()
        self._startup.set_package_to_disabled(codepath)
        self._startup.save_persisted_startup()
Exemplo n.º 23
0
    def add_menu_items(self, pkg):
        """Emit the appropriate signal if the package has menu items.

        :type pkg: Package
        """
        items = pkg.menu_items()
        if items:
            app = get_vistrails_application()
            app.send_notification("pm_add_package_menu", pkg.identifier,
                                  pkg.name, items)
Exemplo n.º 24
0
    def show_error_message(self, pkg, msg):
        """show_error_message(pkg: Package, msg: str) -> None
        Print a message to standard error output and emit a signal to the
        builder so if it is possible, a message box is also shown """

        debug.critical("Package %s (%s) says: %s" %
                       (pkg.name, pkg.identifier, msg))
        app = get_vistrails_application()
        app.send_notification("pm_package_error_message", pkg.identifier,
                              pkg.name, msg)
Exemplo n.º 25
0
    def late_disable_package(self, codepath):
        """Disables a package 'late', i.e. after VisTrails initialization.

        Note that all the reverse dependencies need to already be disabled.
        """
        pkg = self.get_package_by_codepath(codepath)
        self.remove_package(codepath)
        app = get_vistrails_application()
        self._startup.set_package_to_disabled(codepath)
        self._startup.save_persisted_startup()
Exemplo n.º 26
0
    def add_menu_items(self, pkg):
        """Emit the appropriate signal if the package has menu items.

        :type pkg: Package
        """
        items = pkg.menu_items()
        if items:
            app = get_vistrails_application()
            app.send_notification("pm_add_package_menu", pkg.identifier,
                                  pkg.name, items)
Exemplo n.º 27
0
    def find_own_dom_element(self):
        """find_own_dom_element() -> (DOM, Node)

        Opens the startup DOM, looks for the element that belongs to the package,
        and returns DOM and node. Creates a new one in the <disabledpackages>
        section if none is found.
        """
        dom = get_vistrails_application().vistrailsStartup.startup_dom()

        node, section = self._get_package_node(dom, create='disabled')
        return (dom, node)
Exemplo n.º 28
0
    def test_remove_package(self):
        """ Tests if the package really gets deleted, and that it gets
            selected again in the available packages list.
        """
        
        pkg = "URL"
        _app = get_vistrails_application()
        builder = _app.builderWindow
        builder.showPreferences()
        prefs = builder.preferencesDialog
        packages = prefs._packages_tab
        prefs._tab_widget.setCurrentWidget(packages)
        QtGui.QApplication.processEvents()

        # check if package is loaded
        av = packages._available_packages_list
        try:
            item, = av.findItems(pkg, QtCore.Qt.MatchExactly)
            av.setCurrentItem(item)
            QtGui.QApplication.processEvents()
            QtGui.QApplication.processEvents()
            packages.enable_current_package()
        except ValueError:
            # Already enabled
            pass
        QtGui.QApplication.processEvents()
        QtGui.QApplication.processEvents()

        inst = packages._enabled_packages_list
        item, = inst.findItems(pkg, QtCore.Qt.MatchExactly)
        inst.setCurrentItem(item)
        QtGui.QApplication.processEvents()
        QtGui.QApplication.processEvents()
        packages.disable_current_package()
        QtGui.QApplication.processEvents()
        QtGui.QApplication.processEvents()

        # force delayed calls
        packages.populate_lists()
        packages.select_package_after_update_slot(pkg)
        QtGui.QApplication.processEvents()
        QtGui.QApplication.processEvents()

        # This does not work because the selection is delayed
        av = packages._available_packages_list
        items = av.selectedItems()
        self.assertEqual(len(items), 1, "No available items selected!")
        self.assertEqual(items[0].text(), unicode(pkg),
                         "Wrong available item selected: %s" % items[0].text())

        # check if configuration has been written correctly
        startup = _app.startup
        self.assertIn(pkg, startup.disabled_packages)
        self.assertNotIn(pkg, startup.enabled_packages)
Exemplo n.º 29
0
    def test_remove_package(self):
        """ Tests if the package really gets deleted, and that it gets
            selected again in the available packages list.
        """

        pkg = "URL"
        _app = get_vistrails_application()
        builder = _app.builderWindow
        builder.showPreferences()
        prefs = builder.preferencesDialog
        packages = prefs._packages_tab
        prefs._tab_widget.setCurrentWidget(packages)
        QtGui.QApplication.processEvents()

        # check if package is loaded
        av = packages._available_packages_list
        try:
            item, = av.findItems(pkg, QtCore.Qt.MatchExactly)
            av.setCurrentItem(item)
            QtGui.QApplication.processEvents()
            QtGui.QApplication.processEvents()
            packages.enable_current_package()
        except ValueError:
            # Already enabled
            pass
        QtGui.QApplication.processEvents()
        QtGui.QApplication.processEvents()

        inst = packages._enabled_packages_list
        item, = inst.findItems(pkg, QtCore.Qt.MatchExactly)
        inst.setCurrentItem(item)
        QtGui.QApplication.processEvents()
        QtGui.QApplication.processEvents()
        packages.disable_current_package()
        QtGui.QApplication.processEvents()
        QtGui.QApplication.processEvents()

        # force delayed calls
        packages.populate_lists()
        packages.select_package_after_update_slot(pkg)
        QtGui.QApplication.processEvents()
        QtGui.QApplication.processEvents()

        # This does not work because the selection is delayed
        av = packages._available_packages_list
        items = av.selectedItems()
        self.assertEqual(len(items), 1, "No available items selected!")
        self.assertEqual(items[0].text(), unicode(pkg),
                         "Wrong available item selected: %s" % items[0].text())

        # check if configuration has been written correctly
        startup = _app.startup
        self.assertIn(pkg, startup.disabled_packages)
        self.assertNotIn(pkg, startup.enabled_packages)
Exemplo n.º 30
0
    def test_remove_package(self):
        """ Tests if the package really gets deleted, and that it gets
            selected again in the available packages list.
        """
        
        pkg = "dialogs"
        _app = get_vistrails_application()
        builder = _app.builderWindow
        builder.showPreferences()
        prefs = builder.preferencesDialog
        packages = prefs._packages_tab
        prefs._tab_widget.setCurrentWidget(packages)

        # check if package is loaded
        av = packages._available_packages_list
        for item in av.findItems(pkg, QtCore.Qt.MatchExactly):
            av.setCurrentItem(item)
            packages.enable_current_package()
            QtCore.QCoreApplication.processEvents()

        inst = packages._enabled_packages_list
        for item in inst.findItems(pkg, QtCore.Qt.MatchExactly):
            inst.setCurrentItem(item)
            packages.disable_current_package()
            QtCore.QCoreApplication.processEvents()

        # force delayed calls
        packages.populate_lists()
        packages.select_package_after_update_slot(pkg)
        QtCore.QCoreApplication.processEvents()

        # This does not work because the selection is delayed
        av = packages._available_packages_list
        items = av.selectedItems()
        self.assertEqual(len(items), 1, "No available items selected!")
        self.assertEqual(items[0].text(), unicode(pkg),
                         "Wrong available item selected: %s" % items[0].text())
        # check if configuration has been written correctly
        startup = _app.vistrailsStartup
        doc = startup.startup_dom().documentElement
        disabledpackages = enter_named_element(doc, 'disabledpackages')
        dpackage = None
        for package_node in named_elements(disabledpackages, 'package'):
            if str(package_node.attributes['name'].value) == pkg:
                dpackage = package_node
        self.assertIsNotNone(dpackage, "Removed package '%s' is not in unloaded packages list!" % pkg)

        epackages = enter_named_element(doc, 'packages')
        apackage = None
        for package_node in named_elements(epackages, 'package'):
            if str(package_node.attributes['name'].value) == pkg:
                apackage = package_node
        self.assertIsNone(apackage, "Removed package '%s' is still in loaded packages list!" % pkg)
Exemplo n.º 31
0
Arquivo: __init__.py Projeto: rbax/DAT
def execute_pipeline(controller, pipeline, reason, locator, version, **kwargs):
    """Execute the pipeline while showing a progress dialog.
    """
    _ = translate('execute_pipeline')

    totalProgress = len(pipeline.modules)
    progress = QtGui.QProgressDialog(_("Executing..."), None, 0, totalProgress)
    progress.setWindowTitle(_("Pipeline Execution"))
    progress.setWindowModality(QtCore.Qt.WindowModal)
    progress.show()

    def moduleExecuted(objId):
        progress.setValue(progress.value() + 1)
        QtCore.QCoreApplication.processEvents()

    if 'module_executed_hook' in kwargs:
        kwargs['module_executed_hook'].append(moduleExecuted)
    else:
        kwargs['module_executed_hook'] = [moduleExecuted]

    results, changed = controller.execute_workflow_list([(
        locator,  # locator
        version,  # version
        pipeline,  # pipeline
        DummyView(),  # view
        None,  # custom_aliases
        None,  # custom_params
        reason,  # reason
        None,  # sinks
        kwargs)])  # extra_info
    get_vistrails_application().send_notification('execution_updated')
    progress.setValue(totalProgress)
    progress.hide()
    progress.deleteLater()

    if not results[0].errors:
        return None
    else:
        module_id, error = next(results[0].errors.iteritems())
        return str(error)
Exemplo n.º 32
0
    def reset_configuration(self):
        """Reset package configuration to original package settings.
        """

        (dom, element) = self.find_own_dom_element()
        doc = dom.documentElement
        configuration = enter_named_element(element, 'configuration')
        if configuration:
            element.removeChild(configuration)
        self.configuration = copy.copy(self._initial_configuration)

        startup = get_vistrails_application().vistrailsStartup
        startup.write_startup_dom(dom)
Exemplo n.º 33
0
    def _get_package_node(self, dom, create):
        doc = dom.documentElement
        packages = enter_named_element(doc, 'packages')
        for package_node in named_elements(packages, 'package'):
            if package_node.attributes['name'].value == self.codepath:
                return package_node, 'enabled'
        oldpackages = enter_named_element(doc, 'disabledpackages')
        for package_node in named_elements(oldpackages, 'package'):
            if package_node.attributes['name'].value == self.codepath:
                return package_node, 'disabled'

        if create is None:
            return None, None
        else:
            package_node = dom.createElement('package')
            package_node.setAttribute('name', self.codepath)
            if create == 'enabled':
                packages.appendChild(package_node)
            elif create == 'disabled':
                oldpackages.appendChild(package_node)
            else:
                raise ValueError
            get_vistrails_application().vistrailsStartup.write_startup_dom(dom)
            return package_node, create
Exemplo n.º 34
0
    def create_startup_package_node(self):
        """Writes the node to the <packages> section.

        If it was in the <disabledpackages> section, move it, else, create it.
        """
        dom = get_vistrails_application().vistrailsStartup.startup_dom()

        node, section = self._get_package_node(dom, create='enabled')
        if section == 'disabled':
            self._move_package_node(dom, 'enabled', node)

        configuration = enter_named_element(node, 'configuration')
        if configuration:
            self.configuration.set_from_dom_node(configuration)

        dom.unlink()
Exemplo n.º 35
0
    def reload_package_disable(self, codepath):
        # for all reverse dependencies, disable them
        prefix_dictionary = {}
        pkg = self.get_package_by_codepath(codepath)
        reverse_deps = []
        for dep_id in self.all_reverse_dependencies(pkg.identifier):
            reverse_deps.append(self.get_package(dep_id))

        for dep_pkg in reverse_deps:
            prefix_dictionary[dep_pkg.codepath] = dep_pkg.prefix
            self.late_disable_package(dep_pkg.codepath)

        # Queue the re-enabling of the packages so event loop can free
        # any QObjects whose deleteLater() method is invoked
        app = get_vistrails_application()
        app.send_notification("pm_reloading_package", codepath, reverse_deps, prefix_dictionary)
Exemplo n.º 36
0
    def reload_package_disable(self, codepath):
        # for all reverse dependencies, disable them
        prefix_dictionary = {}
        pkg = self.get_package_by_codepath(codepath)
        reverse_deps = []
        for dep_id in self.all_reverse_dependencies(pkg.identifier):
            reverse_deps.append(self.get_package(dep_id))

        for dep_pkg in reverse_deps:
            prefix_dictionary[dep_pkg.codepath] = dep_pkg.prefix
            self.late_disable_package(dep_pkg.codepath)

        # Queue the re-enabling of the packages so event loop can free
        # any QObjects whose deleteLater() method is invoked
        app = get_vistrails_application()
        app.send_notification("pm_reloading_package", codepath, reverse_deps,
                              prefix_dictionary)
Exemplo n.º 37
0
    def remove_package(self, codepath):
        """remove_package(name): Removes a package from the system."""
        pkg = self._package_list[codepath]

        from vistrails.core.interpreter.cached import CachedInterpreter
        CachedInterpreter.clear_package(pkg.identifier)

        self._dependency_graph.delete_vertex(pkg.identifier)
        del self._package_versions[pkg.identifier][pkg.version]
        if len(self._package_versions[pkg.identifier]) == 0:
            del self._package_versions[pkg.identifier]
        self.remove_old_identifiers(pkg.identifier)
        self.remove_menu_items(pkg)
        pkg.finalize()
        del self._package_list[codepath]
        self._registry.remove_package(pkg)
        app = get_vistrails_application()
        app.send_notification("package_removed", codepath)
Exemplo n.º 38
0
    def remove_package(self, codepath):
        """remove_package(name): Removes a package from the system."""
        pkg = self._package_list[codepath]

        from vistrails.core.interpreter.cached import CachedInterpreter
        CachedInterpreter.clear_package(pkg.identifier)

        self._dependency_graph.delete_vertex(pkg.identifier)
        del self._package_versions[pkg.identifier][pkg.version]
        if len(self._package_versions[pkg.identifier]) == 0:
            del self._package_versions[pkg.identifier]
        self.remove_old_identifiers(pkg.identifier)
        self.remove_menu_items(pkg)
        pkg.finalize()
        del self._package_list[codepath]
        self._registry.remove_package(pkg)
        app = get_vistrails_application()
        app.send_notification("package_removed", codepath)
Exemplo n.º 39
0
 def late_enable_package(self, codepath, prefix_dictionary={}, needs_add=True):
     """late_enable_package enables a package 'late', that is,
     after VisTrails initialization. All dependencies need to be
     already enabled.
     """
     if needs_add:
         if codepath in self._package_list:
             msg = "duplicate package identifier: %s" % codepath
             raise VistrailsInternalError(msg)
         self.add_package(codepath)
     app = get_vistrails_application()
     pkg = self.get_package_by_codepath(codepath)
     try:
         pkg.load(prefix_dictionary.get(pkg.codepath, None))
         # pkg.create_startup_package_node()
     except Exception, e:
         # invert self.add_package
         del self._package_list[codepath]
         raise
Exemplo n.º 40
0
    def _get_variables_root(controller=None):
        """Create or get the version tagged 'dat-vars'

        This is the base version of all DAT variables. It consists of a single
        OutputPort module with name 'value'.
        """
        if controller is None:
            controller = get_vistrails_application().get_controller()
            assert controller is not None
        if controller.vistrail.has_tag_str('dat-vars'):
            root_version = controller.vistrail.get_version_number('dat-vars')
        else:
            # Create the 'dat-vars' version
            controller.change_selected_version(0)
            reg = get_module_registry()
            operations = []

            # Add an OutputPort module
            descriptor = reg.get_descriptor_by_name(
                'org.vistrails.vistrails.basic', 'OutputPort')
            out_mod = controller.create_module_from_descriptor(descriptor)
            operations.append(('add', out_mod))

            # Add a function to this module
            operations.extend(
                controller.update_function_ops(
                    out_mod,
                    'name',
                    ['value']))

            # Perform the operations
            action = create_action(operations)
            controller.add_new_action(action)
            root_version = controller.perform_action(action)
            # Tag as 'dat-vars'
            controller.vistrail.set_tag(root_version, 'dat-vars')

        controller.change_selected_version(root_version)
        pipeline = controller.current_pipeline
        outmod_id = pipeline.modules.keys()
        assert len(outmod_id) == 1
        outmod_id = outmod_id[0]
        return controller, root_version, outmod_id
Exemplo n.º 41
0
    def startDrag(self, actions):
        indexes = self.selectedIndexes()
        if len(indexes) > 0:
            mime_data = self.model().mimeData(indexes)
            drag = QtGui.QDrag(self)
            drag.setMimeData(mime_data)
            item = mime_data.items[0]

            app = get_vistrails_application()
            pipeline_view = app.builderWindow.get_current_controller().current_pipeline_view
            if hasattr(pipeline_view.scene(), 'add_tmp_module'):
                module_item = \
                    pipeline_view.scene().add_tmp_module(item.descriptor)
                pixmap = pipeline_view.paintModuleToPixmap(module_item)

                drag.setPixmap(pixmap)
                drag.setHotSpot(QtCore.QPoint(pixmap.width()/2,
                                              pixmap.height()/2))
                drag.exec_(actions)
                pipeline_view.scene().delete_tmp_module()
Exemplo n.º 42
0
 def late_enable_package(self, codepath, prefix_dictionary={},
                         needs_add=True):
     """late_enable_package enables a package 'late', that is,
     after VisTrails initialization. All dependencies need to be
     already enabled.
     """
     if needs_add:
         if codepath in self._package_list:
             msg = 'duplicate package identifier: %s' % codepath
             raise VistrailsInternalError(msg)
         self.add_package(codepath)
     app = get_vistrails_application()
     pkg = self.get_package_by_codepath(codepath)
     try:
         pkg.load(prefix_dictionary.get(pkg.codepath, None))
         # pkg.create_startup_package_node()
     except Exception, e:
         # invert self.add_package
         del self._package_list[codepath]
         raise
Exemplo n.º 43
0
    def __init__(self, parent, persistent_config, temp_config):
        QtGui.QWidget.__init__(self, parent)

        self.persistent_config = persistent_config
        self.temp_config = temp_config

        scroll_area = QtGui.QScrollArea()
        inner_widget =  QtGui.QWidget()
        self.inner_layout = QtGui.QVBoxLayout()
        inner_widget.setLayout(self.inner_layout)
        scroll_area.setWidget(inner_widget)
        scroll_area.setWidgetResizable(True)
        self.setLayout(QtGui.QVBoxLayout())
        self.layout().addWidget(scroll_area, 1)
        self.layout().setContentsMargins(0,0,0,0)

        app = get_vistrails_application()
        app.register_notification("package_added", self.update_output_modules)
        app.register_notification("package_removed", self.update_output_modules)

        self.mode_widgets = {}
Exemplo n.º 44
0
    def startDrag(self, actions):
        indexes = self.selectedIndexes()
        if len(indexes) > 0:
            mime_data = self.model().mimeData(indexes)
            drag = QtGui.QDrag(self)
            drag.setMimeData(mime_data)
            item = mime_data.items[0]

            app = get_vistrails_application()
            pipeline_view = app.builderWindow.get_current_controller(
            ).current_pipeline_view
            if hasattr(pipeline_view.scene(), 'add_tmp_module'):
                module_item = \
                    pipeline_view.scene().add_tmp_module(item.descriptor)
                pixmap = pipeline_view.paintModuleToPixmap(module_item)

                drag.setPixmap(pixmap)
                drag.setHotSpot(
                    QtCore.QPoint(pixmap.width() / 2,
                                  pixmap.height() / 2))
                drag.exec_(actions)
                pipeline_view.scene().delete_tmp_module()
Exemplo n.º 45
0
def hide_splash_if_necessary():
    """Disables the splashscreen, otherwise it sits in front of windows.
    """
    app = get_vistrails_application()
    if hasattr(app, 'splashScreen') and app.splashScreen:
        app.splashScreen.hide()
Exemplo n.º 46
0
    def __init__(self, parent):
        QtGui.QWidget.__init__(self, parent)

        base_layout = QtGui.QHBoxLayout(self)

        left = QtGui.QFrame(self)
        right = QtGui.QFrame(self)

        base_layout.addWidget(left)
        base_layout.addWidget(right, 1)

        ######################################################################
        left_layout = QtGui.QVBoxLayout(left)
        left_layout.addWidget(QtGui.QLabel("Disabled packages:", left))
        self._available_packages_list = QtGui.QListWidget(left)
        left_layout.addWidget(self._available_packages_list)
        left_layout.addWidget(QtGui.QLabel("Enabled packages:", left))
        self._enabled_packages_list = QtGui.QListWidget(left)
        left_layout.addWidget(self._enabled_packages_list)
        self.update_button = QtGui.QPushButton("Refresh Lists", left)
        left_layout.addWidget(self.update_button, 0, QtCore.Qt.AlignLeft)

        self.update_button.clicked.connect(self.populate_lists)

        self.connect(self._available_packages_list,
                     QtCore.SIGNAL('itemSelectionChanged()'),
                     self.selected_available_list, QtCore.Qt.QueuedConnection)

        self.connect(self._enabled_packages_list,
                     QtCore.SIGNAL('itemSelectionChanged()'),
                     self.selected_enabled_list, QtCore.Qt.QueuedConnection)

        sm = QtGui.QAbstractItemView.SingleSelection
        self._available_packages_list.setSelectionMode(sm)
        self._enabled_packages_list.setSelectionMode(sm)

        ######################################################################
        right_layout = QtGui.QVBoxLayout(right)
        info_frame = QtGui.QFrame(right)

        info_layout = QtGui.QVBoxLayout(info_frame)
        grid_frame = QtGui.QFrame(info_frame)
        grid_frame.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                 QtGui.QSizePolicy.Expanding)

        info_layout.addWidget(grid_frame)
        grid_layout = QtGui.QGridLayout(grid_frame)
        l1 = QtGui.QLabel("Package Name:", grid_frame)
        grid_layout.addWidget(l1, 0, 0)
        l2 = QtGui.QLabel("Identifier:", grid_frame)
        grid_layout.addWidget(l2, 1, 0)
        l3 = QtGui.QLabel("Version:", grid_frame)
        grid_layout.addWidget(l3, 2, 0)
        l4 = QtGui.QLabel("Dependencies:", grid_frame)
        grid_layout.addWidget(l4, 3, 0)
        l5 = QtGui.QLabel("Reverse Dependencies:", grid_frame)
        grid_layout.addWidget(l5, 4, 0)
        l6 = QtGui.QLabel("Description:", grid_frame)
        grid_layout.addWidget(l6, 5, 0)

        self._name_label = QtGui.QLabel("", grid_frame)
        grid_layout.addWidget(self._name_label, 0, 1)

        self._identifier_label = QtGui.QLabel("", grid_frame)
        grid_layout.addWidget(self._identifier_label, 1, 1)

        self._version_label = QtGui.QLabel("", grid_frame)
        grid_layout.addWidget(self._version_label, 2, 1)

        self._dependencies_label = QtGui.QLabel("", grid_frame)
        grid_layout.addWidget(self._dependencies_label, 3, 1)

        self._reverse_dependencies_label = QtGui.QLabel("", grid_frame)
        grid_layout.addWidget(self._reverse_dependencies_label, 4, 1)

        self._description_label = QtGui.QLabel("", grid_frame)
        grid_layout.addWidget(self._description_label, 5, 1)

        for lbl in [
                l1, l2, l3, l4, l5, l6, self._name_label, self._version_label,
                self._dependencies_label, self._identifier_label,
                self._reverse_dependencies_label, self._description_label
        ]:
            lbl.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft)
            lbl.setWordWrap(True)

        grid_layout.setRowStretch(4, 1)
        grid_layout.setColumnStretch(1, 1)

        right_layout.addWidget(info_frame)

        self._enable_button = QtGui.QPushButton("&Enable")
        self._enable_button.setEnabled(False)
        self.connect(self._enable_button, QtCore.SIGNAL("clicked()"),
                     self.enable_current_package)
        self._disable_button = QtGui.QPushButton("&Disable")
        self._disable_button.setEnabled(False)
        self.connect(self._disable_button, QtCore.SIGNAL("clicked()"),
                     self.disable_current_package)
        self._configure_button = QtGui.QPushButton("&Configure...")
        self._configure_button.setEnabled(False)
        self.connect(self._configure_button, QtCore.SIGNAL("clicked()"),
                     self.configure_current_package)
        self._reload_button = QtGui.QPushButton("&Reload")
        self._reload_button.setEnabled(False)
        self.connect(self._reload_button, QtCore.SIGNAL("clicked()"),
                     self.reload_current_package)
        button_box = QtGui.QDialogButtonBox()
        button_box.addButton(self._enable_button,
                             QtGui.QDialogButtonBox.ActionRole)
        button_box.addButton(self._disable_button,
                             QtGui.QDialogButtonBox.ActionRole)
        button_box.addButton(self._configure_button,
                             QtGui.QDialogButtonBox.ActionRole)
        button_box.addButton(self._reload_button,
                             QtGui.QDialogButtonBox.ActionRole)
        right_layout.addWidget(button_box)

        self.connect(self, self.select_package_after_update_signal,
                     self.select_package_after_update_slot,
                     QtCore.Qt.QueuedConnection)

        # pm = get_package_manager()
        # self.connect(pm,
        #              pm.reloading_package_signal,
        #              self.reload_current_package_finisher,
        #              QtCore.Qt.QueuedConnection)
        app = get_vistrails_application()
        app.register_notification("pm_reloading_package",
                                  self.reload_current_package_finisher)
        app.register_notification("package_added", self.package_added)
        app.register_notification("package_removed", self.package_removed)

        self.populate_lists()

        self._current_package = None
Exemplo n.º 47
0
 def vt_controller():
     app = get_vistrails_application()
     view = app.builderWindow.new_vistrail()
     controller = view.get_controller()
     VistrailManager.set_controller(controller, register=True)
     return controller
Exemplo n.º 48
0
 def get_key(self, key):
     return get_vistrails_application().keyChain.get_key(key)
Exemplo n.º 49
0
 def set_key(self, key, passwd):
     get_vistrails_application().keyChain.set_key(key, passwd)
Exemplo n.º 50
0
 def get_key(self, key):
     return get_vistrails_application().keyChain.get_key(key)
Exemplo n.º 51
0
                                       "requirement: %s" % (
                                           pkg.codepath, e.requirement),
                                       e)
                    self.late_disable_package(pkg.codepath)
                except Package.InitializationFailed, e:
                    debug.critical("Initialization of package <codepath %s> "
                                   "failed and will be disabled" %
                                   pkg.codepath,
                                   e)
                    # We disable the package manually to skip over things
                    # we know will not be necessary - the only thing needed is
                    # the reference in the package list
                    self.late_disable_package(pkg.codepath)
                else:
                    self.add_menu_items(pkg)
                    app = get_vistrails_application()
                    app.send_notification("package_added", pkg.codepath)

        self._startup.save_persisted_startup()

    def add_menu_items(self, pkg):
        """Emit the appropriate signal if the package has menu items.

        :type pkg: Package
        """
        items = pkg.menu_items()
        if items:
            app = get_vistrails_application()
            app.send_notification("pm_add_package_menu", pkg.identifier,
                                  pkg.name, items)
            # self.emit(self.add_package_menu_signal,
Exemplo n.º 52
0
                        debug.critical(
                            "Package <codepath %s> is missing a "
                            "requirement: %s" % (pkg.codepath, e.requirement),
                            e)
                    self.late_disable_package(pkg.codepath)
                except Package.InitializationFailed, e:
                    debug.critical(
                        "Initialization of package <codepath %s> "
                        "failed and will be disabled" % pkg.codepath, e)
                    # We disable the package manually to skip over things
                    # we know will not be necessary - the only thing needed is
                    # the reference in the package list
                    self.late_disable_package(pkg.codepath)
                else:
                    self.add_menu_items(pkg)
                    app = get_vistrails_application()
                    app.send_notification("package_added", pkg.codepath)

        self._startup.save_persisted_startup()

    def add_menu_items(self, pkg):
        """Emit the appropriate signal if the package has menu items.

        :type pkg: Package
        """
        items = pkg.menu_items()
        if items:
            app = get_vistrails_application()
            app.send_notification("pm_add_package_menu", pkg.identifier,
                                  pkg.name, items)
            # self.emit(self.add_package_menu_signal,