|
|
|
@ -224,7 +224,7 @@ class process(StdoutableProcess):
|
|
|
|
|
self.cacheerr = self.pipe.stderr.read()
|
|
|
|
|
except IOError:
|
|
|
|
|
self.cacheerr = b""
|
|
|
|
|
return self.cacheerr
|
|
|
|
|
return self.cacheerr.decode("UTF-8")
|
|
|
|
|
|
|
|
|
|
def readByLine(self):
|
|
|
|
|
_cacheerr = []
|
|
|
|
@ -244,7 +244,7 @@ class process(StdoutableProcess):
|
|
|
|
|
for fd in ret[0]:
|
|
|
|
|
if fd == _stdout:
|
|
|
|
|
s = self.pipe.stdout.readline()
|
|
|
|
|
yield s
|
|
|
|
|
yield s.decode("UTF-8")
|
|
|
|
|
self._cachedata.append(s)
|
|
|
|
|
if fd == _stderr:
|
|
|
|
|
s = self.pipe.stderr.readline()
|
|
|
|
@ -255,13 +255,13 @@ class process(StdoutableProcess):
|
|
|
|
|
s = self.pipe.stdout.readline()
|
|
|
|
|
if not s:
|
|
|
|
|
break
|
|
|
|
|
yield s
|
|
|
|
|
yield s.decode("UTF-8")
|
|
|
|
|
self._cachedata.append(s)
|
|
|
|
|
while True:
|
|
|
|
|
s = self.pipe.stderr.readline()
|
|
|
|
|
if not s:
|
|
|
|
|
break
|
|
|
|
|
yield s
|
|
|
|
|
yield s.decode("UTF-8")
|
|
|
|
|
_cacheerr.append(s)
|
|
|
|
|
break
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
@ -309,6 +309,10 @@ class process(StdoutableProcess):
|
|
|
|
|
"""Next string from stdout"""
|
|
|
|
|
return next(self.__iter__())
|
|
|
|
|
|
|
|
|
|
def __next__(self):
|
|
|
|
|
"""Next string from stdout"""
|
|
|
|
|
return next(self.__iter__())
|
|
|
|
|
|
|
|
|
|
def returncode(self):
|
|
|
|
|
"""Get return code"""
|
|
|
|
|
self.read()
|
|
|
|
@ -568,10 +572,10 @@ class processProgress(process):
|
|
|
|
|
def __init__(self, command, *params, **kwarg):
|
|
|
|
|
process.__init__(self, command, *params, **kwarg)
|
|
|
|
|
self.readsize = kwarg.get("readsize", 10)
|
|
|
|
|
self.delimeter = re.compile("\n")
|
|
|
|
|
self.delimeter = re.compile(b"\n")
|
|
|
|
|
self.init(**kwarg)
|
|
|
|
|
self._cachedata = []
|
|
|
|
|
self.buf = ""
|
|
|
|
|
self.buf = b""
|
|
|
|
|
|
|
|
|
|
def init(self, *args, **kwarg):
|
|
|
|
|
pass
|
|
|
|
@ -587,7 +591,7 @@ class processProgress(process):
|
|
|
|
|
return strdata
|
|
|
|
|
|
|
|
|
|
def processBuffer(self, buf):
|
|
|
|
|
return ""
|
|
|
|
|
return b""
|
|
|
|
|
|
|
|
|
|
def progress(self):
|
|
|
|
|
try:
|
|
|
|
@ -596,7 +600,7 @@ class processProgress(process):
|
|
|
|
|
yield res
|
|
|
|
|
self._open()
|
|
|
|
|
if self.cacheresult is None:
|
|
|
|
|
self.buf = ""
|
|
|
|
|
self.buf = b""
|
|
|
|
|
fd = self.pipe.stdout.fileno()
|
|
|
|
|
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
|
|
|
|
|
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
|
|
|
|
@ -1142,22 +1146,22 @@ class PercentProgress(processProgress):
|
|
|
|
|
end: конечный прогрессбар (по умолчанию)
|
|
|
|
|
atty: для получения данных создается pty
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
#TODO probably full of encoding errors, needs testing
|
|
|
|
|
def init(self, *args, **kwargs):
|
|
|
|
|
self.rePerc = re.compile("(\d+(?:\.\d+)?)%", re.S)
|
|
|
|
|
self.rePerc = re.compile(b"(\d+(?:\.\d+)?)%", re.S)
|
|
|
|
|
self.part = kwargs.get("part", 1)
|
|
|
|
|
if self.part < 1:
|
|
|
|
|
self.part = 1
|
|
|
|
|
self.add_offset = 100 / self.part
|
|
|
|
|
self.add_offset = 100 // self.part
|
|
|
|
|
self.offset = 0 + kwargs.get("startpart", 0) * self.add_offset
|
|
|
|
|
self.is_end = kwargs.get("end", True)
|
|
|
|
|
self.stderr = STDOUT
|
|
|
|
|
self.delimeter = re.compile("[%s]" % kwargs.get("delimeter", "\n\r"))
|
|
|
|
|
self.delimeter = re.compile(bytes("[%s]" % kwargs.get("delimeter", "\n\r"), encoding="UTF-8"))
|
|
|
|
|
#TODO do something with this monster?
|
|
|
|
|
self.cachedata = re.compile(kwargs.get("cachefilter",
|
|
|
|
|
self.cachedata = re.compile(bytes(kwargs.get("cachefilter",
|
|
|
|
|
"((?:\[31;01m\*|\[33;01m\*|"
|
|
|
|
|
"Bad Option|No space left|FATAL ERROR|SYNTAX:|mkisofs:|"
|
|
|
|
|
"error:|warning:|fatal:).*)"))
|
|
|
|
|
"error:|warning:|fatal:).*)"), encoding="UTF-8"))
|
|
|
|
|
self.atty = kwargs.get("atty", False)
|
|
|
|
|
self.alldata = ""
|
|
|
|
|
|
|
|
|
@ -1773,11 +1777,11 @@ class xattr():
|
|
|
|
|
if p.success():
|
|
|
|
|
return p.read()
|
|
|
|
|
err = p.readerr()
|
|
|
|
|
raise XAttrError(err.partition(b":")[2].strip())
|
|
|
|
|
raise XAttrError(err.partition(":")[2].strip())
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def set(cls, dn, attrname, value):
|
|
|
|
|
p = process(cls.setfattr, "-n", attrname, "-v", value, dn)
|
|
|
|
|
if not p.success():
|
|
|
|
|
err = p.readerr()
|
|
|
|
|
raise XAttrError(err.rpartition(b":")[2].strip())
|
|
|
|
|
raise XAttrError(err.rpartition(":")[2].strip())
|
|
|
|
|