Exemple #1
0
def test_get_installdir():
    '''get install directory should return the base of where sregistry
       is installed
    '''
    print("Testing utils.get_installdir")
    from sregistry.utils import get_installdir
    whereami = get_installdir()
    print(whereami)
    assert whereami.endswith('sregistry')
def get_build_template(name="singularity-cloudbuild-local.json"):
    """get default build template.

       Parameters
       ==========
       name: singularity-cloudbuild-local.json (default) that will build a
                 container interactively, waiting for the build to finish.
             singularity-cloudbuild-git.json build a recipe from a GitHub
                 repository.
    """
    base = get_installdir()
    name = "%s/main/templates/build/%s" % (base, name)

    if os.path.exists(name):
        bot.debug("Found template %s" % name)
        return read_json(name)

    bot.warning("Template %s not found." % name)
def get_build_template(name=None, manager="apt"):
    """get a particular build template, by default we return templates
       that are based on package managers.

       Parameters
       ==========
       name: the full path of the template file to use.
       manager: the package manager to use in the template (yum or apt)

    """
    base = get_installdir()
    if name is None:
        name = "%s/main/templates/build/singularity-builder-%s.sh" % (base, manager)

    if os.path.exists(name):
        bot.debug("Found template %s" % name)
        return "".join(read_file(name))

    bot.warning("Template %s not found." % name)