From cef116c9f2f4cb44628641237efe24b12cbee657 Mon Sep 17 00:00:00 2001 From: asamoukin Date: Thu, 20 Aug 2009 07:18:39 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D0=BE=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=B8?= =?UTF-8?q?=D0=BC=D0=BE=D1=81=D1=82=D1=8C=20=D1=81=20python=202.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.calculate.ru/calculate2/calculate-lib/trunk@2507 c91db197-33c1-4113-bf15-f8a5c547ca64 --- pym/cl_profile.py | 7 +++++-- pym/cl_utils.py | 13 ++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pym/cl_profile.py b/pym/cl_profile.py index c75613e..8d999c6 100644 --- a/pym/cl_profile.py +++ b/pym/cl_profile.py @@ -21,7 +21,7 @@ import stat import re import xml.dom.minidom from xml import xpath -import popen2 +import subprocess import types import copy import random @@ -1854,7 +1854,10 @@ class _file(_error): nameFile = self.nameFileNew if profile=="Old" and self.nameFileOld: nameFile = self.nameFileOld - fout, fin = popen2.popen2("file %s"%(nameFile)) + sp = subprocess.Popen("file '%s'"%nameFile, stdin=subprocess.PIPE, + stdout=subprocess.PIPE, close_fds=True, + shell=True) + fout, fin = (sp.stdout, sp.stdin) fin.close() textLine = fout.readline() fout.readlines() diff --git a/pym/cl_utils.py b/pym/cl_utils.py index 2052157..a82481b 100644 --- a/pym/cl_utils.py +++ b/pym/cl_utils.py @@ -20,7 +20,7 @@ from random import choice from re import search, compile, S import os import types -import popen2 +import subprocess def getdirlist(s_path): #Получить список директорий по указаному пути @@ -268,19 +268,26 @@ def runOsCommand(cmd, inStr=None, ret_first=None): """Выполняет внешнюю программу Параметры: - cmdStrProg внешняя программа + cmd внешняя программа inStr данные передаваемые программе на страндартный вход. ret_first вернуть только первую строку Возвращаемые параметры: строка/строки которую выведет внешняя программа """ - fout, fin = popen2.popen4(cmd) + pipe = subprocess.Popen(cmd, stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + close_fds=True, + shell=True) + fout, fin, ferr = (pipe.stdout, pipe.stdin, pipe.stderr) # если есть данные на вход, передать их if inStr: fin.write(inStr) fin.close() res = fout.readlines() fout.close() + res += ferr.readlines() + ferr.close() if res: if len(res) > 1: if ret_first: