Update system imports for compatibility with Python 3.
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Sun, 20 Sep 2009 16:22:08 +0000 (16:22 -0000)
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Sun, 20 Sep 2009 16:22:08 +0000 (16:22 -0000)
svn path=/main/trunk/; revision=14294

18 files changed:
bin/dispatch-conf
bin/glsa-check
bin/repoman
pym/_emerge/BinpkgFetcher.py
pym/_emerge/JobStatusDisplay.py
pym/_emerge/actions.py
pym/_emerge/main.py
pym/portage/__init__.py
pym/portage/checksum.py
pym/portage/data.py
pym/portage/dbapi/bintree.py
pym/portage/dispatch_conf.py
pym/portage/getbinpkg.py
pym/portage/glsa.py
pym/portage/output.py
pym/portage/sets/__init__.py
pym/portage/util.py
pym/repoman/utilities.py

index 38359c5b30fcdf32d15377f10f376c066de81897..5247cdb608ddbe35451d0dcea7b11d3cf63ac988 100755 (executable)
@@ -19,7 +19,13 @@ if not hasattr(__builtins__, "set"):
 
 from stat import *
 from random import *
-import atexit, commands, re, shutil, stat, sys
+import atexit, re, shutil, stat, sys
+try:
+    from subprocess import getoutput as subprocess_getoutput
+    from subprocess import getstatusoutput as subprocess_getstatusoutput
+except ImportError:
+    from commands import getoutput as subprocess_getoutput
+    from commands import getstatusoutput as subprocess_getstatusoutput
 try:
     import portage
 except ImportError:
@@ -131,11 +137,11 @@ class dispatch:
             else:
                 mrgfail = portage.dispatch_conf.file_archive(archive, conf['current'], conf['new'], mrgconf)
             if os.path.exists(archive + '.dist'):
-                unmodified = len(commands.getoutput(DIFF_CONTENTS % (conf['current'], archive + '.dist'))) == 0
+                unmodified = len(subprocess_getoutput(DIFF_CONTENTS % (conf['current'], archive + '.dist'))) == 0
             else:
                 unmodified = 0
             if os.path.exists(mrgconf):
-                if mrgfail or len(commands.getoutput(DIFF_CONTENTS % (conf['new'], mrgconf))) == 0:
+                if mrgfail or len(subprocess_getoutput(DIFF_CONTENTS % (conf['new'], mrgconf))) == 0:
                     os.unlink(mrgconf)
                     newconf = conf['new']
                 else:
@@ -146,13 +152,13 @@ class dispatch:
             if newconf == mrgconf and \
                 self.options.get('ignore-previously-merged') != 'yes' and \
                 os.path.exists(archive+'.dist') and \
-                len(commands.getoutput(DIFF_CONTENTS % (archive+'.dist', conf['new']))) == 0:
+                len(subprocess_getoutput(DIFF_CONTENTS % (archive+'.dist', conf['new']))) == 0:
                 # The current update is identical to the archived .dist
                 # version that has previously been merged.
                 os.unlink(mrgconf)
                 newconf = conf['new']
 
-            mystatus, myoutput = commands.getstatusoutput(
+            mystatus, myoutput = subprocess_getstatusoutput(
                 DIFF_CONTENTS  % (conf ['current'], newconf))
             same_file = 0 == len(myoutput)
             if mystatus >> 8 == 2:
@@ -160,9 +166,9 @@ class dispatch:
                 same_cvs = False
                 same_wsc = False
             else:
-                same_cvs = 0 == len(commands.getoutput(
+                same_cvs = 0 == len(subprocess_getoutput(
                     DIFF_CVS_INTERP % (conf ['current'], newconf)))
-                same_wsc = 0 == len(commands.getoutput(
+                same_wsc = 0 == len(subprocess_getoutput(
                     DIFF_WSCOMMENTS % (conf ['current'], newconf)))
 
             # Do options permit?
index 6516a1d91248914180c568406ba34d703735ae7d..e9c28f9e6371880f39ae1381c3ae33af4120475f 100755 (executable)
@@ -268,7 +268,7 @@ if mode == "test":
 # mail mode as requested by solar
 if mode == "mail":
        import portage.mail, socket
-       from StringIO import StringIO
+       from io import StringIO
        from email.mime.text import MIMEText
        
        # color doesn't make any sense for mail
index c849a22f7a9156fb1f5783689c0cb3394a8a9d3d..613e1ec140ef6791da17e8989e83bc2f56874e6c 100755 (executable)
 from __future__ import print_function
 
 import codecs
-import commands
+try:
+       from subprocess import getstatusoutput as subprocess_getstatusoutput
+except ImportError:
+       from commands import getstatusoutput as subprocess_getstatusoutput
 import errno
 import formatter
 import logging
@@ -23,14 +26,10 @@ import tempfile
 import time
 import platform
 
+from io import StringIO
 from itertools import chain, izip
 from stat import S_ISDIR, ST_CTIME
 
-try:
-       from cStringIO import StringIO
-except ImportError:
-       from StringIO import StringIO
-
 if not hasattr(__builtins__, "set"):
        from sets import Set as set
 
@@ -1136,7 +1135,7 @@ for x in scanlist:
                                        (checkdir, y, m.group(0)))
 
                        if desktop_file_validate and desktop_pattern.match(y):
-                               status, cmd_output = commands.getstatusoutput(
+                               status, cmd_output = subprocess_getstatusoutput(
                                        "'%s' '%s'" % (desktop_file_validate, full_path))
                                if os.WIFEXITED(status) and os.WEXITSTATUS(status) != os.EX_OK:
                                        # Note: in the future we may want to grab the
@@ -1186,7 +1185,7 @@ for x in scanlist:
                if xmllint_capable and not metadata_bad:
                        # xmlint can produce garbage output even on success, so only dump
                        # the ouput when it fails.
-                       st, out = commands.getstatusoutput(
+                       st, out = subprocess_getstatusoutput(
                                "xmllint --nonet --noout --dtdvalid '%s' '%s'" % \
                                 (metadata_dtd, os.path.join(checkdir, "metadata.xml")))
                        if st != os.EX_OK:
@@ -1983,7 +1982,7 @@ else:
                        if myfile not in expansion:
                                continue
 
-               myout = commands.getstatusoutput("egrep -q "+headerstring+" "+myfile)
+               myout = subprocess_getstatusoutput("egrep -q "+headerstring+" "+myfile)
                if myout[0] == 0:
                        myheaders.append(myfile)
 
index e72799a1de179a42bbfcd4961f692bfcad6a3265..1f244cb1aa7421c295fda0d0129002bf9e86ebe1 100644 (file)
@@ -3,7 +3,10 @@
 # $Id$
 
 from _emerge.SpawnProcess import SpawnProcess
-import urlparse
+try:
+       from urllib.parse import urlparse as urllib_parse_urlparse
+except ImportError:
+       from urlparse import urlparse as urllib_parse_urlparse
 import sys
 import portage
 from portage import os
@@ -61,7 +64,7 @@ class BinpkgFetcher(SpawnProcess):
                        self.wait()
                        return
 
-               protocol = urlparse.urlparse(uri)[0]
+               protocol = urllib_parse_urlparse(uri)[0]
                fcmd_prefix = "FETCHCOMMAND"
                if resume:
                        fcmd_prefix = "RESUMECOMMAND"
index 98724e8a7bb5dcd1a87ea5302fbb6df9bcf87ee5..dd72a29714f58570cef0069a38d9ab7b731c64cb 100644 (file)
@@ -5,11 +5,7 @@
 import formatter
 import sys
 import time
-
-try:
-       from cStringIO import StringIO
-except ImportError:
-       from StringIO import StringIO
+from io import StringIO
 
 import portage
 from portage import os
index 08f11836eebdd3fd4d82a0996c4b9fa7b3437a1b..fda9f3d81f0a599892af60e1028e99810165e5c9 100644 (file)
@@ -2,7 +2,10 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-import commands
+try:
+       from subprocess import getstatusoutput as subprocess_getstatusoutput
+except ImportError:
+       from commands import getstatusoutput as subprocess_getstatusoutput
 import errno
 import logging
 import platform
@@ -1240,7 +1243,7 @@ def action_info(settings, trees, myopts, myfiles):
        else:
                print("Unknown")
 
-       output=commands.getstatusoutput("distcc --version")
+       output=subprocess_getstatusoutput("distcc --version")
        if not output[0]:
                print(str(output[1].split("\n",1)[0]), end=' ')
                if "distcc" in settings.features:
@@ -1248,7 +1251,7 @@ def action_info(settings, trees, myopts, myfiles):
                else:
                        print("[disabled]")
 
-       output=commands.getstatusoutput("ccache -V")
+       output=subprocess_getstatusoutput("ccache -V")
        if not output[0]:
                print(str(output[1].split("\n",1)[0]), end=' ')
                if "ccache" in settings.features:
@@ -2661,16 +2664,16 @@ def getgccversion(chost):
        "!!! other terminals also.\n"
        )
 
-       mystatus, myoutput = commands.getstatusoutput("gcc-config -c")
+       mystatus, myoutput = subprocess_getstatusoutput("gcc-config -c")
        if mystatus == os.EX_OK and myoutput.startswith(chost + "-"):
                return myoutput.replace(chost + "-", gcc_ver_prefix, 1)
 
-       mystatus, myoutput = commands.getstatusoutput(
+       mystatus, myoutput = subprocess_getstatusoutput(
                chost + "-" + gcc_ver_command)
        if mystatus == os.EX_OK:
                return gcc_ver_prefix + myoutput
 
-       mystatus, myoutput = commands.getstatusoutput(gcc_ver_command)
+       mystatus, myoutput = subprocess_getstatusoutput(gcc_ver_command)
        if mystatus == os.EX_OK:
                return gcc_ver_prefix + myoutput
 
index cf3a4e416f13f04f2e3e1111b4ee23aa5210d309..9503146620d9c04b7b02a3778f768a97ef1314f7 100644 (file)
@@ -7,12 +7,16 @@ import signal
 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
 from portage import _unicode_decode
 import _emerge.help
-import portage.xpak, commands, errno, re, time
+import portage.xpak, errno, re, time
 from portage.output import colorize, xtermTitle, xtermTitleReset
 from portage.output import create_color_func
 good = create_color_func("GOOD")
@@ -142,7 +146,7 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval):
                                                                        raise
                                                                del e
                                        processed_count += 1
-                                       myso=commands.getstatusoutput("LANG=C LANGUAGE=C /usr/bin/install-info --dir-file="+inforoot+"/dir "+inforoot+"/"+x)[1]
+                                       myso=subprocess_getstatusoutput("LANG=C LANGUAGE=C /usr/bin/install-info --dir-file="+inforoot+"/dir "+inforoot+"/"+x)[1]
                                        existsstr="already exists, for file `"
                                        if myso!="":
                                                if re.search(existsstr,myso):
index e6e5f5bdade95012ee6e5893ab1d3b3e21b950fc..deb7b2ff9994cceb4e88337e00625346a8a5f2ec 100644 (file)
@@ -28,7 +28,10 @@ try:
                import pickle
 
        import stat
-       import commands
+       try:
+               from subprocess import getstatusoutput as subprocess_getstatusoutput
+       except ImportError:
+               from commands import getstatusoutput as subprocess_getstatusoutput
        from time import sleep
        from random import shuffle
        from itertools import chain, izip
@@ -434,7 +437,7 @@ if platform.system() in ('FreeBSD',):
                @classmethod
                def chflags(cls, path, flags, opts=""):
                        cmd = 'chflags %s %o %s' % (opts, flags, _shell_quote(path))
-                       status, output = commands.getstatusoutput(cmd)
+                       status, output = subprocess_getstatusoutput(cmd)
                        if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK:
                                return
                        # Try to generate an ENOENT error if appropriate.
@@ -1990,7 +1993,10 @@ class config(object):
                                self._local_repo_configs = {}
                                self._local_repo_conf_path = \
                                        os.path.join(abs_user_config, 'repos.conf')
-                               from ConfigParser import SafeConfigParser, ParsingError
+                               try:
+                                       from configparser import SafeConfigParser, ParsingError
+                               except ImportError:
+                                       from ConfigParser import SafeConfigParser, ParsingError
                                repo_conf_parser = SafeConfigParser()
                                try:
                                        repo_conf_parser.readfp(
index 01637b1a6b707fa43fd89318f3ab39830ae73684..ee2e51c71d8cdbdf4e436d3222743b0b65a4f976 100644 (file)
@@ -12,7 +12,10 @@ from portage import _unicode_encode
 import errno
 import stat
 import tempfile
-import commands
+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 = {}
@@ -112,7 +115,7 @@ hashfunc_map["size"] = getsize
 
 prelink_capable = False
 if os.path.exists(PRELINK_BINARY):
-       results = commands.getstatusoutput(PRELINK_BINARY+" --version > /dev/null 2>&1")
+       results = subprocess_getstatusoutput(PRELINK_BINARY+" --version > /dev/null 2>&1")
        if (results[0] >> 8) == 0:
                prelink_capable=1
        del results
index 0ce760a923d19261c557e885eeb8a455768e7309..c30a3688a3e61c848f48fd79a4f194af3a81de2a 100644 (file)
@@ -100,7 +100,10 @@ userpriv_groups = [portage_gid]
 if secpass >= 2:
        # Get a list of group IDs for the portage user.  Do not use grp.getgrall()
        # since it is known to trigger spurious SIGPIPE problems with nss_ldap.
-       from commands import getstatusoutput
+       try:
+               from subprocess import getstatusoutput
+       except ImportError:
+               from commands import getstatusoutput
        mystatus, myoutput = getstatusoutput("id -G portage")
        if mystatus == os.EX_OK:
                for x in myoutput.split():
index e020415abebde0c52581f49714b2511e6a58631a..bc91152a66393974486b7f25ad541e79b599b592 100644 (file)
@@ -660,7 +660,10 @@ class binarytree(object):
 
                        base_url = self.settings["PORTAGE_BINHOST"]
                        from portage.const import CACHE_PATH
-                       from urlparse import urlparse
+                       try:
+                               from urllib.parse import urlparse
+                       except ImportError:
+                               from urlparse import urlparse
                        urldata = urlparse(base_url)
                        pkgindex_file = os.path.join(self.settings["ROOT"], CACHE_PATH, "binhost",
                                urldata[1] + urldata[2], "Packages")
@@ -678,13 +681,16 @@ class binarytree(object):
                                if e.errno != errno.ENOENT:
                                        raise
                        local_timestamp = pkgindex.header.get("TIMESTAMP", None)
-                       import urllib, urlparse
+                       try:
+                               from urllib.request import urlopen as urllib_request_urlopen
+                       except ImportError:
+                               from urllib import urlopen as urllib_request_urlopen
                        rmt_idx = self._new_pkgindex()
                        try:
                                # urlparse.urljoin() only works correctly with recognized
                                # protocols and requires the base url to have a trailing
                                # slash, so join manually...
-                               f = urllib.urlopen(base_url.rstrip("/") + "/Packages")
+                               f = urllib_request_urlopen(base_url.rstrip("/") + "/Packages")
                                try:
                                        rmt_idx.readHeader(f)
                                        remote_timestamp = rmt_idx.header.get("TIMESTAMP", None)
@@ -1082,7 +1088,10 @@ class binarytree(object):
                
                mydest = os.path.dirname(self.getname(pkgname))
                self._ensure_dir(mydest)
-               from urlparse import urlparse
+               try:
+                       from urllib.parse import urlparse
+               except ImportError:
+                       from urlparse import urlparse
                # urljoin doesn't work correctly with unrecognized protocols like sftp
                if self._remote_has_index:
                        rel_url = self._remotepkgs[pkgname].get("PATH")
index e18eb34fa5e53bf6a9b59504792d0d34f3720b16..971f9eb5f82200d9ee394ab93d336a854ad33c69 100644 (file)
@@ -7,7 +7,11 @@
 # Library by Wayne Davison <gentoo@blorf.net>, derived from code
 # written by Jeremy Wohl (http://igmus.org)
 
-import os, sys, commands, shutil
+import os, sys, shutil
+try:
+       from subprocess import getoutput as subprocess_getoutput
+except ImportError:
+       from commands import getoutput as subprocess_getoutput
 
 import portage
 from portage.localization import _
@@ -110,7 +114,7 @@ def file_archive(archive, curconf, newconf, mrgconf):
 
     # Archive the current config file if it isn't already saved
     if os.path.exists(archive) \
-     and len(commands.getoutput("diff -aq '%s' '%s'" % (curconf,archive))) != 0:
+     and len(subprocess_getoutput("diff -aq '%s' '%s'" % (curconf,archive))) != 0:
         suf = 1
         while suf < 9 and os.path.exists(archive + '.' + str(suf)):
             suf += 1
index adab28fabc0008886dd5393d78fb3b7d216a9fb6..c3994d26db081adee7f00bb54a6c7f5c3783f469 100644 (file)
@@ -11,13 +11,21 @@ from portage import os
 from portage import _encodings
 from portage import _unicode_encode
 
-import HTMLParser
 import sys
 import socket
 import time
 import tempfile
 import base64
-import urllib2
+
+try:
+       from html.parser import HTMLParser as html_parser_HTMLParser
+except ImportError:
+       from HTMLParser import HTMLParser as html_parser_HTMLParser
+
+try:
+       from urllib.parse import unquote as urllib_parse_unquote
+except:
+       from urllib2 import unquote as urllib_parse_unquote
 
 try:
        import cPickle as pickle
@@ -30,9 +38,18 @@ except ImportError as e:
        sys.stderr.write(colorize("BAD","!!! CANNOT IMPORT FTPLIB: ")+str(e)+"\n")
 
 try:
-       import httplib
+       try:
+               from http.client import HTTPConnection as http_client_HTTPConnection
+               from http.client import HTTPSConnection as http_client_HTTPConnection
+               from http.client import BadStatusLine as http_client_HTTPConnection
+               from http.client import ResponseNotReady as http_client_HTTPConnection
+       except ImportError:
+               from httplib import HTTPConnection as http_client_HTTPConnection
+               from httplib import HTTPSConnection as http_client_HTTPConnection
+               from httplib import BadStatusLine as http_client_HTTPConnection
+               from httplib import ResponseNotReady as http_client_HTTPConnection
 except ImportError as e:
-       sys.stderr.write(colorize("BAD","!!! CANNOT IMPORT HTTPLIB: ")+str(e)+"\n")
+       sys.stderr.write(colorize("BAD","!!! CANNOT IMPORT HTTP.CLIENT: ")+str(e)+"\n")
 
 def make_metadata_dict(data):
        myid,myglob = data
@@ -43,12 +60,12 @@ def make_metadata_dict(data):
 
        return mydict
 
-class ParseLinks(HTMLParser.HTMLParser):
+class ParseLinks(html_parser_HTMLParser):
        """Parser class that overrides HTMLParser to grab all anchors from an html
        page and provide suffix and prefix limitors"""
        def __init__(self):
                self.PL_anchors = []
-               HTMLParser.HTMLParser.__init__(self)
+               html_parser_HTMLParser.__init__(self)
 
        def get_anchors(self):
                return self.PL_anchors
@@ -77,7 +94,7 @@ class ParseLinks(HTMLParser.HTMLParser):
                        for x in attrs:
                                if x[0] == 'href':
                                        if x[1] not in self.PL_anchors:
-                                               self.PL_anchors.append(urllib2.unquote(x[1]))
+                                               self.PL_anchors.append(urllib_parse_unquote(x[1]))
 
 
 def create_conn(baseurl,conn=None):
@@ -132,9 +149,9 @@ def create_conn(baseurl,conn=None):
 
        if not conn:
                if protocol == "https":
-                       conn = httplib.HTTPSConnection(host)
+                       conn = http_client_HTTPSConnection(host)
                elif protocol == "http":
-                       conn = httplib.HTTPConnection(host)
+                       conn = http_client_HTTPConnection(host)
                elif protocol == "ftp":
                        passive = 1
                        if(host[-1] == "*"):
@@ -637,14 +654,14 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
                                                "/".join((baseurl.rstrip("/"), x.lstrip("/"))),
                                                conn, chunk_size)
                                        break
-                               except httplib.BadStatusLine:
+                               except http_client_BadStatusLine:
                                        # Sometimes this error is thrown from conn.getresponse() in
                                        # make_http_request().  The docstring for this error in
                                        # httplib.py says "Presumably, the server closed the
                                        # connection before sending a valid response".
                                        conn, protocol, address, params, headers = create_conn(
                                                baseurl)
-                               except httplib.ResponseNotReady:
+                               except http_client_ResponseNotReady:
                                        # With some http servers this error is known to be thrown
                                        # from conn.getresponse() in make_http_request() when the
                                        # remote file does not have appropriate read permissions.
index 95c3c813c13e96a755f93f1d3f763bbe7b0fc32a..1f061b23108e8d22ffab013b6e7e2e2a7faba65a 100644 (file)
@@ -4,7 +4,10 @@
 
 import codecs
 import sys
-import urllib
+try:
+       from urllib.request import urlopen as urllib_request_urlopen
+except ImportError:
+       from urllib import urlopen as urllib_request_urlopen
 import re
 import xml.dom.minidom
 
@@ -470,7 +473,7 @@ class Glsa:
                        myurl = "file://"+self.nr
                else:
                        myurl = repository + "glsa-%s.xml" % str(self.nr)
-               self.parse(urllib.urlopen(myurl))
+               self.parse(urllib_request_urlopen(myurl))
                return None
 
        def parse(self, myfile):
index 06073df71977f19d21c9f861fe6deb6b30e7aa0c..5170d70aabbd1f6f6c40e389ff5b3af2a014a119 100644 (file)
@@ -5,7 +5,10 @@
 __docformat__ = "epytext"
 
 import codecs
-import commands
+try:
+       from subprocess import getstatusoutput as subprocess_getstatusoutput
+except ImportError:
+       from commands import getstatusoutput as subprocess_getstatusoutput
 import errno
 import formatter
 import re
@@ -405,7 +408,7 @@ def get_term_size():
                        pass
        except ImportError:
                pass
-       st, out = commands.getstatusoutput('stty size')
+       st, out = subprocess_getstatusoutput('stty size')
        if st == os.EX_OK:
                out = out.split()
                if len(out) == 2:
index 6c5f850ade0919b7d8e1cdcb9b8dd4095a6f9c6c..20923ca2ebc38980902ccc530696ca47deb1427e 100644 (file)
@@ -5,8 +5,11 @@
 __all__ = ["SETPREFIX", "get_boolean", "SetConfigError",
        "SetConfig", "load_default_config"]
 
+try:
+       from configparser import SafeConfigParser, NoOptionError
+except ImportError:
+       from ConfigParser import SafeConfigParser, NoOptionError
 from portage import os
-from ConfigParser import SafeConfigParser, NoOptionError
 from portage import load_mod
 from portage.const import USER_CONFIG_PATH, GLOBAL_CONFIG_PATH
 from portage.exception import PackageSetNotFound
index 7b7c2a6f1a557f0e1084ef3b6bb8d02d0829e145..1401febaeed1cf5b8821e34de443a36757c38357 100644 (file)
@@ -12,7 +12,10 @@ __all__ = ['apply_permissions', 'apply_recursive_permissions',
        'stack_dicts', 'stack_lists', 'unique_array', 'varexpand', 'write_atomic',
        'writedict', 'writemsg', 'writemsg_level', 'writemsg_stdout']
 
-import commands
+try:
+       from subprocess import getstatusoutput as subprocess_getstatusoutput
+except ImportError:
+       from commands import getstatusoutput as subprocess_getstatusoutput
 import codecs
 import errno
 import logging
@@ -21,6 +24,7 @@ import shlex
 import stat
 import string
 import sys
+from io import StringIO
 
 import portage
 from portage import os
@@ -40,11 +44,6 @@ try:
 except ImportError:
        import pickle
 
-try:
-       from cStringIO import StringIO
-except ImportError:
-       from StringIO import StringIO
-
 noiselimit = 0
 
 def initialize_logger(level=logging.WARN):
@@ -1402,7 +1401,7 @@ def find_updated_config_files(target_root, config_protect):
                                mycommand = "find '%s' -maxdepth 1 -name '._cfg????_%s'" % \
                                                os.path.split(x.rstrip(os.path.sep))
                        mycommand += " ! -name '.*~' ! -iname '.*.bak' -print0"
-                       a = commands.getstatusoutput(mycommand)
+                       a = subprocess_getstatusoutput(mycommand)
 
                        if a[0] == 0:
                                files = a[1].split('\0')
index a65e57d51778b4ae41596e9f3cd9f7da016ebfdf..fcabd599db8a24553ceff96ff308ef551760d430 100644 (file)
@@ -19,11 +19,14 @@ __all__ = [
 ]
 
 import codecs
-import commands
 import errno
 import itertools
 import logging
 import sys
+try:
+       from subprocess import getstatusoutput as subprocess_getstatusoutput
+except ImportError:
+       from commands import getstatusoutput as subprocess_getstatusoutput
 
 from xml.dom import minidom
 from xml.dom import NotFoundErr
@@ -59,13 +62,13 @@ def detect_vcs_conflicts(options, vcs):
        if vcs == 'cvs':
                logging.info("Performing a " + output.green("cvs -n up") + \
                        " with a little magic grep to check for updates.")
-               retval = commands.getstatusoutput("cvs -n up 2>&1 | " + \
+               retval = subprocess_getstatusoutput("cvs -n up 2>&1 | " + \
                        "egrep '^[^\?] .*' | " + \
                        "egrep -v '^. .*/digest-[^/]+|^cvs server: .* -- ignored$'")
        if vcs == 'svn':
                logging.info("Performing a " + output.green("svn status -u") + \
                        " with a little magic grep to check for updates.")
-               retval = commands.getstatusoutput("svn status -u 2>&1 | " + \
+               retval = subprocess_getstatusoutput("svn status -u 2>&1 | " + \
                        "egrep -v '^.  +.*/digest-[^/]+' | " + \
                        "head -n-1")