diff options
author | sobomax <sobomax@FreeBSD.org> | 2009-11-21 08:40:59 +0800 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2009-11-21 08:40:59 +0800 |
commit | 1dd08ff193c4053a51838d6d7797009f5ca8eee9 (patch) | |
tree | 09966ab649629747eb34b89d78ea305c61486264 /Tools/scripts | |
parent | a4e57d42e1aded1a4cf1ba4f96f8c88d2643af38 (diff) | |
download | freebsd-ports-gnome-1dd08ff193c4053a51838d6d7797009f5ca8eee9.tar.gz freebsd-ports-gnome-1dd08ff193c4053a51838d6d7797009f5ca8eee9.tar.zst freebsd-ports-gnome-1dd08ff193c4053a51838d6d7797009f5ca8eee9.zip |
Correct depreciation warning with Python 2.6 and fix several warnings
from the pytchecker.
Diffstat (limited to 'Tools/scripts')
-rwxr-xr-x | Tools/scripts/patchtool.py | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/Tools/scripts/patchtool.py b/Tools/scripts/patchtool.py index ba35a1cea426..216f8beb4c40 100755 --- a/Tools/scripts/patchtool.py +++ b/Tools/scripts/patchtool.py @@ -20,7 +20,7 @@ # highly discouraged!!! # -import os, os.path, popen2, sys, getopt, glob, errno, types +import os, os.path, subprocess, sys, getopt, glob, errno, types # Some global variables used as constants True = 1 @@ -129,12 +129,12 @@ def querymakevar(varname, path = 'Makefile', strict = False, cache = {}): dir = os.path.dirname(path) CMDLINE = '%s %s && %s -f %s -V %s' % (Vars.CD_CMD, dir, Vars.MAKE_CMD, \ path, varname) - pipe = popen2.popen3(CMDLINE) + devnull = open('/dev/null', 'a') + pipe = subprocess.Popen(CMDLINE, shell = True, stdin = subprocess.PIPE, \ + stdout = subprocess.PIPE, stderr = devnull, close_fds = True) retval = '' - for line in pipe[0].readlines(): + for line in pipe.stdout.readlines(): retval = retval + line.strip() + ' ' - for fd in pipe: - fd.close() retval = retval[:-1] if strict == True and retval.strip() == '': raise MakeVarError(path, varname) @@ -197,11 +197,11 @@ def gendiff(path, wrksrc, outfile = ''): savedir = os.getcwd() os.chdir(wrksrc) - pipe = popen2.Popen3(cmdline, True) - outbuf = pipe.fromchild.readlines() - for stream in (pipe.fromchild, pipe.tochild): - stream.close() - exitval = os.WEXITSTATUS(pipe.wait()) + devnull = open('/dev/null', 'a') + pipe = subprocess.Popen(cmdline, shell = True, stdin = subprocess.PIPE, \ + stdout = subprocess.PIPE, stderr = devnull, close_fds = True) + outbuf = pipe.stdout.readlines() + exitval = pipe.wait() if exitval == 0: # No differences were found retval = False retmsg = 'no differencies found between original and current ' \ @@ -290,7 +290,7 @@ Usage: %s [-afi] file ... # # Simple custom exception # -class MyError: +class MyError(Exception): msg = 'error' def __init__(self, file, msg=''): @@ -353,9 +353,9 @@ class Patch: # Not reached # self.fullpath = path - file = open(path) + filedes = open(path) - for line in file.readlines(): + for line in filedes.readlines(): if self.minus3file == '': if line[:len(MINUS3_DELIM)] == MINUS3_DELIM: lineparts = line.split() @@ -374,7 +374,7 @@ class Patch: # Not reached # break - file.close() + filedes.close() if self.minus3file == '' or self.plus3file == '': raise PatchError(path) @@ -436,13 +436,13 @@ class PatchesCollection: raise IOError(errno.ENOENT, patchdir) # Not reached # - for file in glob.glob(os.path.join(patchdir, Vars.PATCH_PREFIX + '*')): + for filename in glob.glob(os.path.join(patchdir, Vars.PATCH_PREFIX + '*')): for sufx in Vars.PATCH_IGN_SUFX: - if file[-len(sufx):] == sufx: - write_msg('WARNING: patchfile "%s" ignored\n' % file) + if filename[-len(sufx):] == sufx: + write_msg('WARNING: patchfile "%s" ignored\n' % filename) break else: - self.addpatchfile(file, wrksrc) + self.addpatchfile(filename, wrksrc) def addpatchfile(self, path, wrksrc): path = os.path.abspath(path) @@ -558,7 +558,7 @@ def generate(args, automatic, force, ignoremtime): relpath = getrelpath(filepath, wrksrc) - if automatic == True: + if automatic: patchdir = querymakevar('PATCHDIR', portdir, True) if os.path.isdir(patchdir): |