From 8243a08d6d2121e4c1e92201c9d4361df42e5d8f Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sun, 20 Sep 2009 16:22:08 +0000 Subject: Update system imports for compatibility with Python 3. svn path=/main/trunk/; revision=14294 --- bin/dispatch-conf | 20 +++++++++++++------- bin/glsa-check | 2 +- bin/repoman | 17 ++++++++--------- 3 files changed, 22 insertions(+), 17 deletions(-) (limited to 'bin') diff --git a/bin/dispatch-conf b/bin/dispatch-conf index 38359c5b3..5247cdb60 100755 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@ -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? diff --git a/bin/glsa-check b/bin/glsa-check index 6516a1d91..e9c28f9e6 100755 --- a/bin/glsa-check +++ b/bin/glsa-check @@ -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 diff --git a/bin/repoman b/bin/repoman index c849a22f7..613e1ec14 100755 --- a/bin/repoman +++ b/bin/repoman @@ -10,7 +10,10 @@ 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) -- cgit v1.2.3-1-g7c22