Ejemplo n.º 1
0
    def check_dependencies(self, package, deps):
        # want to check that necessary version also exists, if specified
        missing_deps = []
        for dep in deps:
            min_version = None
            max_version = None
            if type(dep) == tuple:
                identifier = dep[0]
                if len(dep) > 1:
                    min_version = dep[1]
                    if len(dep) > 2:
                        max_version = dep[2]
            else:
                identifier = dep

            if identifier not in self._package_versions:
                missing_deps.append((identifier, None, None))
            else:
                if min_version is None and max_version is None:
                    continue
                found_version = False
                for version, pkg in \
                        self._package_versions[identifier].iteritems():
                    if ((min_version is None
                         or versions_increasing(min_version, version)) and
                        (max_version is None
                         or versions_increasing(version, max_version))):
                        found_version = True
                if not found_version:
                    missing_deps.append((identifier, min_version, max_version))

        if len(missing_deps) > 0:
            raise Package.MissingDependency(package, missing_deps)
        return True
    def check_dependencies(self, package, deps):
        # want to check that necessary version also exists, if specified
        missing_deps = []
        for dep in deps:
            min_version = None
            max_version = None
            if type(dep) == tuple:
                identifier = dep[0]
                if len(dep) > 1:
                    min_version = dep[1]
                    if len(dep) > 2:
                        max_version = dep[2]
            else:
                identifier = dep

            if identifier not in self._package_versions:
                missing_deps.append((identifier, None, None))
            else:
                if min_version is None and max_version is None:
                    continue
                found_version = False
                for version, pkg in \
                        self._package_versions[identifier].iteritems():
                    if ((min_version is None or
                         versions_increasing(min_version, version)) and
                        (max_version is None or
                         versions_increasing(version, max_version))):
                        found_version = True
                if not found_version:
                    missing_deps.append((identifier, min_version, max_version))

        if len(missing_deps) > 0:
            raise Package.MissingDependency(package, missing_deps)
        return True
Ejemplo n.º 3
0
    def update_module(self, module=None):
        self.module = module
        for ports_list in self.ports_lists:
            ports_list.update_module(module)
        self.annotations.updateModule(module)

        if module is None:
            self.name_edit.setText("")
            if not versions_increasing(QtCore.QT_VERSION_STR, '4.7.0'):
                self.name_edit.setPlaceholderText("")
            # self.name_edit.setEnabled(False)
            self.type_edit.setText("")
            # self.type_edit.setEnabled(False)
            self.package_edit.setText("")
        else:
            if module.has_annotation_with_key('__desc__'):
                label = module.get_annotation_by_key('__desc__').value.strip()
            else:
                label = ''
            self.name_edit.setText(label)
            if not label and not versions_increasing(QtCore.QT_VERSION_STR, 
                                                     '4.7.0'):
                #print QtCore.QT_VERSION_STR, versions_increasing(QtCore.QT_VERSION_STR, '4.7.0')
                self.name_edit.setPlaceholderText(self.module.name)

            # self.name_edit.setEnabled(True)
            self.type_edit.setText(self.module.name)
            # self.type_edit.setEnabled(True)
            self.package_edit.setText(self.module.package)
Ejemplo n.º 4
0
 def add_descriptor(self, desc):
     self.db_add_module_descriptor(desc)
     key = (desc.name, desc.namespace)
     if key in self.descriptors:
         old_desc = self.descriptors[key]
         if versions_increasing(old_desc.version, desc.version):
             self.descriptors[key] = desc
     else:
         self.descriptors[key] = desc
 def add_descriptor(self, desc):
     self.db_add_module_descriptor(desc)
     key = (desc.name, desc.namespace)
     if key in self.descriptors:
         old_desc = self.descriptors[key]
         if versions_increasing(old_desc.version, desc.version):
             self.descriptors[key] = desc
     else:
         self.descriptors[key] = desc
Ejemplo n.º 6
0
    def get_package(self, identifier, version=None):
        package_versions = self._package_versions[identifier]
        if version is not None:
            return package_versions[version]

        max_version = '0'
        max_pkg = None
        for version, pkg in package_versions.iteritems():
            if versions_increasing(max_version, version):
                max_version = version
                max_pkg = pkg
        return max_pkg
