예제 #1
0
 def test_vtl_files(self):
     from vistrails.tests.utils import run_file
     for root, dirs, file_names in os.walk(self.vtl_path):
         for file_name in sorted(file_names):
             if file_name.endswith('.vtl'):
                 # update available packages
                 from vistrails.core.packagemanager import get_package_manager
                 get_package_manager().build_available_package_names_list()
                 f = os.path.join(root, file_name)
                 locator = FileLocator(f)
                 version = locator._vnode
                 # if there is a version specified try to execute it,
                 # else just load the pipeline
                 if version:
                     errors = run_file(f, lambda x: x == version)
                     self.assertEqual(errors, [], 'Errors processing %s: %s' % (f, str(errors)))
                 else:
                     import vistrails.core.db.io
                     from vistrails.core.vistrail.controller import \
                         VistrailController
                     loaded_objs = vistrails.core.db.io.load_vistrail(locator)
                     controller = VistrailController(loaded_objs[0],
                                                     locator,
                                                     *loaded_objs[1:])
                     controller.change_selected_version(
                         controller.vistrail.get_latest_version())
                     self.assertTrue(controller.current_pipeline.is_valid,
                                     "Latest pipeline is invalid: %s" % f)
예제 #2
0
 def test_vtl_files(self):
     from vistrails.tests.utils import run_file
     for root, dirs, file_names in os.walk(self.vtl_path):
         for file_name in sorted(file_names):
             if file_name.endswith('.vtl'):
                 # update available packages
                 from vistrails.core.packagemanager import get_package_manager
                 get_package_manager().build_available_package_names_list()
                 f = os.path.join(root, file_name)
                 locator = FileLocator(f)
                 version = locator._vnode
                 # if there is a version specified try to execute it,
                 # else just load the pipeline
                 if version:
                     errors = run_file(f, lambda x: x == version)
                     self.assertEqual(
                         errors, [],
                         'Errors processing %s: %s' % (f, str(errors)))
                 else:
                     import vistrails.core.db.io
                     from vistrails.core.vistrail.controller import \
                         VistrailController
                     loaded_objs = vistrails.core.db.io.load_vistrail(
                         locator)
                     controller = VistrailController(
                         loaded_objs[0], locator, *loaded_objs[1:])
                     controller.change_selected_version(
                         controller.vistrail.get_latest_version())
                     self.assertTrue(controller.current_pipeline.is_valid,
                                     "Latest pipeline is invalid: %s" % f)
예제 #3
0
    def createFailedPackage(self):
        """ Failed package is created so that the user can remove
        it manually using package submenu """
        pm = get_package_manager()
        if pm.has_package(self.signature):
            # do nothing
            return
        reg = vistrails.core.modules.module_registry.get_module_registry()

        # create a document hash integer from the cached sax tree
        # "name" is what suds use as the cache key
        name = '%s-%s' % (abs(hash(self.address)), "wsdl")
        self.wsdlHash = '0'

        package_id = reg.idScope.getNewId(Package.vtType)
        package = Package(id=package_id,
                          load_configuration=False,
                          name="SUDS#" + self.address,
                          identifier=self.signature,
                          version=self.wsdlHash,
                          )
        suds_package = reg.get_package_by_name(identifier)
        package._module = suds_package.module
        package._init_module = suds_package.init_module
        self.package = package
        reg.add_package(package)
        reg.signals.emit_new_package(self.signature)
        self.module = new_module(Module, str(self.signature))
        reg.add_module(self.module, **{'package':self.signature,
                                       'package_version':self.wsdlHash,
                                       'abstract':True})
        self.service = -1
예제 #4
0
 def operation_added(self, operation):
     pm = get_package_manager()
     package = pm.get_package(operation.package_identifier)
     item = OperationItem(operation, package.name, operation.wizard
                          is not None)
     self._operations[operation] = item
     self._list.addItem(item, package.name)
예제 #5
0
파일: global_data.py 프로젝트: rbax/DAT
    def new_package(self, package_identifier, prepend=False):
        """Called when a package is loaded in VisTrails.

        Discovers and registers Plots and VariableLoaders.
        """
        pm = get_package_manager()
        package = pm.get_package(package_identifier)
        if hasattr(package.init_module, '_plots'):
            for plot in package.init_module._plots:
                if not isinstance(plot, Plot):
                    warnings.warn(
                        "Package %s (%s) declares in _plots something "
                        "that is not a plot: %r" %
                        (package_identifier, package.codepath, plot))
                    continue
                plot.package_identifier = package_identifier

                # Resolve the port types
                for port in plot.ports:
                    port.type = resolve_descriptor(port.type,
                                                   package_identifier)

                # Read and check the metadata from the workflow
                try:
                    plot._read_metadata(package_identifier)
                except Exception, e:
                    warnings.warn("In package '%s'\n"
                                  "Couldn't read plot subworkflow for '%s':\n"
                                  "%s" % (package_identifier, plot.name, e))
                else:
                    self._add_plot(plot)
