Exemplo n.º 1
0
def test_multiargs_no_argumetns():
    stack = []

    def dummy(*args, **kwargs):
        stack.append((args, kwargs))

    decorator.multiargs(dummy)()
    assert stack == [((), {})]
Exemplo n.º 2
0
def test_multiargs_no_list():
    stack = []

    def dummy(*args, **kwargs):
        stack.append((args, kwargs))

    decorator.multiargs(dummy)("foo", bar="baz")
    assert stack == [(("foo",), {"bar": "baz"})]
Exemplo n.º 3
0
def test_multiargs():
    stack = []

    def dummy(*args, **kwargs):
        stack.append((args, kwargs))

    decorator.multiargs(dummy)([1, 2, 3])
    print stack
    assert stack == [((1,), {}), ((2,), {}), ((3,), {})]
Exemplo n.º 4
0
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, with_statement

from cuisine import package_ensure as ensure
from cuisine import package_install as install
from cuisine import package_update as update
from cuisine import package_upgrade as upgrade

from revolver import contextmanager as ctx
from revolver import file, server, core, decorator

ensure = decorator.multiargs(decorator.sudo(ensure))
install = decorator.multiargs(decorator.sudo(install))
update = decorator.multiargs(decorator.sudo(update))
upgrade = decorator.sudo(upgrade)


def is_installed(name):
    with ctx.settings(warn_only=True):
        res = core.run("dpkg -s %s" % name)
        for line in res.splitlines():
            if line.startswith("Status: "):
                status = line[8:]
                if "installed" in status.split(" "):
                    return True
        return False


def install_ppa(name):
    ensure("python-software-properties")