From: Mike Frysinger <vapier@gentoo.org>
To: gentoo-catalyst@lists.gentoo.org
Subject: [gentoo-catalyst] [PATCH 4/4] replace os.system with cmd
Date: Fri, 20 May 2016 10:27:46 -0400 [thread overview]
Message-ID: <1463754466-15028-4-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1463754466-15028-1-git-send-email-vapier@gentoo.org>
Use the existing cmd() helper for running external programs.
---
catalyst/base/stagebase.py | 11 ++++++-----
catalyst/fileops.py | 4 ++--
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index f0f3ba9..6695ac4 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -967,16 +967,17 @@ class StageBase(TargetBase, ClearBase, GenBase):
if not ismount(target):
continue
- retval=os.system("umount " + target)
-
- if retval!=0:
+ try:
+ cmd(['umount', target])
+ except CatalystError:
log.warning('First attempt to unmount failed: %s', target)
log.warning('Killing any pids still running in the chroot')
self.kill_chroot_pids()
- retval2 = os.system("umount " + target)
- if retval2!=0:
+ try:
+ cmd(['umount', target])
+ except CatalystError:
ouch=1
log.warning("Couldn't umount bind mount: %s", target)
diff --git a/catalyst/fileops.py b/catalyst/fileops.py
index 4b9e200..6971911 100644
--- a/catalyst/fileops.py
+++ b/catalyst/fileops.py
@@ -22,7 +22,7 @@ from snakeoil.osutils import (ensure_dirs as snakeoil_ensure_dirs,
# pylint: enable=unused-import
from catalyst import log
-from catalyst.support import CatalystError
+from catalyst.support import (cmd, CatalystError)
def ensure_dirs(path, gid=-1, uid=-1, mode=0o755, minimal=True,
@@ -79,7 +79,7 @@ def clear_dir(target, mode=0o755, chg_flags=False, remove=False,
mystat = os.stat(target)
# There's no easy way to change flags recursively in python
if chg_flags and os.uname()[0] == "FreeBSD":
- os.system("chflags -R noschg " + target)
+ cmd(['chflags', '-R', 'noschg', target])
log.debug('shutil.rmtree()')
shutil.rmtree(target)
except Exception:
--
2.8.2
next prev parent reply other threads:[~2016-05-20 14:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-20 14:27 [gentoo-catalyst] [PATCH 1/4] use native code in more places for file ops Mike Frysinger
2016-05-20 14:27 ` [gentoo-catalyst] [PATCH 2/4] cmd: add support for running commands directly Mike Frysinger
2016-05-20 15:48 ` Brian Dolbec
2016-05-20 14:27 ` [gentoo-catalyst] [PATCH 3/4] replace ad-hoc implementations of clear_dir Mike Frysinger
2016-05-20 15:49 ` Brian Dolbec
2016-05-20 14:27 ` Mike Frysinger [this message]
2016-05-20 15:51 ` [gentoo-catalyst] [PATCH 4/4] replace os.system with cmd Brian Dolbec
2016-05-20 15:46 ` [gentoo-catalyst] [PATCH 1/4] use native code in more places for file ops Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1463754466-15028-4-git-send-email-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gentoo-catalyst@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox