From cc567a89c6813341913055a8250c241fa737be84 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 10 Dec 2011 12:05:38 -0800 Subject: [PATCH] Use portage.shutil for safer unicode handling. --- pym/_emerge/Binpkg.py | 2 +- pym/_emerge/actions.py | 2 +- pym/portage/dbapi/vartree.py | 2 +- pym/portage/package/ebuild/_spawn_nofetch.py | 2 +- pym/portage/package/ebuild/doebuild.py | 3 +-- pym/portage/package/ebuild/fetch.py | 3 +-- pym/portage/package/ebuild/prepare_build_dirs.py | 3 +-- pym/portage/tests/dbapi/test_fakedbapi.py | 2 +- pym/portage/tests/ebuild/test_ipc_daemon.py | 4 ++-- pym/portage/tests/locks/test_asynchronous_lock.py | 2 +- pym/portage/tests/locks/test_lock_nonblock.py | 2 +- pym/portage/tests/repoman/test_simple.py | 2 +- pym/portage/tests/resolver/ResolverPlayground.py | 2 +- pym/portage/xpak.py | 2 +- pym/repoman/utilities.py | 2 +- 15 files changed, 16 insertions(+), 19 deletions(-) diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py index b25906918..ba25d3a4b 100644 --- a/pym/_emerge/Binpkg.py +++ b/pym/_emerge/Binpkg.py @@ -14,12 +14,12 @@ from portage.eapi import eapi_exports_replace_vars from portage.util import ensure_dirs, writemsg import portage from portage import os +from portage import shutil from portage import _encodings from portage import _unicode_decode from portage import _unicode_encode import io import logging -import shutil from portage.output import colorize class Binpkg(CompositeTask): diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index b7b3b90e7..f38998d09 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -10,7 +10,6 @@ import platform import pwd import random import re -import shutil import signal import socket import stat @@ -27,6 +26,7 @@ portage.proxy.lazyimport.lazyimport(globals(), ) from portage import os +from portage import shutil from portage import subprocess_getstatusoutput from portage import _unicode_decode from portage.cache.cache_errors import CacheError diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 9af3a8733..a9a147a98 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -48,6 +48,7 @@ from portage import abssymlink, _movefile, bsd_chflags # This is a special version of the os module, wrapped for unicode support. from portage import os +from portage import shutil from portage import _encodings from portage import _os_merge from portage import _selinux_merge @@ -69,7 +70,6 @@ import logging import os as _os import pwd import re -import shutil import stat import sys import tempfile diff --git a/pym/portage/package/ebuild/_spawn_nofetch.py b/pym/portage/package/ebuild/_spawn_nofetch.py index befdc89d4..bda1dc078 100644 --- a/pym/portage/package/ebuild/_spawn_nofetch.py +++ b/pym/portage/package/ebuild/_spawn_nofetch.py @@ -1,10 +1,10 @@ # Copyright 2010-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -import shutil import tempfile from portage import os +from portage import shutil from portage.const import EBUILD_PHASES from portage.elog import elog_process from portage.package.ebuild.config import config diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index 865ccd49d..37aead0f3 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -10,7 +10,6 @@ from itertools import chain import logging import os as _os import re -import shutil import signal import stat import sys @@ -31,7 +30,7 @@ portage.proxy.lazyimport.lazyimport(globals(), ) from portage import auxdbkeys, bsd_chflags, \ - eapi_is_supported, merge, os, selinux, \ + eapi_is_supported, merge, os, selinux, shutil, \ unmerge, _encodings, _parse_eapi_ebuild_head, _os_merge, \ _shell_quote, _unicode_decode, _unicode_encode from portage.const import EBUILD_SH_ENV_FILE, EBUILD_SH_ENV_DIR, \ diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py index 43597ac7d..70743bfb2 100644 --- a/pym/portage/package/ebuild/fetch.py +++ b/pym/portage/package/ebuild/fetch.py @@ -10,7 +10,6 @@ import io import logging import random import re -import shutil import stat import sys import tempfile @@ -24,7 +23,7 @@ portage.proxy.lazyimport.lazyimport(globals(), 'portage.package.ebuild.prepare_build_dirs:prepare_build_dirs', ) -from portage import OrderedDict, os, selinux, _encodings, \ +from portage import OrderedDict, os, selinux, shutil, _encodings, \ _shell_quote, _unicode_encode from portage.checksum import hashfunc_map, perform_md5, verify_all from portage.const import BASH_BINARY, CUSTOM_MIRRORS_FILE, \ diff --git a/pym/portage/package/ebuild/prepare_build_dirs.py b/pym/portage/package/ebuild/prepare_build_dirs.py index 6de486acf..50b14ec91 100644 --- a/pym/portage/package/ebuild/prepare_build_dirs.py +++ b/pym/portage/package/ebuild/prepare_build_dirs.py @@ -5,12 +5,11 @@ __all__ = ['prepare_build_dirs'] import errno import gzip -import shutil import stat import time import portage -from portage import os, _encodings, _unicode_encode, _unicode_decode +from portage import os, shutil, _encodings, _unicode_encode, _unicode_decode from portage.data import portage_gid, portage_uid, secpass from portage.exception import DirectoryNotFound, FileNotFound, \ OperationNotPermitted, PermissionDenied, PortageException diff --git a/pym/portage/tests/dbapi/test_fakedbapi.py b/pym/portage/tests/dbapi/test_fakedbapi.py index cfef94e26..bce824530 100644 --- a/pym/portage/tests/dbapi/test_fakedbapi.py +++ b/pym/portage/tests/dbapi/test_fakedbapi.py @@ -1,10 +1,10 @@ # Copyright 2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -import shutil import tempfile from portage import os +from portage import shutil from portage.dbapi.virtual import fakedbapi from portage.package.ebuild.config import config from portage.tests import TestCase diff --git a/pym/portage/tests/ebuild/test_ipc_daemon.py b/pym/portage/tests/ebuild/test_ipc_daemon.py index b5b4796e1..379953d4b 100644 --- a/pym/portage/tests/ebuild/test_ipc_daemon.py +++ b/pym/portage/tests/ebuild/test_ipc_daemon.py @@ -1,10 +1,10 @@ -# Copyright 2010 Gentoo Foundation +# Copyright 2010-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -import shutil import tempfile import time from portage import os +from portage import shutil from portage import _python_interpreter from portage.tests import TestCase from portage.const import PORTAGE_BIN_PATH diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/portage/tests/locks/test_asynchronous_lock.py index 8946caf89..0d6f11656 100644 --- a/pym/portage/tests/locks/test_asynchronous_lock.py +++ b/pym/portage/tests/locks/test_asynchronous_lock.py @@ -1,11 +1,11 @@ # Copyright 2010-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -import shutil import signal import tempfile from portage import os +from portage import shutil from portage.tests import TestCase from _emerge.AsynchronousLock import AsynchronousLock from _emerge.PollScheduler import PollScheduler diff --git a/pym/portage/tests/locks/test_lock_nonblock.py b/pym/portage/tests/locks/test_lock_nonblock.py index d5748ad62..cc1b28e82 100644 --- a/pym/portage/tests/locks/test_lock_nonblock.py +++ b/pym/portage/tests/locks/test_lock_nonblock.py @@ -1,12 +1,12 @@ # Copyright 2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -import shutil import tempfile import traceback import portage from portage import os +from portage import shutil from portage.tests import TestCase class LockNonblockTestCase(TestCase): diff --git a/pym/portage/tests/repoman/test_simple.py b/pym/portage/tests/repoman/test_simple.py index 5f6d7fc74..3643ff2d7 100644 --- a/pym/portage/tests/repoman/test_simple.py +++ b/pym/portage/tests/repoman/test_simple.py @@ -1,13 +1,13 @@ # Copyright 2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -import shutil import subprocess import sys import time import portage from portage import os +from portage import shutil from portage import _unicode_decode from portage.const import PORTAGE_BASE_PATH, PORTAGE_BIN_PATH, PORTAGE_PYM_PATH from portage.process import find_binary diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py index cbf42efc3..a18585508 100644 --- a/pym/portage/tests/resolver/ResolverPlayground.py +++ b/pym/portage/tests/resolver/ResolverPlayground.py @@ -2,11 +2,11 @@ # Distributed under the terms of the GNU General Public License v2 from itertools import permutations -import shutil import sys import tempfile import portage from portage import os +from portage import shutil from portage.const import (GLOBAL_CONFIG_PATH, PORTAGE_BASE_PATH, USER_CONFIG_PATH) from portage.dbapi.vartree import vartree diff --git a/pym/portage/xpak.py b/pym/portage/xpak.py index a05a86009..f95ade9a8 100644 --- a/pym/portage/xpak.py +++ b/pym/portage/xpak.py @@ -22,11 +22,11 @@ __all__ = ['addtolist', 'decodeint', 'encodeint', 'getboth', import array import errno -import shutil import sys import portage from portage import os +from portage import shutil from portage import normalize_path from portage import _encodings from portage import _unicode_decode diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py index c42c4c59d..449005ab1 100644 --- a/pym/repoman/utilities.py +++ b/pym/repoman/utilities.py @@ -34,10 +34,10 @@ import sys import time import textwrap import difflib -import shutil from tempfile import mkstemp from portage import os +from portage import shutil from portage import subprocess_getstatusoutput from portage import _encodings from portage import _unicode_decode -- 2.26.2