예제 #6
0
    def find_descriptor(controller, pipeline, module_id, desired_version=''):
        reg = get_module_registry()

        get_descriptor = reg.get_descriptor_by_name
        pm = get_package_manager()
        invalid_module = pipeline.modules[module_id]
        mpkg, mname, mnamespace, mid = (invalid_module.package,
                                        invalid_module.name,
                                        invalid_module.namespace,
                                        invalid_module.id)
        pkg = pm.get_package(mpkg)
        desired_version = ''
        d = None
        # don't check for abstraction/subworkflow since the old module
        # could be a subworkflow
        if reg.has_abs_upgrade(*invalid_module.descriptor_info):
            return reg.get_abs_upgrade(*invalid_module.descriptor_info)

        try:
            try:
                d = get_descriptor(mpkg, mname, mnamespace, '',
                                   desired_version)
            except MissingModule, e:
                r = None
                if pkg.can_handle_missing_modules():
                    r = pkg.handle_missing_module(controller, module_id,
                                                  pipeline)
                    d = get_descriptor(mpkg, mname, mnamespace, '',
                                       desired_version)
                if not r:
                    raise e
        except MissingModule, e:
            return None
예제 #7
0
    def new_package(self, package_identifier, prepend=False):
        """Called when a package is loaded in VisTrails.

        Discovers and registers Plots and VariableLoaders.
        """
        pm = get_package_manager()
        package = pm.get_package(package_identifier)
        if hasattr(package.init_module, '_plots'):
            for plot in package.init_module._plots:
                if not isinstance(plot, Plot):
                    warnings.warn(
                        "Package %s (%s) declares in _plots something "
                        "that is not a plot: %r" % (
                            package_identifier, package.codepath, plot))
                    continue
                plot.package_identifier = package_identifier

                # Resolve the port types
                for port in plot.ports:
                    port.type = resolve_descriptor(port.type,
                                                   package_identifier)

                # Read and check the metadata from the workflow
                try:
                    plot._read_metadata(package_identifier)
                except Exception, e:
                    warnings.warn("In package '%s'\n"
                                  "Couldn't read plot subworkflow for '%s':\n"
                                  "%s" % (package_identifier, plot.name, e))
                else:
                    self._add_plot(plot)
예제 #8
0
파일: api.py 프로젝트: tacaswell/VisTrails
 def load_package(self, identifier, codepath):
     packages = self.get_packages()
     if identifier not in packages:
         pm = get_package_manager()
         pm.late_enable_package(codepath)
         self._packages = None
     return self.get_package(identifier)
예제 #9
0
파일: operations.py 프로젝트: VisTrails/DAT
 def operation_added(self, operation):
     pm = get_package_manager()
     package = pm.get_package(operation.package_identifier)
     item = OperationItem(operation, package.name,
                          operation.wizard is not None)
     self._operations[operation] = item
     self._list.addItem(item, package.name)
예제 #10
0
    def find_descriptor(controller, pipeline, module_id, desired_version=''):
        reg = get_module_registry()

        get_descriptor = reg.get_descriptor_by_name
        pm = get_package_manager()
        invalid_module = pipeline.modules[module_id]
        mpkg, mname, mnamespace, mid = (invalid_module.package,
                                        invalid_module.name,
                                        invalid_module.namespace,
                                        invalid_module.id)
        pkg = pm.get_package(mpkg)
        desired_version = ''
        d = None
        # don't check for abstraction/subworkflow since the old module
        # could be a subworkflow
        if reg.has_abs_upgrade(*invalid_module.descriptor_info):
            return reg.get_abs_upgrade(*invalid_module.descriptor_info)

        try:
            try:
                d = get_descriptor(mpkg, mname, mnamespace, '', desired_version)
            except MissingModule, e:
                r = None
                if pkg.can_handle_missing_modules():
                    r = pkg.handle_missing_module(controller, module_id, 
                                                  pipeline)
                    d = get_descriptor(mpkg, mname, mnamespace, '', 
                                       desired_version)
                if not r:
                    raise e
        except MissingModule, e:
            return None
예제 #11
0
def package_dependencies():
    pm = get_package_manager()
    spreadsheet_identifier = 'org.vistrails.vistrails.spreadsheet'
    if pm.has_package(spreadsheet_identifier):
        return [spreadsheet_identifier]
    else: # pragma: no cover
        return []
예제 #12
0
def package_dependencies():
    pm = get_package_manager()
    spreadsheet_identifier = 'org.vistrails.vistrails.spreadsheet'
    if pm.has_package(spreadsheet_identifier):
        return [spreadsheet_identifier]
    else: # pragma: no cover
        return []
예제 #13
0
 def load_package(self, identifier, codepath):
     packages = self.get_packages()
     if identifier not in packages:
         pm = get_package_manager()
         pm.late_enable_package(codepath)
         self._packages = None
     return self.get_package(identifier)
