コード例 #1
0
ファイル: component.py プロジェクト: DaMouse404/yotta
        def provider(
            dspec,
            available_components,
            search_dirs,
            working_directory,
            update_installed,
            dep_of=None
        ):
            r = access.satisfyFromAvailable(dspec.name, available_components)
            if r:
                if r.isTestDependency() and not dspec.is_test_dependency:
                    logger.debug('test dependency subsequently occurred as real dependency: %s', r.getName())
                    r.setTestDependency(False)
                return r
            update_if_installed = False
            if update_installed is True:
                update_if_installed = True
            elif update_installed:
                update_if_installed = dspec.name in update_installed
            r = access.satisfyVersionFromSearchPaths(
                dspec.name,
                dspec.versionReq(),
                search_dirs,
                update_if_installed,
                inherit_shrinkwrap = dep_of.getShrinkwrap()
            )
            if r:
                r.setTestDependency(dspec.is_test_dependency)
                return r
            # before resorting to install this module, check if we have an
            # existing linked module (which wasn't picked up because it didn't
            # match the version specification) - if we do, then we shouldn't
            # try to install, but should return that anyway:
            default_path = os.path.join(self.modulesPath(), dspec.name)
            if fsutils.isLink(default_path):
                r = Component(
                                       default_path,
                     test_dependency = dspec.is_test_dependency,
                    installed_linked = fsutils.isLink(default_path),
                  inherit_shrinkwrap = dep_of.getShrinkwrap()
                )
                if r:
                    assert(r.installedLinked())
                    return r
                else:
                    logger.error('linked module %s is invalid: %s', dspec.name, r.getError())
                    return r

            r = access.satisfyVersionByInstalling(
                dspec.name,
                dspec.versionReq(),
                self.modulesPath(),
                inherit_shrinkwrap = dep_of.getShrinkwrap()
            )
            if not r:
                logger.error('could not install %s' % dspec.name)
            if r is not None:
                r.setTestDependency(dspec.is_test_dependency)
            return r
コード例 #2
0
        def provider(
            dspec,
            available_components,
            search_dirs,
            working_directory,
            update_installed,
            dep_of=None
        ):
            r = access.satisfyFromAvailable(dspec.name, available_components)
            if r:
                if r.isTestDependency() and not dspec.is_test_dependency:
                    logger.debug('test dependency subsequently occurred as real dependency: %s', r.getName())
                    r.setTestDependency(False)
                return r
            update_if_installed = False
            if update_installed is True:
                update_if_installed = True
            elif update_installed:
                update_if_installed = dspec.name in update_installed
            r = access.satisfyVersionFromSearchPaths(
                dspec.name,
                dspec.versionReq(),
                search_dirs,
                update_if_installed,
                inherit_shrinkwrap = dep_of.getShrinkwrap()
            )
            if r:
                r.setTestDependency(dspec.is_test_dependency)
                return r
            # before resorting to install this module, check if we have an
            # existing linked module (which wasn't picked up because it didn't
            # match the version specification) - if we do, then we shouldn't
            # try to install, but should return that anyway:
            default_path = os.path.join(self.modulesPath(), dspec.name)
            if fsutils.isLink(default_path):
                r = Component(
                                       default_path,
                     test_dependency = dspec.is_test_dependency,
                    installed_linked = fsutils.isLink(default_path),
                  inherit_shrinkwrap = dep_of.getShrinkwrap()
                )
                if r:
                    assert(r.installedLinked())
                    return r
                else:
                    logger.error('linked module %s is invalid: %s', dspec.name, r.getError())
                    return r

            r = access.satisfyVersionByInstalling(
                dspec.name,
                dspec.versionReq(),
                self.modulesPath(),
                inherit_shrinkwrap = dep_of.getShrinkwrap()
            )
            if not r:
                logger.error('could not install %s' % dspec.name)
            if r is not None:
                r.setTestDependency(dspec.is_test_dependency)
            return r
コード例 #3
0
ファイル: remove.py プロジェクト: yuben75/yotta
def rmLinkOrDirectory(path, nonexistent_warning):
    if not os.path.exists(path):
        logging.warning(nonexistent_warning)
        return 1
    if fsutils.isLink(path):
        fsutils.rmF(path)
    else:
        fsutils.rmRf(path)
    return 0
