Example #1
0
 def test_ShorthandRefs(self):
     for url in ShortHand_URLs:
         for spec in Git_Specs:
             if len(spec):
                 # Shorthand URLs support '@' and ' ' as well as '#'
                 for m in ['#', '@', ' ']:
                     ns = url + m + spec
                     n, s = sourceparse.parseModuleNameAndSpec(ns)
                     self.assertEqual(n, 'reponame')
                     self.assertEqual(s, ns)
             else:
                 n, s = sourceparse.parseModuleNameAndSpec(url)
                 self.assertEqual(n, 'reponame')
                 self.assertEqual(s, url)
Example #2
0
 def test_ShorthandRefs(self):
     for url in ShortHand_URLs:
         for spec in Git_Specs:
             if len(spec):
                 # Shorthand URLs support '@' and ' ' as well as '#'
                 for m in ['#', '@', ' ']:
                     ns = url + m + spec
                     n, s = sourceparse.parseModuleNameAndSpec(ns)
                     self.assertEqual(n, 'reponame')
                     self.assertEqual(s, ns)
             else:
                 n, s = sourceparse.parseModuleNameAndSpec(url)
                 self.assertEqual(n, 'reponame')
                 self.assertEqual(s, url)
Example #3
0
 def test_atHGURL(self):
     for name in Valid_Names:
         for v in HG_URLs:
             nv = name + '@' + v
             n, s = sourceparse.parseModuleNameAndSpec(nv)
             self.assertEqual(n, name)
             self.assertEqual(s, v)
Example #4
0
def installComponentAsDependency(args, current_component):
    logging.debug('install component %s as dependency of %s' % (args.component, current_component))
    if not current_component:
        logging.debug(str(current_component.getError()))
        logging.error('The current directory does not contain a valid module.')
        return -1
    target, errors = current_component.satisfyTarget(args.target, additional_config=args.config)
    if errors:
        for error in errors:
            logging.error(error)
        return 1
    modules_dir = current_component.modulesPath()

    from yotta.lib import sourceparse
    # check if we have both a name and specification
    component_name, component_spec = sourceparse.parseModuleNameAndSpec(args.component)
    logging.info('%s, %s', component_name, component_spec)

    if component_name == current_component.getName():
        logging.error('will not install module %s as a dependency of itself', component_name)
        return -1
    try:
        installed = access.satisfyVersion(
                component_name,
                component_spec,
                     available = {current_component.getName():current_component},
                  search_paths = [modules_dir],
             working_directory = modules_dir
        )
    except access_common.AccessException as e:
        logging.error(e)
        return 1


    # We always add the component to the dependencies of the current component
    # (if it is not already present), and write that back to disk. Without
    # writing to disk the dependency wouldn't be usable.
    if installed and not current_component.hasDependency(component_name):
        vs = sourceparse.parseSourceURL(component_spec)
        if vs.source_type == 'registry':
            saved_spec = current_component.saveDependency(installed)
        else:
            saved_spec = current_component.saveDependency(installed, component_spec)

        current_component.writeDescription()
        logging.info('dependency %s: %s written to module.json', component_name, saved_spec)
    else:
        logging.info('dependency %s is already present in module.json', component_name)

    # !!! should only install dependencies necessary for the one thing that
    # we're installing (but existing components should be made available to
    # satisfy dependencies)
    components, errors = current_component.satisfyDependenciesRecursive(
                      target = target,
        available_components = [(current_component.getName(), current_component)],
                        test = {'own':'toplevel', 'all':True, 'none':False}[args.install_test_deps]

    )
    return checkPrintStatus(errors, components, current_component, target)
Example #5
0
 def test_atVersion(self):
     for name in Valid_Names:
         for v in Registry_URLs:
             if len(v):
                 nv = name + '@' + v
                 n, s = sourceparse.parseModuleNameAndSpec(nv)
                 self.assertEqual(n, name)
                 self.assertEqual(s, v)
Example #6
0
 def test_HGRefs(self):
     for url in HG_URLs:
         for spec in HG_Specs:
             if len(spec):
                 ns = url + '#' + spec
             else:
                 ns = url
             n, s = sourceparse.parseModuleNameAndSpec(ns)
             self.assertEqual(n, 'reponame')
             self.assertEqual(s, ns)