예제 #14
0
def choose_operation(typecasts,
                     source_descriptor,
                     expected_descriptor,
                     parent=None):
    _ = translate('typecast_dialog')

    dialog = QtGui.QDialog(parent)
    dialog.setWindowTitle(_("Type casting"))
    layout = QtGui.QVBoxLayout()

    label = QtGui.QLabel(
        _("A {actual} variable was put in a {expected} port. These are not "
          "compatible, but the following operations can do the "
          "conversion:").format(
              actual="%s (%s)" % (source_descriptor.module.__name__,
                                  source_descriptor.identifier),
              expected="%s (%s)" % (expected_descriptor.module.__name__,
                                    expected_descriptor.identifier)))
    label.setWordWrap(True)
    layout.addWidget(label)
    list_widget = CategorizedListWidget()
    list_widget.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
    pm = get_package_manager()
    for operation in typecasts:
        package = pm.get_package(operation.package_identifier)
        item = OperationItem(operation, package.name)
        list_widget.addItem(item, item.category)
    layout.addWidget(list_widget)

    buttons = QtGui.QHBoxLayout()
    ok = QtGui.QPushButton(_("Typecast", "Accept typecast dialog button"))
    QtCore.QObject.connect(ok, QtCore.SIGNAL('clicked()'), dialog,
                           QtCore.SLOT('accept()'))
    buttons.addWidget(ok)
    cancel = QtGui.QPushButton(_("Cancel", "Reject typecast dialog button"))
    QtCore.QObject.connect(cancel, QtCore.SIGNAL('clicked()'), dialog,
                           QtCore.SLOT('reject()'))
    buttons.addWidget(cancel)
    layout.addLayout(buttons)

    def check_selection():
        selection = list_widget.selectedItems()
        if selection:
            item = selection[0]
            if isinstance(item, OperationItem):
                ok.setEnabled(True)
                return
        ok.setEnabled(False)

    QtCore.QObject.connect(list_widget,
                           QtCore.SIGNAL('itemSelectionChanged()'),
                           check_selection)
    check_selection()

    dialog.setLayout(layout)
    if dialog.exec_() == QtGui.QDialog.Accepted:
        return list_widget.selectedItems()[0].operation
    else:
        raise CancelExecution
예제 #15
0
파일: init.py 프로젝트: KenSuber/cwsl-mas
 def package_configuration():
     """
     Create a shortcut to Edit->Preferences->Module Package->Enabled Packages->Configure in menu.
     """
     pkgmgr = get_package_manager()
     package = pkgmgr.get_package(identifier)
     dlg = QPackageConfigurationDialog(None, package)
     dlg.exec_()
예제 #16
0
    def setUp(cls):
        cls._application = dat.tests.setup_application()

        pm = get_package_manager()

        pm.late_enable_package(
            'pkg_test_operations',
            {'pkg_test_operations': 'dat.tests.'})
예제 #17
0
파일: init.py 프로젝트: BowenYang/VisTrails
 def setUpClass(cls):
     from vistrails.core.packagemanager import get_package_manager
     from vistrails.core.modules.module_registry import MissingPackage
     pm = get_package_manager()
     try:
         pm.get_package('org.vistrails.vistrails.http')
     except MissingPackage:
         pm.late_enable_package('URL')
예제 #18
0
파일: init.py 프로젝트: KenSuber/cwsl-mas
 def package_configuration():
     """
     Create a shortcut to Edit->Preferences->Module Package->Enabled Packages->Configure in menu.
     """
     pkgmgr = get_package_manager()
     package = pkgmgr.get_package(identifier)
     dlg = QPackageConfigurationDialog(None, package)
     dlg.exec_()
예제 #19
0
 def reload_current_package_finisher(self, codepath, reverse_deps, prefix_dictionary):
     # REENABLES the current package and all reverse dependencies
     pm = get_package_manager()
     try:
         pm.reload_package_enable(reverse_deps, prefix_dictionary)
     except Package.InitializationFailed, e:
         debug.critical("Re-initialization of package '%s' failed" % 
                         codepath, str(e))
         raise
예제 #20
0
def choose_operation(typecasts, source_descriptor, expected_descriptor,
                     parent=None):
    _ = translate('typecast_dialog')

    dialog = QtGui.QDialog(parent)
    dialog.setWindowTitle(_("Type casting"))
    layout = QtGui.QVBoxLayout()

    label = QtGui.QLabel(_(
        "A {actual} variable was put in a {expected} port. These are not "
        "compatible, but the following operations can do the "
        "conversion:").format(
            actual="%s (%s)" % (source_descriptor.module.__name__,
                                source_descriptor.identifier),
            expected="%s (%s)" % (expected_descriptor.module.__name__,
                                  expected_descriptor.identifier)))
    label.setWordWrap(True)
    layout.addWidget(label)
    list_widget = CategorizedListWidget()
    list_widget.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
    pm = get_package_manager()
    for operation in typecasts:
        package = pm.get_package(operation.package_identifier)
        item = OperationItem(operation, package.name)
        list_widget.addItem(item, item.category)
    layout.addWidget(list_widget)

    buttons = QtGui.QHBoxLayout()
    ok = QtGui.QPushButton(_("Typecast", "Accept typecast dialog button"))
    QtCore.QObject.connect(ok, QtCore.SIGNAL('clicked()'),
                           dialog, QtCore.SLOT('accept()'))
    buttons.addWidget(ok)
    cancel = QtGui.QPushButton(_("Cancel", "Reject typecast dialog button"))
    QtCore.QObject.connect(cancel, QtCore.SIGNAL('clicked()'),
                           dialog, QtCore.SLOT('reject()'))
    buttons.addWidget(cancel)
    layout.addLayout(buttons)

    def check_selection():
        selection = list_widget.selectedItems()
        if selection:
            item = selection[0]
            if isinstance(item, OperationItem):
                ok.setEnabled(True)
                return
        ok.setEnabled(False)
    QtCore.QObject.connect(
        list_widget, QtCore.SIGNAL('itemSelectionChanged()'),
        check_selection)
    check_selection()

    dialog.setLayout(layout)
    if dialog.exec_() == QtGui.QDialog.Accepted:
        return list_widget.selectedItems()[0].operation
    else:
        raise CancelExecution