Ejemplo n.º 7
0
 def setup_indices(self):
     self.descriptor_versions = self.db_module_descriptors_name_index
     self.descriptors_by_id = self.db_module_descriptors_id_index
     self.descriptors = {}
     for key, desc in self.descriptor_versions.iteritems():
         key = key[:2]
         if key in self.descriptors:
             old_desc = self.descriptors[key]
             if versions_increasing(old_desc.version, desc.version):
                 self.descriptors[key] = desc
         else:
             self.descriptors[key] = desc
    def get_package(self, identifier, version=None):
        package_versions = self._package_versions[identifier]
        if version is not None:
            return package_versions[version]

        max_version = '0'
        max_pkg = None
        for version, pkg in package_versions.iteritems():
            if versions_increasing(max_version, version):
                max_version = version
                max_pkg = pkg
        return max_pkg
 def setup_indices(self):
     self.descriptor_versions = self.db_module_descriptors_name_index
     self.descriptors_by_id = self.db_module_descriptors_id_index
     self.descriptors = {}
     for key, desc in self.descriptor_versions.iteritems():
         key = key[:2]
         if key in self.descriptors:
             old_desc = self.descriptors[key]
             if versions_increasing(old_desc.version, desc.version):
                 self.descriptors[key] = desc
         else:
             self.descriptors[key] = desc
Ejemplo n.º 10
0
    def remap_module(controller, module_id, pipeline, module_remap):

        """remap_module offers a method to shortcut the
        specification of upgrades.  It is useful when just changing
        the names of ports or modules, but can also be used to add
        intermediate modules or change the format of parameters.  It
        is usually called from handle_module_upgrade_request, and the
        first three arguments are passed from the arguments to that
        method.

        module_remap specifies all of the changes and is of the format
        {<old_module_name>: [(<start_version>, <end_version>, 
                             <new_module_klass> | <new_module_id> | None, 
                             <remap_dictionary>)]}
        where new_module_klass is the class and new_module_id
        is a string of the format 
            <package_name>:[<namespace> | ]<module_name>
        passing None keeps the original name,
        and remap_dictionary is {<remap_type>:
        <name_changes>} and <name_changes> is a map from <old_name> to
        <new_name> or <remap_function>
        The remap functions are passed the old object and the new
        module and should return a list of operations with elements of
        the form ('add', <obj>).

        For example:

        def outputName_remap(old_conn, new_module):
            ops = []
            ...
            return ops
        module_remap = {'FileSink': [(None, '1.5.1', FileSink,
                                     {'dst_port_remap':
                                          {'overrideFile': 'overwrite',
                                           'outputName': outputName_remap},
                                      'function_remap':
                                          {'overrideFile': 'overwrite',
                                           'outputName': 'outputPath'}}),
                        }
        """

        reg = get_module_registry()

        old_module = pipeline.modules[module_id]
        old_desc_str = reg.create_descriptor_string(old_module.package,
                                                    old_module.name,
                                                    old_module.namespace,
                                                    False)
        # print 'running module_upgrade_request', old_module.name
        if old_desc_str in module_remap:
            for upgrade_tuple in module_remap[old_desc_str]:
                (start_version, end_version, new_module_type, remap) = \
                    upgrade_tuple
                old_version = old_module.version
                if ((start_version is None or 
                     not versions_increasing(old_version, start_version)) and
                    (end_version is None or
                     versions_increasing(old_version, end_version))):
                    # do upgrade
                    
                    if new_module_type is None:
                        try:
                            new_module_desc = \
                                reg.get_descriptor_by_name(old_module.package, 
                                                           old_module.name, 
                                                           old_module.namespace)
                        except MissingModule, e:
                            # if the replacement is an abstraction,
                            # and it has been upgraded, we use that
                            if reg.has_abs_upgrade(old_module.package,
                                                   old_module.name,
                                                   old_module.namespace):
                                new_module_desc = \
                                    reg.get_abs_upgrade(old_module.package,
                                                        old_module.name,
                                                        old_module.namespace)
                            else:
                                raise e
                    elif type(new_module_type) == type(""):
                        d_tuple = \
                            reg.expand_descriptor_string(new_module_type, \
                                                             old_module.package)
                        try:
                            new_module_desc = \
                                reg.get_descriptor_by_name(*d_tuple)
                        except MissingModule, e:
                            # if the replacement is an abstraction,
                            # and it has been upgraded, we use that
                            if reg.has_abs_upgrade(*d_tuple):
                                new_module_desc = reg.get_abs_upgrade(*d_tuple)
                            else:
                                raise e
                    else: # we have a klass for get_descriptor
                        new_module_desc = reg.get_descriptor(new_module_type)
                   
                    src_port_remap = remap.get('src_port_remap', {})
                    dst_port_remap = remap.get('dst_port_remap', {})
                    # !!! we're going to let dst_port_remap serve as a
                    # base for function_remap but the developer is
                    # responsible for knowing that anything beyond name
                    # remaps requires different functions
                    function_remap = copy.copy(dst_port_remap)
                    function_remap.update(remap.get('function_remap', {}))
                    annotation_remap = remap.get('annotation_remap', {})
                    action_list = \
                        UpgradeWorkflowHandler.replace_module(controller, 
                                                              pipeline,
                                                              module_id, 
                                                              new_module_desc,
                                                              function_remap,
                                                              src_port_remap,
                                                              dst_port_remap,
                                                              annotation_remap)
                    return action_list