Skip to content

Commit

Permalink
don’t throw exceptions when we will still detect failure anyway
Browse files Browse the repository at this point in the history
  • Loading branch information
trehn committed Aug 29, 2017
1 parent daf0f3a commit dc6f15e
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 28 deletions.
3 changes: 2 additions & 1 deletion bundlewrap/items/pkg_apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def pkg_install(self):
runlevel +
"DEBIAN_FRONTEND=noninteractive "
"apt-get -qy -o Dpkg::Options::=--force-confold --no-install-recommends "
"install {}".format(quote(self.name.replace("_", ":")))
"install {}".format(quote(self.name.replace("_", ":"))),
may_fail=True,
)

def pkg_installed(self):
Expand Down
4 changes: 2 additions & 2 deletions bundlewrap/items/pkg_dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def pkg_all_installed(self):
yield "{}:{}".format(self.ITEM_TYPE_NAME, line.split()[0].split(".")[0])

def pkg_install(self):
self.node.run("dnf -d0 -e0 -y install {}".format(quote(self.name)))
self.node.run("dnf -d0 -e0 -y install {}".format(quote(self.name)), may_fail=True)

def pkg_installed(self):
result = self.node.run(
Expand All @@ -30,4 +30,4 @@ def pkg_installed(self):
return result.return_code == 0

def pkg_remove(self):
self.node.run("dnf -d0 -e0 -y remove {}".format(quote(self.name)))
self.node.run("dnf -d0 -e0 -y remove {}".format(quote(self.name)), may_fail=True)
4 changes: 2 additions & 2 deletions bundlewrap/items/pkg_openbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

def pkg_install(node, pkgname, version):
full_name = "{}-{}".format(pkgname, version) if version else pkgname
return node.run("pkg_add -r -I {}".format(full_name))
return node.run("pkg_add -r -I {}".format(full_name), may_fail=True)


def pkg_installed(node, pkgname):
Expand All @@ -30,7 +30,7 @@ def pkg_installed(node, pkgname):


def pkg_remove(node, pkgname):
return node.run("pkg_delete -I -D dependencies {}".format(quote(pkgname)))
return node.run("pkg_delete -I -D dependencies {}".format(quote(pkgname)), may_fail=True)


class OpenBSDPkg(Item):
Expand Down
6 changes: 3 additions & 3 deletions bundlewrap/items/pkg_pacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def pkg_install(self):
local_file = join(self.item_dir, self.attributes['tarball'])
remote_file = "/tmp/{}".format(basename(local_file))
self.node.upload(local_file, remote_file)
self.node.run("pacman --noconfirm -U {}".format(quote(remote_file)))
self.node.run("pacman --noconfirm -U {}".format(quote(remote_file)), may_fail=True)
self.node.run("rm -- {}".format(quote(remote_file)))
else:
self.node.run("pacman --noconfirm -S {}".format(quote(self.name)))
self.node.run("pacman --noconfirm -S {}".format(quote(self.name)), may_fail=True)

def pkg_installed(self):
result = self.node.run(
Expand All @@ -48,4 +48,4 @@ def pkg_installed(self):
return result.return_code == 0

def pkg_remove(self):
self.node.run("pacman --noconfirm -Rs {}".format(quote(self.name)))
self.node.run("pacman --noconfirm -Rs {}".format(quote(self.name)), may_fail=True)
4 changes: 2 additions & 2 deletions bundlewrap/items/pkg_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def pkg_install(node, pkgname, version=None):
if version:
pkgname = "{}=={}".format(pkgname, version)
pip_path, pkgname = split_path(pkgname)
return node.run("{} install -U {}".format(quote(pip_path), quote(pkgname)))
return node.run("{} install -U {}".format(quote(pip_path), quote(pkgname)), may_fail=True)


def pkg_installed(node, pkgname):
Expand All @@ -30,7 +30,7 @@ def pkg_installed(node, pkgname):

def pkg_remove(node, pkgname):
pip_path, pkgname = split_path(pkgname)
return node.run("{} uninstall -y {}".format(quote(pip_path), quote(pkgname)))
return node.run("{} uninstall -y {}".format(quote(pip_path), quote(pkgname)), may_fail=True)


class PipPkg(Item):
Expand Down
4 changes: 2 additions & 2 deletions bundlewrap/items/pkg_snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def pkg_all_installed(self):
yield "{}:{}".format(self.ITEM_TYPE_NAME, line.split()[0].split(" ")[0])

def pkg_install(self):
self.node.run("snap install {}".format(quote(self.name)))
self.node.run("snap install {}".format(quote(self.name)), may_fail=True)

def pkg_installed(self):
result = self.node.run(
Expand All @@ -30,4 +30,4 @@ def pkg_installed(self):
return result.return_code == 0

def pkg_remove(self):
self.node.run("snap remove {}".format(quote(self.name)))
self.node.run("snap remove {}".format(quote(self.name)), may_fail=True)
4 changes: 2 additions & 2 deletions bundlewrap/items/pkg_yum.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def pkg_all_installed(self):
yield "{}:{}".format(self.ITEM_TYPE_NAME, line.split()[0].split(".")[0])

def pkg_install(self):
self.node.run("yum -d0 -e0 -y install {}".format(quote(self.name)))
self.node.run("yum -d0 -e0 -y install {}".format(quote(self.name)), may_fail=True)

def pkg_installed(self):
result = self.node.run(
Expand All @@ -30,4 +30,4 @@ def pkg_installed(self):
return result.return_code == 0

def pkg_remove(self):
self.node.run("yum -d0 -e0 -y remove {}".format(quote(self.name)))
self.node.run("yum -d0 -e0 -y remove {}".format(quote(self.name)), may_fail=True)
4 changes: 2 additions & 2 deletions bundlewrap/items/pkg_zypper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


def pkg_install(node, pkgname):
return node.run("zypper {} install {}".format(ZYPPER_OPTS, quote(pkgname)))
return node.run("zypper {} install {}".format(ZYPPER_OPTS, quote(pkgname)), may_fail=True)


def pkg_installed(node, pkgname):
Expand All @@ -30,7 +30,7 @@ def pkg_installed(node, pkgname):


def pkg_remove(node, pkgname):
return node.run("zypper {} remove {}".format(ZYPPER_OPTS, quote(pkgname)))
return node.run("zypper {} remove {}".format(ZYPPER_OPTS, quote(pkgname)), may_fail=True)


class ZypperPkg(Item):
Expand Down
8 changes: 4 additions & 4 deletions bundlewrap/items/svc_openbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def svc_start(node, svcname):
return node.run("/etc/rc.d/{} start".format(quote(svcname)))
return node.run("/etc/rc.d/{} start".format(quote(svcname)), may_fail=True)


def svc_running(node, svcname):
Expand All @@ -18,11 +18,11 @@ def svc_running(node, svcname):


def svc_stop(node, svcname):
return node.run("/etc/rc.d/{} stop".format(quote(svcname)))
return node.run("/etc/rc.d/{} stop".format(quote(svcname)), may_fail=True)


def svc_enable(node, svcname):
return node.run("rcctl set {} status on".format(quote(svcname)))
return node.run("rcctl set {} status on".format(quote(svcname)), may_fail=True)


def svc_enabled(node, svcname):
Expand All @@ -34,7 +34,7 @@ def svc_enabled(node, svcname):


def svc_disable(node, svcname):
return node.run("rcctl set {} status off".format(quote(svcname)))
return node.run("rcctl set {} status off".format(quote(svcname)), may_fail=True)


class SvcOpenBSD(Item):
Expand Down
8 changes: 4 additions & 4 deletions bundlewrap/items/svc_systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def svc_start(node, svcname):
return node.run("systemctl start -- {}".format(quote(svcname)))
return node.run("systemctl start -- {}".format(quote(svcname)), may_fail=True)


def svc_running(node, svcname):
Expand All @@ -21,11 +21,11 @@ def svc_running(node, svcname):


def svc_stop(node, svcname):
return node.run("systemctl stop -- {}".format(quote(svcname)))
return node.run("systemctl stop -- {}".format(quote(svcname)), may_fail=True)


def svc_enable(node, svcname):
return node.run("systemctl enable -- {}".format(quote(svcname)))
return node.run("systemctl enable -- {}".format(quote(svcname)), may_fail=True)


def svc_enabled(node, svcname):
Expand All @@ -37,7 +37,7 @@ def svc_enabled(node, svcname):


def svc_disable(node, svcname):
return node.run("systemctl disable -- {}".format(quote(svcname)))
return node.run("systemctl disable -- {}".format(quote(svcname)), may_fail=True)


class SvcSystemd(Item):
Expand Down
4 changes: 2 additions & 2 deletions bundlewrap/items/svc_systemv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def svc_start(node, svcname):
return node.run("/etc/init.d/{} start".format(quote(svcname)))
return node.run("/etc/init.d/{} start".format(quote(svcname)), may_fail=True)


def svc_running(node, svcname):
Expand All @@ -21,7 +21,7 @@ def svc_running(node, svcname):


def svc_stop(node, svcname):
return node.run("/etc/init.d/{} stop".format(quote(svcname)))
return node.run("/etc/init.d/{} stop".format(quote(svcname)), may_fail=True)


class SvcSystemV(Item):
Expand Down
4 changes: 2 additions & 2 deletions bundlewrap/items/svc_upstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def svc_start(node, svcname):
return node.run("initctl start --no-wait -- {}".format(quote(svcname)))
return node.run("initctl start --no-wait -- {}".format(quote(svcname)), may_fail=True)


def svc_running(node, svcname):
Expand All @@ -20,7 +20,7 @@ def svc_running(node, svcname):


def svc_stop(node, svcname):
return node.run("initctl stop --no-wait -- {}".format(quote(svcname)))
return node.run("initctl stop --no-wait -- {}".format(quote(svcname)), may_fail=True)


class SvcUpstart(Item):
Expand Down

0 comments on commit dc6f15e

Please sign in to comment.