예제 #21
0
 def reload_current_package_finisher(self, codepath, reverse_deps,
                                     prefix_dictionary):
     # REENABLES the current package and all reverse dependencies
     pm = get_package_manager()
     try:
         pm.reload_package_enable(reverse_deps, prefix_dictionary)
     except Package.InitializationFailed, e:
         debug.critical(
             "Re-initialization of package '%s' failed" % codepath, e)
         raise
예제 #22
0
    def reload_current_package(self):
        if self._enabled_packages_list.currentItem() is not None:
            # Disables the selected package (which was enabled) and all its
            # reverse dependencies, then enables it all again
            item = self._enabled_packages_list.currentItem()
            pm = get_package_manager()
            codepath = str(item.text())

            palette = QModulePalette.instance()
            palette.setUpdatesEnabled(False)
            pm.reload_package_disable(codepath)
        elif self._available_packages_list.currentItem() is not None:
            # Reloads the selected package's (which was not enabled) __init__
            # module
            item = self._available_packages_list.currentItem()
            pm = get_package_manager()
            codepath = str(item.text())
            pm._available_packages.pop(codepath).unload()
            self.selected_available_list()
예제 #23
0
 def enablePackage(self):
     """ enablePackge() -> None
     Tries to enable the controlflow package through the controller.
     """
     pm = get_package_manager()
     cf_pkg_id = 'org.vistrails.vistrails.control_flow'
     if not pm.has_package(cf_pkg_id):
         dep_graph = pm.build_dependency_graph([cf_pkg_id])
         if not self.controller.try_to_enable_package(cf_pkg_id, dep_graph):
             raise MissingPackage(cf_pkg_id)
예제 #24
0
    def reload_current_package(self):
        if self._enabled_packages_list.currentItem() is not None:
            # Disables the selected package (which was enabled) and all its
            # reverse dependencies, then enables it all again
            item = self._enabled_packages_list.currentItem()
            pm = get_package_manager()
            codepath = str(item.text())

            palette = QModulePalette.instance()
            palette.setUpdatesEnabled(False)
            pm.reload_package_disable(codepath)
        elif self._available_packages_list.currentItem() is not None:
            # Reloads the selected package's (which was not enabled) __init__
            # module
            item = self._available_packages_list.currentItem()
            pm = get_package_manager()
            codepath = str(item.text())
            pm._available_packages.pop(codepath).unload()
            self.selected_available_list()
예제 #25
0
 def reload_current_package(self):
     # DISABLES the current package and all reverse dependencies
     inst = self._enabled_packages_list
     item = inst.currentItem()
     pm = get_package_manager()
     codepath = str(item.text())
     
     palette = QModulePalette.instance()
     palette.setUpdatesEnabled(False)
     pm.reload_package_disable(codepath)
예제 #26
0
 def enablePackage(self):
     """ enablePackge() -> None
     Tries to enable the controlflow package through the controller.
     """
     pm = get_package_manager()
     cf_pkg_id = 'org.vistrails.vistrails.control_flow'
     if not pm.has_package(cf_pkg_id):
         dep_graph = pm.build_dependency_graph([cf_pkg_id])
         if not self.controller.try_to_enable_package(cf_pkg_id, dep_graph):
             raise MissingPackage(cf_pkg_id)
예제 #27
0
 def selected_available_list(self):
     item = self._available_packages_list.currentItem()
     if item is None:
         return  # prevent back and forth looping when clearing selection
     self._enabled_packages_list.setCurrentItem(None)
     codepath = str(item.text())
     pm = get_package_manager()
     self._current_package = pm.look_at_available_package(codepath)
     self.set_buttons_to_available_package()
     self.set_package_information()
     self._available_packages_list.setFocus()
예제 #28
0
 def selected_available_list(self):
     item = self._available_packages_list.currentItem()
     if item is None:
         return # prevent back and forth looping when clearing selection
     self._enabled_packages_list.setCurrentItem(None)
     codepath = str(item.text())
     pm = get_package_manager()
     self._current_package = pm.look_at_available_package(codepath)
     self.set_buttons_to_available_package()
     self.set_package_information()
     self._available_packages_list.setFocus()
예제 #29
0
    def tearDownClass(cls):
        pm = get_package_manager()

        def disable(codepath):
            try:
                pm.late_disable_package(codepath)
            except MissingPackage:
                pass

        disable('pkg_test_variables')
        disable('pkg_test_plots')