Example #7
0
 def test_HGRefs(self):
     for url in HG_URLs:
         for spec in HG_Specs:
             if len(spec):
                 ns = url + '#' + spec
             else:
                 ns = url
             n, s = sourceparse.parseModuleNameAndSpec(ns)
             self.assertEqual(n, 'reponame')
             self.assertEqual(s, ns)
Example #8
0
def installComponent(args):
    path = folders.globalInstallDirectory() if args.act_globally else os.getcwd()
    logging.debug('install component %s to %s' % (args.component, path))

    from yotta.lib import sourceparse
    # check if we have both a name and specification
    component_name, component_spec = sourceparse.parseModuleNameAndSpec(args.component)

    try:
        access.satisfyVersion(
                  component_name,
                  component_spec,
                       available = dict(),
                    search_paths = [path],
               working_directory = path
        )
    except access_common.AccessException as e:
        logging.error('%s', e)
        return 1
    os.chdir(component_name)
    return installDeps(args, component.Component(os.getcwd()))
Example #9
0
def installComponent(args):
    path = folders.globalInstallDirectory(
    ) if args.act_globally else os.getcwd()
    logging.debug('install component %s to %s' % (args.component, path))

    from yotta.lib import sourceparse
    # check if we have both a name and specification
    component_name, component_spec = sourceparse.parseModuleNameAndSpec(
        args.component)

    try:
        access.satisfyVersion(component_name,
                              component_spec,
                              available=dict(),
                              search_paths=[path],
                              working_directory=path)
    except access_common.AccessException as e:
        logging.error('%s', e)
        return 1
    os.chdir(component_name)
    return installDeps(args, component.Component(os.getcwd()))
Example #10
0
 def test_validNames(self):
     for name in Valid_Names:
         n, s = sourceparse.parseModuleNameAndSpec(name)
         self.assertEqual(n, name)
         self.assertEqual(s, '*')
Example #11
0
 def test_GithubRefs(self):
     for url in Github_URLs:
         n, s = sourceparse.parseModuleNameAndSpec(url)
         self.assertEqual(n, 'reponame')
Example #12
0
def installComponentAsDependency(args, current_component):
    logging.debug('install component %s as dependency of %s' %
                  (args.component, current_component))
    if not current_component:
        logging.debug(str(current_component.getError()))
        logging.error('The current directory does not contain a valid module.')
        return -1
    target, errors = current_component.satisfyTarget(
        args.target, additional_config=args.config)
    if errors:
        for error in errors:
            logging.error(error)
        return 1
    modules_dir = current_component.modulesPath()

    from yotta.lib import sourceparse
    # check if we have both a name and specification
    component_name, component_spec = sourceparse.parseModuleNameAndSpec(
        args.component)
    logging.info('%s, %s', component_name, component_spec)

    if component_name == current_component.getName():
        logging.error('will not install module %s as a dependency of itself',
                      component_name)
        return -1
    try:
        installed = access.satisfyVersion(
            component_name,
            component_spec,
            available={current_component.getName(): current_component},
            search_paths=[modules_dir],
            working_directory=modules_dir)
    except access_common.AccessException as e:
        logging.error(e)
        return 1

    # We always add the component to the dependencies of the current component
    # (if it is not already present), and write that back to disk. Without
    # writing to disk the dependency wouldn't be usable.
    if installed and not current_component.hasDependency(component_name):
        saved_spec = current_component.saveDependency(installed)
        current_component.writeDescription()
        logging.info('dependency %s: %s written to module.json',
                     component_name, saved_spec)
    else:
        logging.info('dependency %s is already present in module.json',
                     component_name)

    # !!! should only install dependencies necessary for the one thing that
    # we're installing (but existing components should be made available to
    # satisfy dependencies)
    components, errors = current_component.satisfyDependenciesRecursive(
        target=target,
        available_components=[(current_component.getName(), current_component)
                              ],
        test={
            'own': 'toplevel',
            'all': True,
            'none': False
        }[args.install_test_deps])
    return checkPrintStatus(errors, components, current_component, target)