From 6034b1210e2bda02095a157b55505ea652f67e3c Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 12 Jul 2011 16:20:45 -0700 Subject: [PATCH] Use portage.subprocess_getstatusoutput() more. --- pym/_emerge/actions.py | 7 ++----- pym/_emerge/main.py | 8 +++----- pym/portage/checksum.py | 9 +++------ pym/portage/dispatch_conf.py | 6 +----- pym/portage/output.py | 6 +----- 5 files changed, 10 insertions(+), 26 deletions(-) diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 62dadeec2..f6c2721fa 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -3,10 +3,6 @@ from __future__ import print_function -try: - from subprocess import getstatusoutput as subprocess_getstatusoutput -except ImportError: - from commands import getstatusoutput as subprocess_getstatusoutput import errno import logging import platform @@ -25,7 +21,7 @@ from itertools import chain import portage from portage import os -from portage import digraph +from portage import subprocess_getstatusoutput from portage import _unicode_decode from portage.cache.cache_errors import CacheError from portage.const import GLOBAL_CONFIG_PATH, NEWS_LIB_PATH @@ -44,6 +40,7 @@ from portage._sets import load_default_config, SETPREFIX from portage._sets.base import InternalPackageSet from portage.util import cmp_sort_key, writemsg, \ writemsg_level, writemsg_stdout +from portage.util.digraph import digraph from portage._global_updates import _global_updates from _emerge.clear_caches import clear_caches diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 21dea4035..42ce81069 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -9,10 +9,6 @@ import stat import sys import textwrap import platform -try: - from subprocess import getstatusoutput as subprocess_getstatusoutput -except ImportError: - from commands import getstatusoutput as subprocess_getstatusoutput import portage from portage import os from portage import _encodings @@ -162,7 +158,9 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval): raise del e processed_count += 1 - myso=subprocess_getstatusoutput("LANG=C LANGUAGE=C /usr/bin/install-info --dir-file="+inforoot+"/dir "+inforoot+"/"+x)[1] + myso = portage.subprocess_getstatusoutput( + "LANG=C LANGUAGE=C /usr/bin/install-info " + + "--dir-file=%s/dir %s/%s" % (inforoot, inforoot, x))[1] existsstr="already exists, for file `" if myso!="": if re.search(existsstr,myso): diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py index eeb5995bb..9e7e455d1 100644 --- a/pym/portage/checksum.py +++ b/pym/portage/checksum.py @@ -1,5 +1,5 @@ # checksum.py -- core Portage functionality -# Copyright 1998-2010 Gentoo Foundation +# Copyright 1998-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import portage @@ -11,10 +11,6 @@ from portage import _unicode_encode import errno import stat import tempfile -try: - from subprocess import getstatusoutput as subprocess_getstatusoutput -except ImportError: - from commands import getstatusoutput as subprocess_getstatusoutput #dict of all available hash functions hashfunc_map = {} @@ -125,7 +121,8 @@ hashfunc_map["size"] = getsize prelink_capable = False if os.path.exists(PRELINK_BINARY): - results = subprocess_getstatusoutput(PRELINK_BINARY+" --version > /dev/null 2>&1") + results = portage.subprocess_getstatusoutput( + "%s --version > /dev/null 2>&1" % (PRELINK_BINARY,)) if (results[0] >> 8) == 0: prelink_capable=1 del results diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py index 228638c01..499102030 100644 --- a/pym/portage/dispatch_conf.py +++ b/pym/portage/dispatch_conf.py @@ -9,10 +9,6 @@ from __future__ import print_function import os, sys, shutil -try: - from subprocess import getstatusoutput as subprocess_getstatusoutput -except ImportError: - from commands import getstatusoutput as subprocess_getstatusoutput import portage from portage.env.loaders import KeyValuePairFileLoader @@ -36,7 +32,7 @@ def diffstatusoutput_len(cmd): UnicodeDecodeError when necessary. """ try: - status, output = subprocess_getstatusoutput(cmd) + status, output = portage.subprocess_getstatusoutput(cmd) return (status, len(output)) except UnicodeDecodeError: return (1, 1) diff --git a/pym/portage/output.py b/pym/portage/output.py index 1bceb0e90..0e8245f9a 100644 --- a/pym/portage/output.py +++ b/pym/portage/output.py @@ -3,10 +3,6 @@ __docformat__ = "epytext" -try: - from subprocess import getstatusoutput as subprocess_getstatusoutput -except ImportError: - from commands import getstatusoutput as subprocess_getstatusoutput import errno import io import formatter @@ -435,7 +431,7 @@ def get_term_size(): pass except ImportError: pass - st, out = subprocess_getstatusoutput('stty size') + st, out = portage.subprocess_getstatusoutput('stty size') if st == os.EX_OK: out = out.split() if len(out) == 2: -- 2.26.2