예제 #30
0
    def enable_current_package(self):
        av = self._available_packages_list
        item = av.currentItem()
        codepath = str(item.text())
        pm = get_package_manager()

        try:
            new_deps = self._current_package.dependencies()
        except Exception, e:
            debug.critical("Failed getting dependencies of package %s, "
                           "so it will not be enabled" % \
                            self._current_package.name, str(e))
            return
예제 #31
0
    def enable_current_package(self):
        av = self._available_packages_list
        item = av.currentItem()
        codepath = str(item.text())
        pm = get_package_manager()

        try:
            new_deps = self._current_package.dependencies()
        except Exception, e:
            debug.critical(
                "Failed getting dependencies of package %s, "
                "so it will not be enabled" % self._current_package.name, e)
            return
예제 #32
0
    def setUpClass(cls):
        cls._application = dat.tests.setup_application()

        cls._application.register_notification('dat_new_loader',
                                               cls._new_loader)

        pm = get_package_manager()

        pm.late_enable_package('pkg_test_variables',
                               {'pkg_test_variables': 'dat.tests.'})

        pm.late_enable_package('pkg_test_plots',
                               {'pkg_test_plots': 'dat.tests.'})
예제 #33
0
 def selected_enabled_list(self):
     item = self._enabled_packages_list.currentItem()
     if item is None:
         return # prevent back and forth looping when clearing selection
     self._available_packages_list.setCurrentItem(None)
     codepath = str(item.text())
     pm = get_package_manager()
     self._current_package = pm.get_package_by_codepath(codepath)
     self.set_buttons_to_enabled_package()
     # A delayed signal can result in the package already has been removed
     if not pm.has_package(self._current_package.identifier):
         return
     self.set_package_information()
     self._enabled_packages_list.setFocus()
예제 #34
0
 def selected_enabled_list(self):
     item = self._enabled_packages_list.currentItem()
     if item is None:
         return  # prevent back and forth looping when clearing selection
     self._available_packages_list.setCurrentItem(None)
     codepath = str(item.text())
     pm = get_package_manager()
     self._current_package = pm.get_package_by_codepath(codepath)
     self.set_buttons_to_enabled_package()
     # A delayed signal can result in the package already has been removed
     if not pm.has_package(self._current_package.identifier):
         return
     self.set_package_information()
     self._enabled_packages_list.setFocus()
예제 #35
0
 def populate_lists(self):
     pkg_manager = get_package_manager()
     enabled_pkgs = sorted(pkg_manager.enabled_package_list())
     enabled_pkg_dict = dict([(pkg.codepath, pkg) for
                                pkg in enabled_pkgs])
     self._enabled_packages_list.clear()
     for pkg in enabled_pkgs:
         self._enabled_packages_list.addItem(pkg.codepath)
     self._enabled_packages_list.sortItems()
     available_pkg_names = [pkg for pkg in 
                            sorted(pkg_manager.available_package_names_list())
                            if pkg not in enabled_pkg_dict]
     self._available_packages_list.clear()
     for pkg in available_pkg_names:
         self._available_packages_list.addItem(pkg)
     self._available_packages_list.sortItems()
예제 #36
0
파일: init.py 프로젝트: AnyarInc/VisTrails
 def setUpClass(cls):
     # first make sure CLTools is loaded
     pm = get_package_manager()
     if 'CLTools' not in pm._package_list: # pragma: no cover # pragma: no branch
         pm.late_enable_package('CLTools')
     remove_all_scripts()
     cls.testdir = os.path.join(packages_directory(), 'CLTools', 'test_files')
     cls._tools = {}
     for name in os.listdir(cls.testdir):
         if not name.endswith(SUFFIX):
             continue
         _add_tool(os.path.join(cls.testdir, name))
         toolname = os.path.splitext(name)[0]
         cls._tools[toolname] = cl_tools[toolname]
     cls._old_dir = os.getcwd()
     os.chdir(vistrails_root_directory())
예제 #37
0
 def populate_lists(self):
     pkg_manager = get_package_manager()
     enabled_pkgs = sorted(pkg_manager.enabled_package_list())
     enabled_pkg_dict = dict([(pkg.codepath, pkg) for pkg in enabled_pkgs])
     self._enabled_packages_list.clear()
     for pkg in enabled_pkgs:
         self._enabled_packages_list.addItem(pkg.codepath)
     self._enabled_packages_list.sortItems()
     available_pkg_names = [
         pkg for pkg in sorted(pkg_manager.available_package_names_list())
         if pkg not in enabled_pkg_dict
     ]
     self._available_packages_list.clear()
     for pkg in available_pkg_names:
         self._available_packages_list.addItem(pkg)
     self._available_packages_list.sortItems()
예제 #38
0
파일: init.py 프로젝트: licode/VisTrails
 def setUpClass(cls):
     # first make sure CLTools is loaded
     pm = get_package_manager()
     if 'CLTools' not in pm._package_list: # pragma: no cover # pragma: no branch
         pm.late_enable_package('CLTools')
     remove_all_scripts()
     cls.testdir = os.path.join(packages_directory(), 'CLTools', 'test_files')
     cls._tools = {}
     for name in os.listdir(cls.testdir):
         if not name.endswith(SUFFIX):
             continue
         _add_tool(os.path.join(cls.testdir, name))
         toolname = os.path.splitext(name)[0]
         cls._tools[toolname] = cl_tools[toolname]
     cls._old_dir = os.getcwd()
     os.chdir(vistrails_root_directory())
