示例#1
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)
示例#2
0
 def parse(self, filename):
     """parse(filename: str) -> None  
     Loads a list of connections from a XML file, appending it to
     self.__connections.
     
     """
     self.open_file(filename)
     root = self.dom.documentElement
     for element in named_elements(root, 'connection'):
         self.add_connection(ExtConnection.parse(element))
     self.refresh_current_id()
示例#3
0
 def parse(self, filename):
     """parse(filename: str) -> None  
     Loads a list of connections from a XML file, appending it to
     self.__connections.
     
     """
     self.open_file(filename)
     root = self.dom.documentElement
     for element in named_elements(root, 'connection'):
         self.add_connection(ExtConnection.parse(element))
     self.refresh_current_id()
 def parse_locator(text):
     locator = None
     wrapper = XMLWrapper()
     dom = wrapper.create_document_from_string(text)
     root = dom.documentElement
     version = None
     version = root.getAttribute('version')
     if version == '1.0':
         for element in named_elements(root, 'locator'):
             if str(element.getAttribute('type')) == 'file':
                 locator = FileLocator.parse(element)
             elif str(element.getAttribute('type')) == 'db':
                 locator = DBLocator.parse(element)
     return locator
 def parse_locator(text):
     locator = None
     wrapper = XMLWrapper()
     dom = wrapper.create_document_from_string(text)
     root = dom.documentElement
     version = None
     version = root.getAttribute('version')
     if version == '1.0':
         for element in named_elements(root, 'locator'):
             if str(element.getAttribute('type')) == 'file':
                 locator = FileLocator.parse(element)
             elif str(element.getAttribute('type')) == 'db':
                 locator = DBLocator.parse(element)
     return locator
示例#6
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
示例#7
0
    def load_packages(self):
        """load_packages() -> None

        Loads the appropriate packages from .vistrails/startup.xml.
        """
        
        for package_name in self._needed_packages:
            self._package_manager.add_package(package_name)

        def parse_package(node):
            is_value = (lambda node: node.nodeName in
                        set(['bool', 'str', 'int', 'float']))
            package_name = str(node.attributes['name'].value)
            # FIXME use more robust checks here!
            if package_name != 'basic_modules' and \
                    package_name != 'abstraction':
                self._package_manager.add_package(package_name)
        dom = self.startup_dom()
        doc = dom.documentElement
        packages_node = enter_named_element(doc, 'packages')
        for package_node in named_elements(packages_node, 'package'):
            parse_package(package_node)