コード例 #4
0
ファイル: component.py プロジェクト: DaMouse404/yotta
 def provideInstalled(self,
                     dspec,
      available_components,
               search_dirs,
         working_directory,
          update_installed,
                    dep_of
     ):
     #logger.info('%s provideInstalled: %s', dep_of.getName(), dspec.name)
     r = access.satisfyFromAvailable(dspec.name, available_components)
     if r:
         if r.isTestDependency() and not dspec.is_test_dependency:
             logger.debug('test dependency subsequently occurred as real dependency: %s', r.getName())
             r.setTestDependency(False)
         return r
     update_if_installed = False
     if update_installed is True:
         update_if_installed = True
     elif update_installed:
         update_if_installed = dspec.name in update_installed
     r = access.satisfyVersionFromSearchPaths(
         dspec.name,
         dspec.versionReq(),
         search_dirs,
         update_if_installed,
         inherit_shrinkwrap = dep_of.getShrinkwrap()
     )
     if r:
         r.setTestDependency(dspec.is_test_dependency)
         return r
     # return a module initialised to the path where we would have
     # installed this module, so that it's possible to use
     # getDependenciesRecursive to find a list of failed dependencies,
     # as well as just available ones
     # note that this Component object may still be valid (usable to
     # attempt a build), if a different version was previously installed
     # on disk at this location (which means we need to check if the
     # existing version is linked)
     default_path = os.path.join(self.modulesPath(), dspec.name)
     r = Component(
                            default_path,
          test_dependency = dspec.is_test_dependency,
         installed_linked = fsutils.isLink(default_path),
       inherit_shrinkwrap = dep_of.getShrinkwrap()
     )
     return r
コード例 #5
0
def searchPathsFor(name, spec, search_paths, type='module', inherit_shrinkwrap=None):
    for path in search_paths:
        check_path = os.path.join(path, name)
        logger.debug("check path %s for %s" % (check_path, name))
        instance = _clsForType(type)(
                     check_path,
                   installed_linked = fsutils.isLink(check_path),
            latest_suitable_version = None,
                 inherit_shrinkwrap = inherit_shrinkwrap
        )
        if instance:
            logger.debug("got %s v=%s spec %s matches? %s", instance, instance.getVersion(), spec, spec.match(instance.getVersion()))
            if spec.match(instance.getVersion()):
                return instance
        else:
            logger.debug("got %s", instance)
    return None
コード例 #6
0
 def provideInstalled(self,
                     dspec,
      available_components,
               search_dirs,
         working_directory,
          update_installed,
                    dep_of
     ):
     #logger.info('%s provideInstalled: %s', dep_of.getName(), dspec.name)
     r = access.satisfyFromAvailable(dspec.name, available_components)
     if r:
         if r.isTestDependency() and not dspec.is_test_dependency:
             logger.debug('test dependency subsequently occurred as real dependency: %s', r.getName())
             r.setTestDependency(False)
         return r
     update_if_installed = False
     if update_installed is True:
         update_if_installed = True
     elif update_installed:
         update_if_installed = dspec.name in update_installed
     r = access.satisfyVersionFromSearchPaths(
         dspec.name,
         dspec.versionReq(),
         search_dirs,
         update_if_installed,
         inherit_shrinkwrap = dep_of.getShrinkwrap()
     )
     if r:
         r.setTestDependency(dspec.is_test_dependency)
         return r
     # return a module initialised to the path where we would have
     # installed this module, so that it's possible to use
     # getDependenciesRecursive to find a list of failed dependencies,
     # as well as just available ones
     # note that this Component object may still be valid (usable to
     # attempt a build), if a different version was previously installed
     # on disk at this location (which means we need to check if the
     # existing version is linked)
     default_path = os.path.join(self.modulesPath(), dspec.name)
     r = Component(
                            default_path,
          test_dependency = dspec.is_test_dependency,
         installed_linked = fsutils.isLink(default_path),
       inherit_shrinkwrap = dep_of.getShrinkwrap()
     )
     return r
コード例 #7
0
ファイル: uninstall.py プロジェクト: ARMmbed/yotta
def execCommand(args, following_args):
    err = validate.componentNameValidationError(args.component)
    if err:
        logging.error(err)
        return 1
    c = validate.currentDirectoryModule()
    if not c:
        return 1
    status = 0
    if not c.removeDependency(args.component):
        status = 1
    else:
        c.writeDescription()
    path = os.path.join(c.modulesPath(), args.component)
    if fsutils.isLink(path):
        fsutils.rmF(path)
    else:
        fsutils.rmRf(path)
    return status
コード例 #8
0
ファイル: uninstall.py プロジェクト: yuben75/yotta
def execCommand(args, following_args):
    err = validate.componentNameValidationError(args.component)
    if err:
        logging.error(err)
        return 1
    c = validate.currentDirectoryModule()
    if not c:
        return 1
    status = 0
    if not c.removeDependency(args.component):
        status = 1
    else:
        c.writeDescription()
    path = os.path.join(c.modulesPath(), args.component)
    if fsutils.isLink(path):
        fsutils.rmF(path)
    else:
        fsutils.rmRf(path)
    return status