예제 #39
0
 def setUp(self):
     super(TestMashupApp, self).setUp()
     try:
         import vtk
     except ImportError:
         self.skipTest("VTK is not available")
     from vistrails.core.packagemanager import get_package_manager
     from vistrails.core.modules.module_registry import MissingPackage
     pm = get_package_manager()
     identifier = 'org.vistrails.vistrails.vtk'
     try:
         pkg = pm.get_package(identifier)
     except MissingPackage:
         pkg = pm.identifier_is_available(identifier)
         if pkg:
             pm.late_enable_package(pkg.codepath)
             pkg = pm.get_package(identifier)
예제 #40
0
def enable_package(identifier):
    """Enables a package.
    """
    from vistrails.core.modules.module_registry import MissingPackage
    from vistrails.core.packagemanager import get_package_manager

    pm = get_package_manager()

    try:
        pm.get_package(identifier)
    except MissingPackage:
        dep_graph = pm.build_dependency_graph([identifier])
        for pkg_id in pm.get_ordered_dependencies(dep_graph):
            pkg = pm.identifier_is_available(pkg_id)
            if pkg is None:
                raise
            pm.late_enable_package(pkg.codepath)
예제 #41
0
 def setUp(self):
     super(TestMashupApp, self).setUp()
     try:
         import vtk
     except ImportError:
         self.skipTest("VTK is not available")
     from vistrails.core.packagemanager import get_package_manager
     from vistrails.core.modules.module_registry import MissingPackage
     pm = get_package_manager()
     identifier = 'org.vistrails.vistrails.vtk'
     try:
         pkg = pm.get_package(identifier)
     except MissingPackage:
         pkg = pm.identifier_is_available(identifier)
         if pkg:
             pm.late_enable_package(pkg.codepath)
             pkg = pm.get_package(identifier)
예제 #42
0
    def disable_current_package(self):
        inst = self._enabled_packages_list
        item = inst.currentItem()
        codepath = str(item.text())
        pm = get_package_manager()

        dependency_graph = pm.dependency_graph()
        identifier = pm.get_package_by_codepath(codepath).identifier

        if dependency_graph.in_degree(identifier) > 0:
            rev_deps = dependency_graph.inverse_adjacency_list[identifier]
            debug.critical("Missing dependency",
                           ("There are other packages that depend on this:\n %s" +
                            "Please disable those first.") % rev_deps)
        else:
            pm.late_disable_package(codepath)
            self.invalidate_current_pipeline()
예제 #43
0
파일: utils.py 프로젝트: sguzwf/VisTrails
def enable_package(identifier):
    """Enables a package.
    """
    from vistrails.core.modules.module_registry import MissingPackage
    from vistrails.core.packagemanager import get_package_manager

    pm = get_package_manager()

    try:
        pm.get_package(identifier)
    except MissingPackage:
        dep_graph = pm.build_dependency_graph([identifier])
        for pkg_id in pm.get_ordered_dependencies(dep_graph):
            pkg = pm.identifier_is_available(pkg_id)
            if pkg is None:
                raise
            pm.late_enable_package(pkg.codepath)
예제 #44
0
    def test_external_upgrade(self):
        from vistrails.core.application import get_vistrails_application

        app = get_vistrails_application()
        app.new_vistrail()
        default_upgrade_on = app.temp_configuration.upgradeOn
        default_upgrade_delay = app.temp_configuration.upgradeDelay
        app.temp_configuration.upgradeOn = True
        app.temp_configuration.upgradeDelay = False

        created_vistrail = False
        try:
            pm = get_package_manager()
            pm.late_enable_package('upgrades',
                                   {'upgrades':
                                    'vistrails.tests.resources.'})
            app.new_vistrail()
            created_vistrail = True
            c = app.get_controller()
            current_version = self.create_workflow(c)
            for m in c.current_pipeline.modules.itervalues():
                self.assertEqual(m.version, '0.8')

            c.change_selected_version(current_version, from_root=True)
            
            self.assertEqual(len(c.current_pipeline.modules), 2)
            for m in c.current_pipeline.modules.itervalues():
                self.assertEqual(m.version, '1.0')
                if m.name == "TestUpgradeA":
                    self.assertEqual(m.functions[0].name, 'aaa')
            self.assertEqual(len(c.current_pipeline.connections), 1)
            conn = c.current_pipeline.connections.values()[0]
            self.assertEqual(conn.source.name, 'zzz')
            self.assertEqual(conn.destination.name, 'b')
                
        finally:
            if created_vistrail:
                app.close_vistrail()
            try:
                pm.late_disable_package('upgrades')
            except MissingPackage:
                pass
            app.temp_configuration.upgradeOn = default_upgrade_on
            app.temp_configuration.upgradeDelay = default_upgrade_delay
