Exemple #1
0
def anod():
    """bin/anod script entry point.

    This script is installed in the sandbox.
    """
    import os
    import sys

    import e3.anod.driver
    import e3.anod.loader
    import e3.anod.sandbox
    import e3.env
    import e3.store
    import e3.store.cache

    sandbox_dir = os.path.abspath(
        os.path.join(os.path.dirname(sys.modules['__main__'].__file__),
                     os.pardir))

    sandbox = e3.anod.sandbox.SandBox()
    sandbox.root_dir = sandbox_dir

    # Load the local specs
    spec_repo = e3.anod.loader.AnodSpecRepository(sandbox.specs_dir)

    # Load the cache
    cache = e3.store.cache.load_cache('file-cache',
                                      {'cache_dir': sandbox.tmp_cache_dir})

    store = e3.store.load_store('http-simple-store', {}, cache)

    m = Main()
    subparsers = m.argument_parser.add_subparsers()
    anod_cmdline(subparsers, 'download', 'download a binary package')
    m.parse_args()

    action = m.args.action_name
    spec = m.args.spec
    qualifier = m.args.qualifier

    anod_cls = spec_repo.load(name=spec)
    anod_instance = anod_cls(qualifier=qualifier,
                             kind=action,
                             jobs=1,
                             env=e3.env.BaseEnv.from_env())

    # ??? inject the sandbox
    anod_instance.sandbox = sandbox

    driver = e3.anod.driver.AnodDriver(anod_instance=anod_instance,
                                       store=store)

    try:
        driver.activate(sandbox, spec_repo)
        driver.call(action)
    except AnodError as err:
        print(err, file=sys.stderr)
        sys.exit(1)
Exemple #2
0
def test_simple_driver():
    sandbox = e3.anod.sandbox.SandBox()

    class Simple(e3.anod.spec.Anod):
        @e3.anod.spec.Anod.primitive()
        def download():
            pass

    with pytest.raises(e3.anod.spec.AnodError):
        anod_instance = Simple(qualifier="", kind="build")
        anod_instance.sandbox = None
        e3.anod.driver.AnodDriver(anod_instance=anod_instance, store=None).activate(
            sandbox, None
        )

    sandbox.root_dir = os.getcwd()
    anod_instance = Simple(qualifier="", kind="build")
    anod_instance.sandbox = sandbox
    driver = e3.anod.driver.AnodDriver(anod_instance=anod_instance, store=None)

    assert driver.call("why") is False
    with pytest.raises(e3.anod.spec.AnodError) as err:
        driver.download()

    assert ".activate() has not been called" in str(err)
Exemple #3
0
def test_simple_driver():
    sandbox = e3.anod.sandbox.SandBox(root_dir=os.getcwd())

    class Simple(e3.anod.spec.Anod):
        @e3.anod.spec.Anod.primitive()
        def download(self):
            pass

    anod_instance = Simple(qualifier="", kind="build")
    anod_instance.sandbox = sandbox
    driver = e3.anod.driver.AnodDriver(anod_instance=anod_instance, store=None)

    assert driver.call("why") is False
    with pytest.raises(e3.anod.spec.AnodError):
        driver.download()
Exemple #4
0
def test_simple_driver():
    sandbox = e3.anod.sandbox.SandBox()

    class Simple(e3.anod.spec.Anod):
        pass

    with pytest.raises(e3.anod.spec.AnodError):
        anod_instance = Simple(qualifier='', kind='build')
        anod_instance.sandbox = None
        e3.anod.driver.AnodDriver(anod_instance=anod_instance,
                                  store=None).activate()

    sandbox.root_dir = os.getcwd()
    anod_instance = Simple(qualifier='', kind='build')
    anod_instance.sandbox = sandbox
    driver = e3.anod.driver.AnodDriver(anod_instance=anod_instance, store=None)

    assert driver.call('why') is False
Exemple #5
0
def test_simple_driver():
    sandbox = e3.anod.sandbox.SandBox()

    class Simple(e3.anod.spec.Anod):
        pass

    with pytest.raises(e3.anod.spec.AnodError):
        anod_instance = Simple(
            qualifier='', kind='build')
        anod_instance.sandbox = None
        e3.anod.driver.AnodDriver(
            anod_instance=anod_instance,
            store=None).activate()

    sandbox.root_dir = os.getcwd()
    anod_instance = Simple(
        qualifier='', kind='build')
    anod_instance.sandbox = sandbox
    driver = e3.anod.driver.AnodDriver(
        anod_instance=anod_instance,
        store=None)

    assert driver.call('why') is False
def test_simple_driver():
    sandbox = e3.anod.sandbox.SandBox()

    class Simple(e3.anod.spec.Anod):
        pass

    with pytest.raises(e3.anod.spec.AnodError):
        anod_instance = Simple(
            qualifier='', kind='build')
        anod_instance.sandbox = None
        e3.anod.driver.AnodDriver(
            anod_instance=anod_instance,
            store=None).activate()

    tempd = tempfile.mkdtemp(suffix='pytest-e3-core')
    sandbox.root_dir = tempd
    anod_instance = Simple(
        qualifier='', kind='build')
    anod_instance.sandbox = sandbox
    driver = e3.anod.driver.AnodDriver(
        anod_instance=anod_instance,
        store=None)

    assert driver.call('why') is False
Exemple #7
0
def anod():
    """bin/anod script entry point.

    This script is installed in the sandbox.
    """
    import os
    import sys

    import e3.anod.driver
    import e3.anod.loader
    import e3.anod.sandbox
    import e3.env
    import e3.store
    import e3.store.cache

    sandbox_dir = os.path.abspath(os.path.join(os.path.dirname(
        sys.modules['__main__'].__file__), os.pardir))

    sandbox = e3.anod.sandbox.SandBox()
    sandbox.root_dir = sandbox_dir

    # Load the local specs
    spec_repo = e3.anod.loader.AnodSpecRepository(
        os.path.join(sandbox_dir, 'specs'))

    # Load the cache
    cache = e3.store.cache.load_cache(
        'file-cache',
        {'cache_dir': sandbox.tmp_cache_dir})

    store = e3.store.load_store(
        'http-simple-store', {}, cache)

    m = Main()
    subparsers = m.argument_parser.add_subparsers()
    anod_cmdline(subparsers, 'download', 'download a binary package')
    m.parse_args()

    action = m.args.action_name
    spec = m.args.spec
    qualifier = m.args.qualifier

    anod_cls = spec_repo.load(name=spec)
    anod_instance = anod_cls(qualifier=qualifier,
                             kind=action,
                             jobs=1,
                             env=e3.env.BaseEnv.from_env())

    # ??? inject the sandbox
    anod_instance.sandbox = sandbox

    driver = e3.anod.driver.AnodDriver(
        anod_instance=anod_instance,
        store=store)

    try:
        driver.activate()
        driver.call(action)
    except AnodError as err:
        print(err, file=sys.stderr)
        sys.exit(1)