From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 13423138262 for ; Fri, 20 May 2016 14:28:01 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 431AB141C1; Fri, 20 May 2016 14:27:52 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4D566141AD for ; Fri, 20 May 2016 14:27:51 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 682D3340C93 for ; Fri, 20 May 2016 14:27:50 +0000 (UTC) From: Mike Frysinger 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 Message-Id: <1463754466-15028-4-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1463754466-15028-1-git-send-email-vapier@gentoo.org> References: <1463754466-15028-1-git-send-email-vapier@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Archives-Salt: 363d7b24-46ca-4f7c-9c44-4e807499007a X-Archives-Hash: cd0cae2e99d7adc5ff7acb2b02d72bb9 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