예제 #45
0
def set_root_dir(session_dir):
    '''sets
    '''
    global _roottempdir, identifier, configuration

    _roottempdir = session_dir
    configuration.cur_session_folder = session_dir

    package_manager = get_package_manager()
    package = package_manager.get_package(identifier)
    dom, element = package.find_own_dom_element()

    configuration.write_to_dom(dom, element)

    print("*" * 79)
    print("*" * 79)
    print("GeoDataPortal output directory:   " + session_dir)
    print("*" * 79)
    print("*" * 79)
예제 #46
0
def load_package(identifier, autoload=True):
    """Gets a package by identifier, enabling it if necessary.
    """
    initialize()
    pm = get_package_manager()
    pkg = pm.identifier_is_available(identifier)
    if pm.has_package(identifier):
        return Package(pkg)
    elif pkg is None:
        raise NoSuchPackage("Package %r not found" % identifier)

    # Copied from VistrailController#try_to_enable_package()
    dep_graph = pm.build_dependency_graph([identifier])
    deps = pm.get_ordered_dependencies(dep_graph)
    for pkg_id in deps:
        if not do_enable_package(pm, pkg_id):
            raise NoSuchPackage("Package %r not found" % pkg_id)

    return Package(pkg)
예제 #47
0
def set_root_dir(session_dir):
    '''sets
    '''
    global _roottempdir, identifier, configuration

    _roottempdir = session_dir
    configuration.cur_session_folder = session_dir

    package_manager = get_package_manager()
    package = package_manager.get_package(identifier)
    dom, element = package.find_own_dom_element()

    configuration.write_to_dom(dom, element)

    print("*" * 79)
    print("*" * 79)
    print("GeoDataPortal output directory:   " + session_dir)
    print("*" * 79)
    print("*" * 79)
예제 #48
0
파일: api.py 프로젝트: AnyarInc/VisTrails
def load_package(identifier, autoload=True):
    """Gets a package by identifier, enabling it if necessary.
    """
    initialize()
    pm = get_package_manager()
    pkg = pm.identifier_is_available(identifier)
    if pm.has_package(identifier):
        return Package(pkg)
    elif pkg is None:
        raise NoSuchPackage("Package %r not found" % identifier)

    # Copied from VistrailController#try_to_enable_package()
    dep_graph = pm.build_dependency_graph([identifier])
    deps = pm.get_ordered_dependencies(dep_graph)
    for pkg_id in deps:
        if not do_enable_package(pm, pkg_id):
            raise NoSuchPackage("Package %r not found" % pkg_id)

    return Package(pkg)
예제 #49
0
    def test_external_upgrade(self):
        from vistrails.core.application import get_vistrails_application

        app = get_vistrails_application()
        default_upgrades = app.temp_configuration.upgrades
        default_upgrade_delay = app.temp_configuration.upgradeDelay
        app.temp_configuration.upgrades = True
        app.temp_configuration.upgradeDelay = False

        created_vistrail = False
        pm = get_package_manager()
        try:
            pm.late_enable_package('upgrades',
                                   {'upgrades':
                                    'vistrails.tests.resources.'})
            app.new_vistrail()
            created_vistrail = True
            c = app.get_controller()
            current_version = self.create_workflow(c)
            for m in c.current_pipeline.modules.itervalues():
                self.assertEqual(m.version, '0.8')

            c.change_selected_version(current_version, from_root=True)
            
            self.assertEqual(len(c.current_pipeline.modules), 2)
            for m in c.current_pipeline.modules.itervalues():
                self.assertEqual(m.version, '1.0')
                if m.name == "TestUpgradeA":
                    self.assertEqual(m.functions[0].name, 'aaa')
            self.assertEqual(len(c.current_pipeline.connections), 1)
            conn = c.current_pipeline.connections.values()[0]
            self.assertEqual(conn.source.name, 'zzz')
            self.assertEqual(conn.destination.name, 'b')
                
        finally:
            if created_vistrail:
                app.close_vistrail()
            try:
                pm.late_disable_package('upgrades')
            except MissingPackage:
                pass
            app.temp_configuration.upgrades = default_upgrades
            app.temp_configuration.upgradeDelay = default_upgrade_delay
 def dispatch_request(controller, module_id, current_pipeline):
     reg = get_module_registry()
     pm = get_package_manager()
     if module_id not in current_pipeline.modules:
         # It is possible that some other upgrade request has
         # already removed the invalid module of this request. In
         # that case, disregard the request.
         debug.log("module %s already handled. skipping" % module_id)
         return []
     invalid_module = current_pipeline.modules[module_id]
     pkg = pm.get_package(invalid_module.package)
     if hasattr(pkg.module, 'handle_module_upgrade_request'):
         f = pkg.module.handle_module_upgrade_request
         return f(controller, module_id, current_pipeline)
     else:
         debug.log('Package "%s" cannot handle upgrade request. '
                   'VisTrails will attempt automatic upgrade.' % \
                       pkg.identifier)
         auto_upgrade = UpgradeWorkflowHandler.attempt_automatic_upgrade
         return auto_upgrade(controller, current_pipeline, module_id)
