2009-04-26 03:13:08 +04:00
|
|
|
# windows.py - Windows utility function implementations for Mercurial
|
|
|
|
#
|
|
|
|
# Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
2010-01-20 07:20:08 +03:00
|
|
|
# GNU General Public License version 2 or any later version.
|
2009-03-26 21:54:44 +03:00
|
|
|
|
2009-03-27 07:02:21 +03:00
|
|
|
from i18n import _
|
2012-05-27 13:29:52 +04:00
|
|
|
import osutil, encoding
|
2012-12-01 03:55:07 +04:00
|
|
|
import errno, msvcrt, os, re, stat, sys, _winreg
|
2009-03-26 21:54:44 +03:00
|
|
|
|
2011-08-04 01:41:14 +04:00
|
|
|
import win32
|
|
|
|
executablepath = win32.executablepath
|
|
|
|
getuser = win32.getuser
|
|
|
|
hidewindow = win32.hidewindow
|
|
|
|
makedir = win32.makedir
|
|
|
|
nlinks = win32.nlinks
|
|
|
|
oslink = win32.oslink
|
|
|
|
samedevice = win32.samedevice
|
|
|
|
samefile = win32.samefile
|
|
|
|
setsignalhandler = win32.setsignalhandler
|
|
|
|
spawndetached = win32.spawndetached
|
2012-09-14 23:08:17 +04:00
|
|
|
split = os.path.split
|
2011-08-04 01:41:14 +04:00
|
|
|
termwidth = win32.termwidth
|
|
|
|
testpid = win32.testpid
|
|
|
|
unlink = win32.unlink
|
2011-07-29 02:39:27 +04:00
|
|
|
|
2011-11-07 06:14:54 +04:00
|
|
|
umask = 0022
|
2015-01-31 20:39:44 +03:00
|
|
|
_SEEK_END = 2 # os.SEEK_END was introduced in Python 2.5
|
2009-03-26 21:54:44 +03:00
|
|
|
|
2009-05-13 23:36:16 +04:00
|
|
|
def posixfile(name, mode='r', buffering=-1):
|
2015-02-07 01:40:46 +03:00
|
|
|
'''Open a file with even more POSIX-like semantics'''
|
2009-05-13 23:36:16 +04:00
|
|
|
try:
|
2015-02-07 01:40:46 +03:00
|
|
|
fp = osutil.posixfile(name, mode, buffering) # may raise WindowsError
|
2015-01-31 20:39:44 +03:00
|
|
|
|
|
|
|
# The position when opening in append mode is implementation defined, so
|
|
|
|
# make it consistent with other platforms, which position at EOF.
|
|
|
|
if 'a' in mode:
|
|
|
|
fp.seek(0, _SEEK_END)
|
|
|
|
|
|
|
|
return fp
|
2009-05-13 23:36:16 +04:00
|
|
|
except WindowsError, err:
|
2015-02-07 01:40:46 +03:00
|
|
|
# convert to a friendlier exception
|
2009-09-15 04:53:43 +04:00
|
|
|
raise IOError(err.errno, '%s: %s' % (name, err.strerror))
|
2009-05-13 23:36:16 +04:00
|
|
|
|
2009-06-10 17:10:21 +04:00
|
|
|
class winstdout(object):
|
2009-03-26 21:54:44 +03:00
|
|
|
'''stdout on windows misbehaves if sent through a pipe'''
|
|
|
|
|
|
|
|
def __init__(self, fp):
|
|
|
|
self.fp = fp
|
|
|
|
|
|
|
|
def __getattr__(self, key):
|
|
|
|
return getattr(self.fp, key)
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
try:
|
|
|
|
self.fp.close()
|
2011-04-23 01:51:25 +04:00
|
|
|
except IOError:
|
|
|
|
pass
|
2009-03-26 21:54:44 +03:00
|
|
|
|
|
|
|
def write(self, s):
|
|
|
|
try:
|
|
|
|
# This is workaround for "Not enough space" error on
|
|
|
|
# writing large size of data to console.
|
|
|
|
limit = 16000
|
|
|
|
l = len(s)
|
|
|
|
start = 0
|
2010-02-08 17:36:34 +03:00
|
|
|
self.softspace = 0
|
2009-03-26 21:54:44 +03:00
|
|
|
while start < l:
|
|
|
|
end = start + limit
|
|
|
|
self.fp.write(s[start:end])
|
|
|
|
start = end
|
|
|
|
except IOError, inst:
|
2010-01-25 09:05:27 +03:00
|
|
|
if inst.errno != 0:
|
|
|
|
raise
|
2009-03-26 21:54:44 +03:00
|
|
|
self.close()
|
|
|
|
raise IOError(errno.EPIPE, 'Broken pipe')
|
|
|
|
|
|
|
|
def flush(self):
|
|
|
|
try:
|
|
|
|
return self.fp.flush()
|
|
|
|
except IOError, inst:
|
2010-01-25 09:05:27 +03:00
|
|
|
if inst.errno != errno.EINVAL:
|
|
|
|
raise
|
2009-03-26 21:54:44 +03:00
|
|
|
self.close()
|
|
|
|
raise IOError(errno.EPIPE, 'Broken pipe')
|
|
|
|
|
2011-07-16 16:24:28 +04:00
|
|
|
sys.__stdout__ = sys.stdout = winstdout(sys.stdout)
|
2009-03-26 21:54:44 +03:00
|
|
|
|
|
|
|
def _is_win_9x():
|
|
|
|
'''return true if run on windows 95, 98 or me.'''
|
|
|
|
try:
|
|
|
|
return sys.getwindowsversion()[3] == 1
|
|
|
|
except AttributeError:
|
|
|
|
return 'command' in os.environ.get('comspec', '')
|
|
|
|
|
|
|
|
def openhardlinks():
|
2011-02-14 13:12:26 +03:00
|
|
|
return not _is_win_9x()
|
2009-03-26 21:54:44 +03:00
|
|
|
|
2011-05-06 17:19:48 +04:00
|
|
|
def parsepatchoutput(output_line):
|
2009-06-09 17:25:17 +04:00
|
|
|
"""parses the output produced by patch and returns the filename"""
|
2009-03-26 21:54:44 +03:00
|
|
|
pf = output_line[14:]
|
|
|
|
if pf[0] == '`':
|
|
|
|
pf = pf[1:-1] # Remove the quotes
|
|
|
|
return pf
|
|
|
|
|
|
|
|
def sshargs(sshcmd, host, user, port):
|
|
|
|
'''Build argument list for ssh or Plink'''
|
|
|
|
pflag = 'plink' in sshcmd.lower() and '-P' or '-p'
|
|
|
|
args = user and ("%s@%s" % (user, host)) or host
|
|
|
|
return port and ("%s %s %s" % (args, pflag, port)) or args
|
|
|
|
|
2011-05-06 17:22:31 +04:00
|
|
|
def setflags(f, l, x):
|
2009-03-26 21:54:44 +03:00
|
|
|
pass
|
|
|
|
|
2011-08-02 15:18:56 +04:00
|
|
|
def copymode(src, dst, mode=None):
|
|
|
|
pass
|
|
|
|
|
2011-04-04 13:41:54 +04:00
|
|
|
def checkexec(path):
|
|
|
|
return False
|
|
|
|
|
2011-04-05 13:55:52 +04:00
|
|
|
def checklink(path):
|
|
|
|
return False
|
|
|
|
|
2011-05-06 17:25:35 +04:00
|
|
|
def setbinary(fd):
|
2009-03-26 21:54:44 +03:00
|
|
|
# When run without console, pipes may expose invalid
|
|
|
|
# fileno(), usually set to -1.
|
2011-07-26 01:04:44 +04:00
|
|
|
fno = getattr(fd, 'fileno', None)
|
|
|
|
if fno is not None and fno() >= 0:
|
|
|
|
msvcrt.setmode(fno(), os.O_BINARY)
|
2009-03-26 21:54:44 +03:00
|
|
|
|
|
|
|
def pconvert(path):
|
2012-02-05 17:58:31 +04:00
|
|
|
return path.replace(os.sep, '/')
|
2009-03-26 21:54:44 +03:00
|
|
|
|
|
|
|
def localpath(path):
|
|
|
|
return path.replace('/', '\\')
|
|
|
|
|
|
|
|
def normpath(path):
|
|
|
|
return pconvert(os.path.normpath(path))
|
|
|
|
|
2011-12-16 16:09:40 +04:00
|
|
|
def normcase(path):
|
2015-05-14 12:37:36 +03:00
|
|
|
return encoding.upper(path) # NTFS compares via upper()
|
2011-11-16 00:25:11 +04:00
|
|
|
|
2015-04-01 10:31:41 +03:00
|
|
|
# see posix.py for definitions
|
|
|
|
normcasespec = encoding.normcasespecs.upper
|
|
|
|
normcasefallback = encoding.upperfallback
|
|
|
|
|
2009-03-26 21:54:44 +03:00
|
|
|
def samestat(s1, s2):
|
|
|
|
return False
|
|
|
|
|
|
|
|
# A sequence of backslashes is special iff it precedes a double quote:
|
|
|
|
# - if there's an even number of backslashes, the double quote is not
|
|
|
|
# quoted (i.e. it ends the quoted region)
|
|
|
|
# - if there's an odd number of backslashes, the double quote is quoted
|
|
|
|
# - in both cases, every pair of backslashes is unquoted into a single
|
|
|
|
# backslash
|
|
|
|
# (See http://msdn2.microsoft.com/en-us/library/a1y7w461.aspx )
|
|
|
|
# So, to quote a string, we must surround it in double quotes, double
|
2012-08-16 00:38:42 +04:00
|
|
|
# the number of backslashes that precede double quotes and add another
|
2009-03-26 21:54:44 +03:00
|
|
|
# backslash before every double quote (being careful with the double
|
|
|
|
# quote we've appended to the end)
|
|
|
|
_quotere = None
|
2014-12-25 17:33:26 +03:00
|
|
|
_needsshellquote = None
|
2009-03-26 21:54:44 +03:00
|
|
|
def shellquote(s):
|
2015-05-02 03:17:00 +03:00
|
|
|
r"""
|
|
|
|
>>> shellquote(r'C:\Users\xyz')
|
|
|
|
'"C:\\Users\\xyz"'
|
|
|
|
>>> shellquote(r'C:\Users\xyz/mixed')
|
|
|
|
'"C:\\Users\\xyz/mixed"'
|
|
|
|
>>> # Would be safe not to quote too, since it is all double backslashes
|
|
|
|
>>> shellquote(r'C:\\Users\\xyz')
|
|
|
|
'"C:\\\\Users\\\\xyz"'
|
|
|
|
>>> # But this must be quoted
|
|
|
|
>>> shellquote(r'C:\\Users\\xyz/abc')
|
|
|
|
'"C:\\\\Users\\\\xyz/abc"'
|
|
|
|
"""
|
2009-03-26 21:54:44 +03:00
|
|
|
global _quotere
|
|
|
|
if _quotere is None:
|
|
|
|
_quotere = re.compile(r'(\\*)("|\\$)')
|
2014-12-25 17:33:26 +03:00
|
|
|
global _needsshellquote
|
|
|
|
if _needsshellquote is None:
|
2015-04-30 04:14:59 +03:00
|
|
|
# ":" is also treated as "safe character", because it is used as a part
|
|
|
|
# of path name on Windows. "\" is also part of a path name, but isn't
|
|
|
|
# safe because shlex.split() (kind of) treats it as an escape char and
|
|
|
|
# drops it. It will leave the next character, even if it is another
|
|
|
|
# "\".
|
|
|
|
_needsshellquote = re.compile(r'[^a-zA-Z0-9._:/-]').search
|
2015-02-11 13:57:07 +03:00
|
|
|
if s and not _needsshellquote(s) and not _quotere.search(s):
|
2014-12-25 17:33:26 +03:00
|
|
|
# "s" shouldn't have to be quoted
|
|
|
|
return s
|
2009-03-26 21:54:44 +03:00
|
|
|
return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
|
|
|
|
|
|
|
|
def quotecommand(cmd):
|
|
|
|
"""Build a command string suitable for os.popen* calls."""
|
2010-12-22 22:25:00 +03:00
|
|
|
if sys.version_info < (2, 7, 1):
|
|
|
|
# Python versions since 2.7.1 do this extra quoting themselves
|
|
|
|
return '"' + cmd + '"'
|
|
|
|
return cmd
|
2009-03-26 21:54:44 +03:00
|
|
|
|
|
|
|
def popen(command, mode='r'):
|
|
|
|
# Work around "popen spawned process may not write to stdout
|
|
|
|
# under windows"
|
|
|
|
# http://bugs.python.org/issue1366
|
2012-08-04 09:14:40 +04:00
|
|
|
command += " 2> %s" % os.devnull
|
2009-03-26 21:54:44 +03:00
|
|
|
return os.popen(quotecommand(command), mode)
|
|
|
|
|
2011-05-06 17:31:09 +04:00
|
|
|
def explainexit(code):
|
2009-03-26 21:54:44 +03:00
|
|
|
return _("exited with status %d") % code, code
|
|
|
|
|
|
|
|
# if you change this stub into a real check, please try to implement the
|
|
|
|
# username and groupname functions above, too.
|
2009-05-31 01:42:35 +04:00
|
|
|
def isowner(st):
|
2009-03-26 21:54:44 +03:00
|
|
|
return True
|
|
|
|
|
2011-05-08 22:35:46 +04:00
|
|
|
def findexe(command):
|
2009-03-26 21:54:44 +03:00
|
|
|
'''Find executable for command searching like cmd.exe does.
|
|
|
|
If command is a basename then PATH is searched for command.
|
|
|
|
PATH isn't searched if command is an absolute or relative path.
|
|
|
|
An extension from PATHEXT is found and added if not present.
|
|
|
|
If command isn't found None is returned.'''
|
|
|
|
pathext = os.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD')
|
|
|
|
pathexts = [ext for ext in pathext.lower().split(os.pathsep)]
|
|
|
|
if os.path.splitext(command)[1].lower() in pathexts:
|
|
|
|
pathexts = ['']
|
|
|
|
|
|
|
|
def findexisting(pathcommand):
|
|
|
|
'Will append extension (if needed) and return existing file'
|
|
|
|
for ext in pathexts:
|
|
|
|
executable = pathcommand + ext
|
|
|
|
if os.path.exists(executable):
|
|
|
|
return executable
|
|
|
|
return None
|
|
|
|
|
|
|
|
if os.sep in command:
|
|
|
|
return findexisting(command)
|
|
|
|
|
|
|
|
for path in os.environ.get('PATH', '').split(os.pathsep):
|
|
|
|
executable = findexisting(os.path.join(path, command))
|
|
|
|
if executable is not None:
|
|
|
|
return executable
|
2009-12-30 08:59:41 +03:00
|
|
|
return findexisting(os.path.expanduser(os.path.expandvars(command)))
|
2009-03-26 21:54:44 +03:00
|
|
|
|
2012-12-01 03:55:07 +04:00
|
|
|
_wantedkinds = set([stat.S_IFREG, stat.S_IFLNK])
|
|
|
|
|
2009-03-26 21:54:44 +03:00
|
|
|
def statfiles(files):
|
2012-12-01 03:55:07 +04:00
|
|
|
'''Stat each file in files. Yield each stat, or None if a file
|
|
|
|
does not exist or has a type we don't care about.
|
|
|
|
|
2009-03-26 21:54:44 +03:00
|
|
|
Cluster and cache stat per directory to minimize number of OS stat calls.'''
|
|
|
|
dircache = {} # dirname -> filename -> status | None if file does not exist
|
2012-12-01 03:55:07 +04:00
|
|
|
getkind = stat.S_IFMT
|
2009-03-26 21:54:44 +03:00
|
|
|
for nf in files:
|
2011-12-12 12:10:19 +04:00
|
|
|
nf = normcase(nf)
|
2009-07-09 16:39:19 +04:00
|
|
|
dir, base = os.path.split(nf)
|
|
|
|
if not dir:
|
|
|
|
dir = '.'
|
2009-03-26 21:54:44 +03:00
|
|
|
cache = dircache.get(dir, None)
|
|
|
|
if cache is None:
|
|
|
|
try:
|
2011-12-12 12:10:19 +04:00
|
|
|
dmap = dict([(normcase(n), s)
|
2012-12-01 03:55:07 +04:00
|
|
|
for n, k, s in osutil.listdir(dir, True)
|
2012-12-07 02:56:44 +04:00
|
|
|
if getkind(s.st_mode) in _wantedkinds])
|
2009-03-26 21:54:44 +03:00
|
|
|
except OSError, err:
|
|
|
|
# handle directory not found in Python version prior to 2.5
|
|
|
|
# Python <= 2.4 returns native Windows code 3 in errno
|
|
|
|
# Python >= 2.5 returns ENOENT and adds winerror field
|
|
|
|
# EINVAL is raised if dir is not a directory.
|
|
|
|
if err.errno not in (3, errno.ENOENT, errno.EINVAL,
|
|
|
|
errno.ENOTDIR):
|
|
|
|
raise
|
|
|
|
dmap = {}
|
|
|
|
cache = dircache.setdefault(dir, dmap)
|
|
|
|
yield cache.get(base, None)
|
|
|
|
|
|
|
|
def username(uid=None):
|
|
|
|
"""Return the name of the user with the given uid.
|
|
|
|
|
|
|
|
If uid is None, return the name of the current user."""
|
|
|
|
return None
|
|
|
|
|
|
|
|
def groupname(gid=None):
|
|
|
|
"""Return the name of the group with the given gid.
|
|
|
|
|
|
|
|
If gid is None, return the name of the current group."""
|
|
|
|
return None
|
|
|
|
|
2015-04-10 18:47:09 +03:00
|
|
|
def removedirs(name):
|
2009-05-12 17:50:44 +04:00
|
|
|
"""special version of os.removedirs that does not remove symlinked
|
|
|
|
directories or junction points if they actually contain files"""
|
|
|
|
if osutil.listdir(name):
|
|
|
|
return
|
|
|
|
os.rmdir(name)
|
|
|
|
head, tail = os.path.split(name)
|
|
|
|
if not tail:
|
|
|
|
head, tail = os.path.split(head)
|
|
|
|
while head and tail:
|
|
|
|
try:
|
2009-10-09 01:32:36 +04:00
|
|
|
if osutil.listdir(head):
|
2009-05-12 17:50:44 +04:00
|
|
|
return
|
|
|
|
os.rmdir(head)
|
2011-04-23 01:51:25 +04:00
|
|
|
except (ValueError, OSError):
|
2009-05-12 17:50:44 +04:00
|
|
|
break
|
|
|
|
head, tail = os.path.split(head)
|
|
|
|
|
2012-12-28 14:55:57 +04:00
|
|
|
def unlinkpath(f, ignoremissing=False):
|
2009-05-12 17:50:44 +04:00
|
|
|
"""unlink and remove the directory if it is empty"""
|
2012-12-28 14:55:57 +04:00
|
|
|
try:
|
|
|
|
unlink(f)
|
|
|
|
except OSError, e:
|
|
|
|
if not (ignoremissing and e.errno == errno.ENOENT):
|
|
|
|
raise
|
2009-05-12 17:50:44 +04:00
|
|
|
# try removing directories that might now be empty
|
|
|
|
try:
|
2015-04-10 18:47:09 +03:00
|
|
|
removedirs(os.path.dirname(f))
|
2009-05-12 17:50:44 +04:00
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
|
2009-10-07 22:32:07 +04:00
|
|
|
def rename(src, dst):
|
|
|
|
'''atomically rename file src to dst, replacing dst if it exists'''
|
|
|
|
try:
|
|
|
|
os.rename(src, dst)
|
2011-01-11 16:10:16 +03:00
|
|
|
except OSError, e:
|
|
|
|
if e.errno != errno.EEXIST:
|
|
|
|
raise
|
2011-01-11 16:10:16 +03:00
|
|
|
unlink(dst)
|
2009-10-07 22:32:07 +04:00
|
|
|
os.rename(src, dst)
|
|
|
|
|
2010-01-06 23:11:58 +03:00
|
|
|
def gethgcmd():
|
|
|
|
return [sys.executable] + sys.argv[:1]
|
|
|
|
|
2010-05-10 23:09:48 +04:00
|
|
|
def groupmembers(name):
|
|
|
|
# Don't support groups on Windows for now
|
2012-05-12 18:00:58 +04:00
|
|
|
raise KeyError
|
2010-05-10 23:09:48 +04:00
|
|
|
|
2011-07-23 14:29:52 +04:00
|
|
|
def isexec(f):
|
|
|
|
return False
|
|
|
|
|
2011-07-25 16:03:02 +04:00
|
|
|
class cachestat(object):
|
|
|
|
def __init__(self, path):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def cacheable(self):
|
|
|
|
return False
|
|
|
|
|
2012-05-27 13:29:52 +04:00
|
|
|
def lookupreg(key, valname=None, scope=None):
|
|
|
|
''' Look up a key/value name in the Windows registry.
|
|
|
|
|
|
|
|
valname: value name. If unspecified, the default value for the key
|
|
|
|
is used.
|
|
|
|
scope: optionally specify scope for registry lookup, this can be
|
|
|
|
a sequence of scopes to look up in order. Default (CURRENT_USER,
|
|
|
|
LOCAL_MACHINE).
|
|
|
|
'''
|
|
|
|
if scope is None:
|
|
|
|
scope = (_winreg.HKEY_CURRENT_USER, _winreg.HKEY_LOCAL_MACHINE)
|
|
|
|
elif not isinstance(scope, (list, tuple)):
|
|
|
|
scope = (scope,)
|
|
|
|
for s in scope:
|
|
|
|
try:
|
|
|
|
val = _winreg.QueryValueEx(_winreg.OpenKey(s, key), valname)[0]
|
|
|
|
# never let a Unicode string escape into the wild
|
|
|
|
return encoding.tolocal(val.encode('UTF-8'))
|
|
|
|
except EnvironmentError:
|
|
|
|
pass
|
|
|
|
|
2009-05-25 01:38:29 +04:00
|
|
|
expandglobs = True
|
2013-04-03 22:35:27 +04:00
|
|
|
|
|
|
|
def statislink(st):
|
|
|
|
'''check whether a stat result is a symlink'''
|
|
|
|
return False
|
|
|
|
|
|
|
|
def statisexec(st):
|
|
|
|
'''check whether a stat result is an executable file'''
|
|
|
|
return False
|
2014-08-16 07:02:18 +04:00
|
|
|
|
|
|
|
def readpipe(pipe):
|
|
|
|
"""Read all available data from a pipe."""
|
|
|
|
chunks = []
|
|
|
|
while True:
|
windows: allow readpipe() to actually read data out of the pipe
It appears that the read() in readpipe() never actually ran before (in
test-ssh.t anyway). A print of the size returned from os.fstat() is 0 for every
single print output in test-ssh.t, so the data in the pipe ends up being read
later instead of when it is available. This is the same problem as Linux, as
mentioned in e20a5309b88d.
There are several places in the Windows SSH tests where the order of local
output vs remote output differ from the other platforms. This only fixes one of
those cases (and interstingly, not the one added in order to test e20a5309b88d),
so there is more investigation needed. However, without this patch, test-ssh.t
also has this diff:
--- c:/Users/Matt/Projects/hg/tests/test-ssh.t
+++ c:/Users/Matt/Projects/hg/tests/test-ssh.t.err
@@ -397,11 +397,11 @@
$ hg push --ssh "sh ../ssh.sh"
pushing to ssh://user@dummy/*/remote (glob)
searching for changes
- remote: Permission denied
- remote: abort: prechangegroup.hg-ssh hook failed
- remote: Permission denied
- remote: pushkey-abort: prepushkey.hg-ssh hook failed
updating 6c0482d977a3 to public failed!
+ remote: Permission denied
+ remote: abort: prechangegroup.hg-ssh hook failed
+ remote: Permission denied
+ remote: pushkey-abort: prepushkey.hg-ssh hook failed
[1]
$ cd ..
Output with this change was stable over 600+ runs of test-ssh.t. I initially
tried a background thread to read the pipe[1], but this was simpler and the test
results were exactly the same. I also tried SetNamedPipeHandleState(), but the
PIPE_NOWAIT is for compatibility with LANMAN 2.0, not for async I/O (the results
were identical though).
[1] http://eyalarubas.com/python-subproc-nonblock.html
2015-04-08 05:31:36 +03:00
|
|
|
size = win32.peekpipe(pipe)
|
2014-08-16 07:02:18 +04:00
|
|
|
if not size:
|
|
|
|
break
|
|
|
|
|
|
|
|
s = pipe.read(size)
|
|
|
|
if not s:
|
|
|
|
break
|
|
|
|
chunks.append(s)
|
|
|
|
|
|
|
|
return ''.join(chunks)
|