commit:     125ca190d30215de85fc3343c95784e658f75c37
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri May 20 05:43:14 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri May 20 05:43:14 2016 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=125ca190

replace os.system with cmd

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:

Reply via email to