예제 #51
0
 def set_buttons_to_enabled_package(self):
     self._enable_button.setEnabled(False)
     assert self._current_package
     pm = get_package_manager()
     from vistrails.core.modules.basic_modules import identifier as basic_modules_identifier
     from vistrails.core.modules.abstraction import identifier as abstraction_identifier
     is_not_basic_modules = (self._current_package.identifier != basic_modules_identifier)
     is_not_abstraction = (self._current_package.identifier != abstraction_identifier)
     can_disable = (pm.can_be_disabled(self._current_package.identifier) and
                    is_not_basic_modules and
                    is_not_abstraction)
     self._disable_button.setEnabled(can_disable)
     if not can_disable and is_not_basic_modules and is_not_abstraction:
         msg = ("Module has reverse dependencies that must\n"+
                "be first disabled.")
         self._disable_button.setToolTip(msg)
     else:
         self._disable_button.setToolTip("")
     conf = self._current_package.configuration is not None
     self._configure_button.setEnabled(conf)
     self._reload_button.setEnabled(is_not_basic_modules)
예제 #52
0
    def run_multi_upgrade_test(self, pkg_remap):
        from vistrails.core.application import get_vistrails_application

        app = get_vistrails_application()
        created_vistrail = False
        pm = get_package_manager()
        try:
            pm.late_enable_package("upgrades", {"upgrades": "vistrails.tests.resources."})
            app.new_vistrail()
            created_vistrail = True
            c = app.get_controller()
            self.create_workflow(c)

            p = c.current_pipeline
            actions = UpgradeWorkflowHandler.remap_module(c, 0, p, pkg_remap)
        finally:
            if created_vistrail:
                app.close_vistrail()
            try:
                pm.late_disable_package("upgrades")
            except MissingPackage:
                pass
예제 #53
0
    def run_multi_upgrade_test(self, pkg_remap):
        from vistrails.core.application import get_vistrails_application

        app = get_vistrails_application()
        created_vistrail = False
        pm = get_package_manager()
        try:
            pm.late_enable_package('upgrades',
                                   {'upgrades': 'vistrails.tests.resources.'})
            app.new_vistrail()
            created_vistrail = True
            c = app.get_controller()
            self.create_workflow(c)

            p = c.current_pipeline
            actions = UpgradeWorkflowHandler.remap_module(c, 0, p, pkg_remap)
        finally:
            if created_vistrail:
                app.close_vistrail()
            try:
                pm.late_disable_package('upgrades')
            except MissingPackage:
                pass
예제 #54
0
 def dispatch_request(controller, module_id, current_pipeline):
     pm = get_package_manager()
     if module_id not in current_pipeline.modules:
         # It is possible that some other upgrade request has
         # already removed the invalid module of this request. In
         # that case, disregard the request.
         debug.log("module %s already handled. skipping" % module_id)
         return []
     invalid_module = current_pipeline.modules[module_id]
     pkg = pm.get_package(invalid_module.package)
     if hasattr(pkg.module, 'handle_module_upgrade_request'):
         f = pkg.module.handle_module_upgrade_request
         return f(controller, module_id, current_pipeline)
     elif hasattr(pkg.module, '_upgrades'):
         return UpgradeWorkflowHandler.remap_module(controller, module_id,
                                                    current_pipeline,
                                                    pkg.module._upgrades)
     else:
         debug.log('Package "%s" cannot handle upgrade request. '
                   'VisTrails will attempt automatic upgrade.' % \
                       pkg.identifier)
         auto_upgrade = UpgradeWorkflowHandler.attempt_automatic_upgrade
         return auto_upgrade(controller, current_pipeline, module_id)
예제 #55
0
파일: init.py 프로젝트: licode/VisTrails
    def createFailedPackage(self):
        """ Failed package is created so that the user can remove
        it manually using package submenu """
        pm = get_package_manager()
        if pm.has_package(self.signature):
            # do nothing
            return
        reg = vistrails.core.modules.module_registry.get_module_registry()

        # create a document hash integer from the cached sax tree
        # "name" is what suds use as the cache key
        name = '%s-%s' % (abs(hash(self.address)), "wsdl")
        self.wsdlHash = '0'

        package_id = reg.idScope.getNewId(Package.vtType)
        package = Package(
            id=package_id,
            load_configuration=False,
            name="SUDS#" + self.address,
            identifier=self.signature,
            version=self.wsdlHash,
        )
        suds_package = reg.get_package_by_name(identifier)
        package._module = suds_package.module
        package._init_module = suds_package.init_module
        self.package = package
        reg.add_package(package)
        reg.signals.emit_new_package(self.signature)
        self.module = new_module(Module, str(self.signature))
        reg.add_module(
            self.module, **{
                'package': self.signature,
                'package_version': self.wsdlHash,
                'abstract': True
            })
        self.service = -1
예제 #56
0
파일: plots.py 프로젝트: VisTrails/DAT
 def plot_added(self, plot):
     pm = get_package_manager()
     package = pm.get_package(plot.package_identifier)
     item = PlotItem(plot, package.name)
     self._plots[plot] = item
     self._list_widget.addItem(item, package.name)