30 class pexpect(object):
34 def spawn(self, stdin, arglist, *pargs, **kwargs):
35 env = kwargs.pop(
'env',
None)
37 env = os.environ.copy()
39 env.pop(
'GNUNET_FORCE_LOGFILE',
None)
40 self.
procproc = subprocess.Popen(arglist, *pargs, env=env, **kwargs)
41 if self.
procproc
is None:
42 print(
"Failed to spawn a process {0}".format(arglist))
45 self.
stdostdo, self.
stdestde = self.
procproc.communicate(stdin)
47 self.
stdostdo, self.
stdestde = self.
procproc.communicate()
51 stream = self.
stdostdo
if s ==
'stdout' else self.
stdestde
52 if isinstance(r, str):
58 "Failed to find `{1}' in {0}, which is `{2}' ({3})".
59 format(s, r, stream,
len(stream))
63 "Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'"
66 m = r.search(stream.decode(), flags)
69 "Failed to find `{1}' in {0}, which is is `{2}'".format(
74 stream = stream[m.end():]
76 self.
stdostdo = stream
78 self.
stdestde = stream
81 def read(self, s, size=-1):
82 stream = self.
stdostdo
if s ==
'stdout' else self.
stdestde
88 result = stream[0:size]
89 new_stream = stream[size:]
91 self.
stdostdo = new_stream
93 self.
stdestde = new_stream
def read(self, s, size=-1)
def expect(self, s, r, flags=0)
def spawn(self, stdin, arglist, *pargs, **kwargs)
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...