Example #1
0
    def from_deployer_charm(cls, dcharm):
        c = cls()
        c['name'] = dcharm.name
        c['directory'] = dcharm.path
        c['testdir'] = utils.find_testdir(dcharm.path)

        return c
Example #2
0
def BundleClassifier(directory, options):
    bundle = find_bundle_file(directory, options.bundle)
    if not bundle:
        return None
    return models.Bundle({
        'bundle': bundle,
        'testdir': utils.find_testdir(directory),
        'name': 'bundle',
    })
Example #3
0
def BundleClassifier(directory, options):
    bundle = find_bundle_file(directory, options.bundle)
    if not bundle:
        return None
    return models.Bundle({
        'bundle': bundle,
        'testdir': utils.find_testdir(directory),
        'name': 'bundle',
    })
Example #4
0
def CharmClassifier(directory, options):
    metadata = os.path.join(directory, "metadata.yaml")
    if not os.path.exists(metadata):
        return None
    testdir = utils.find_testdir(directory)
    metadata = yaml.safe_load(open(metadata))
    return models.Charm({
        'metadata': metadata,
        'testdir': testdir,
        'name': metadata['name'],
    })
Example #5
0
def CharmClassifier(directory, options):
    metadata = os.path.join(directory, "metadata.yaml")
    if not os.path.exists(metadata):
        return None
    testdir = utils.find_testdir(directory)
    metadata = yaml.safe_load(open(metadata))
    return models.Charm({
        'metadata': metadata,
        'testdir': testdir,
        'name': metadata['name'],
    })
Example #6
0
def CharmClassifier(directory, options):
    metadata = os.path.join(directory, "metadata.yaml")
    if not os.path.exists(metadata):
        return None
    lp = vcs.Launchpad()
    data = lp.infer_charm(directory) or {}
    testdir = utils.find_testdir(directory)
    metadata = yaml.safe_load(open(metadata))
    data['metadata'] = metadata
    data['testdir'] = testdir
    if 'name' not in data:
        data['name'] = metadata['name']
    return models.Charm(**data)
Example #7
0
def CharmClassifier(directory, options):
    metadata = os.path.join(directory, "metadata.yaml")
    if not os.path.exists(metadata):
        return None
    lp = vcs.Launchpad()
    data = lp.infer_charm(directory) or {}
    testdir = utils.find_testdir(directory)
    metadata = yaml.safe_load(open(metadata))
    data['metadata'] = metadata
    data['testdir'] = testdir
    if 'name' not in data:
        data['name'] = metadata['name']
    return models.Charm(**data)
Example #8
0
def BundleClassifier(directory, options):
    bundle = find_bundle_file(directory, options.bundle)
    if not bundle:
        return None
    result = {'bundle': bundle, 'testdir': utils.find_testdir(directory)}
    lp = vcs.Launchpad()
    data = lp.infer_bundle(directory) or {}
    result.update(data)
    if 'name' not in data:
        with open(bundle) as fh:
            metadata = yaml.safe_load(fh)
        # XXX: ambiguous
        result['name'] = metadata.keys()[0]
    return models.Bundle(**result)
Example #9
0
def BundleClassifier(directory, options):
    bundle = find_bundle_file(directory, options.bundle)
    if not bundle:
        return None
    result = {'bundle': bundle,
              'testdir': utils.find_testdir(directory)}
    lp = vcs.Launchpad()
    data = lp.infer_bundle(directory) or {}
    result.update(data)
    if 'name' not in data:
        with open(bundle) as fh:
            metadata = yaml.safe_load(fh)
        # XXX: ambiguous
        result['name'] = metadata.keys()[0]
    return models.Bundle(**result)
Example #10
0
    def from_deployer_charm(cls, dcharm):
        """Copy charm source from the deployer cache to a new temp location
        so we can change the charm dir name to match the charm name
        (some tests rely on these matching).

        """
        tmp_dir = tempfile.mkdtemp()
        charm_name = dcharm.name.split('/')[-1]

        # Strip off revision if there is one
        name_parts = charm_name.split('-')
        if is_int(name_parts[-1]):
            charm_name = '-'.join(name_parts[:-1])

        charm_dir = os.path.join(tmp_dir, charm_name)
        shutil.copytree(dcharm.path, charm_dir, symlinks=True)
        atexit.register(shutil.rmtree, tmp_dir)

        c = cls()
        c['name'] = dcharm.name
        c['directory'] = charm_dir
        c['testdir'] = utils.find_testdir(charm_dir)

        return c
Example #11
0
    def from_deployer_charm(cls, dcharm):
        """Copy charm source from the deployer cache to a new temp location
        so we can change the charm dir name to match the charm name
        (some tests rely on these matching).

        """
        tmp_dir = tempfile.mkdtemp()
        charm_name = dcharm.name.split("/")[-1]

        # Strip off revision if there is one
        name_parts = charm_name.split("-")
        if is_int(name_parts[-1]):
            charm_name = "-".join(name_parts[:-1])

        charm_dir = os.path.join(tmp_dir, charm_name)
        shutil.copytree(dcharm.path, charm_dir, symlinks=True)
        atexit.register(shutil.rmtree, tmp_dir)

        c = cls()
        c["name"] = dcharm.name
        c["directory"] = charm_dir
        c["testdir"] = utils.find_testdir(charm_dir)

        return c