GNUnet  0.20.0
gnunet_pyexpect.pexpect Class Reference
Inheritance diagram for gnunet_pyexpect.pexpect:
[legend]
Collaboration diagram for gnunet_pyexpect.pexpect:
[legend]

Public Member Functions

def __init__ (self)
 
def spawn (self, stdin, arglist, *pargs, **kwargs)
 
def expect (self, s, r, flags=0)
 
def read (self, s, size=-1)
 
def __init__ (self)
 
def spawn (self, stdin, arglist, *pargs, **kwargs)
 
def expect (self, s, r, flags=0)
 
def read (self, s, size=-1)
 

Data Fields

 proc
 
 stde
 
 stdo
 

Detailed Description

Definition at line 30 of file gnunet_pyexpect.py.

Constructor & Destructor Documentation

◆ __init__() [1/2]

def gnunet_pyexpect.pexpect.__init__ (   self)

Definition at line 31 of file gnunet_pyexpect.py.

31  def __init__(self):
32  super(pexpect, self).__init__()
33 

Referenced by gnunet_pyexpect.pexpect.__init__().

Here is the caller graph for this function:

◆ __init__() [2/2]

def gnunet_pyexpect.pexpect.__init__ (   self)

Definition at line 31 of file gnunet_pyexpect.py.

31  def __init__(self):
32  super(pexpect, self).__init__()
33 

References gnunet_pyexpect.pexpect.__init__().

Here is the call graph for this function:

Member Function Documentation

◆ spawn() [1/2]

def gnunet_pyexpect.pexpect.spawn (   self,
  stdin,
  arglist,
pargs,
**  kwargs 
)

Definition at line 34 of file gnunet_pyexpect.py.

34  def spawn(self, stdin, arglist, *pargs, **kwargs):
35  env = kwargs.pop('env', None)
36  if env is None:
37  env = os.environ.copy()
38  # This messes up some testcases, disable log redirection
39  env.pop('GNUNET_FORCE_LOGFILE', None)
40  self.proc = subprocess.Popen(arglist, *pargs, env=env, **kwargs)
41  if self.proc is None:
42  print("Failed to spawn a process {0}".format(arglist))
43  sys.exit(1)
44  if stdin is not None:
45  self.stdo, self.stde = self.proc.communicate(stdin)
46  else:
47  self.stdo, self.stde = self.proc.communicate()
48  return self.proc
49 

Referenced by gnunet_pyexpect.pexpect.spawn().

Here is the caller graph for this function:

◆ expect() [1/2]

def gnunet_pyexpect.pexpect.expect (   self,
  s,
  r,
  flags = 0 
)

Definition at line 50 of file gnunet_pyexpect.py.

50  def expect(self, s, r, flags=0):
51  stream = self.stdo if s == 'stdout' else self.stde
52  if isinstance(r, str):
53  if r == "EOF":
54  if len(stream) == 0:
55  return True
56  else:
57  print(
58  "Failed to find `{1}' in {0}, which is `{2}' ({3})".
59  format(s, r, stream, len(stream))
60  )
61  sys.exit(2)
62  raise ValueError(
63  "Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'"
64  .format(r)
65  )
66  m = r.search(stream, flags)
67  if not m:
68  print(
69  "Failed to find `{1}' in {0}, which is is `{2}'".format(
70  s, r.pattern, stream
71  )
72  )
73  sys.exit(2)
74  stream = stream[m.end():]
75  if s == 'stdout':
76  self.stdo = stream
77  else:
78  self.stde = stream
79  return m
80 
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...

References len, gnunet_pyexpect.pexpect.stde, and gnunet_pyexpect.pexpect.stdo.

Referenced by gnunet_pyexpect.pexpect.expect().

Here is the caller graph for this function:

◆ read() [1/2]

def gnunet_pyexpect.pexpect.read (   self,
  s,
  size = -1 
)

Definition at line 81 of file gnunet_pyexpect.py.

81  def read(self, s, size=-1):
82  stream = self.stdo if s == 'stdout' else self.stde
83  result = ""
84  if size < 0:
85  result = stream
86  new_stream = ""
87  else:
88  result = stream[0:size]
89  new_stream = stream[size:]
90  if s == 'stdout':
91  self.stdo = new_stream
92  else:
93  self.stde = new_stream
94  return result

References gnunet_pyexpect.pexpect.stde, and gnunet_pyexpect.pexpect.stdo.

Referenced by gnunet_pyexpect.pexpect.read().

Here is the caller graph for this function:

◆ spawn() [2/2]

def gnunet_pyexpect.pexpect.spawn (   self,
  stdin,
  arglist,
pargs,
**  kwargs 
)

Definition at line 34 of file gnunet_pyexpect.py.

34  def spawn(self, stdin, arglist, *pargs, **kwargs):
35  env = kwargs.pop('env', None)
36  if env is None:
37  env = os.environ.copy()
38  # This messes up some testcases, disable log redirection
39  env.pop('GNUNET_FORCE_LOGFILE', None)
40  self.proc = subprocess.Popen(arglist, *pargs, env=env, **kwargs)
41  if self.proc is None:
42  print("Failed to spawn a process {0}".format(arglist))
43  sys.exit(1)
44  if stdin is not None:
45  self.stdo, self.stde = self.proc.communicate(stdin)
46  else:
47  self.stdo, self.stde = self.proc.communicate()
48  return self.proc
49 

References ServiceList.proc, ResultContext.proc, GetAllContext.proc, ProcessResultContext.proc, ReplCtx.proc, ProcessKeysContext.proc, GNUNET_DEFRAGMENT_Context.proc, GNUNET_FRAGMENT_Context.proc, GNUNET_FS_TreeEncoder.proc, GSF_CadetRequest.proc, GNS_ResolverHandle.proc, RequestHandle.proc, GNUNET_REST_RequestHandler.proc, gnunet_pyexpect.pexpect.proc, GNUNET_NAMESTORE_QueueEntry.proc, GNUNET_NAMESTORE_ZoneIterator.proc, GNUNET_RECLAIM_AttributeIterator.proc, GNUNET_RECLAIM_CredentialIterator.proc, GNUNET_STATISTICS_WatchEntry.proc, GNUNET_STATISTICS_GetHandle.proc, GetStatsContext.proc, SharedServiceInstance.proc, GNUNET_ChildWaitHandle.proc, GNUNET_OS_CommandHandle.proc, gnunet_pyexpect.pexpect.spawn(), gnunet_pyexpect.pexpect.stde, and gnunet_pyexpect.pexpect.stdo.

Here is the call graph for this function:

◆ expect() [2/2]

def gnunet_pyexpect.pexpect.expect (   self,
  s,
  r,
  flags = 0 
)

Definition at line 50 of file gnunet_pyexpect.py.

50  def expect(self, s, r, flags=0):
51  stream = self.stdo if s == 'stdout' else self.stde
52  if isinstance(r, str):
53  if r == "EOF":
54  if len(stream) == 0:
55  return True
56  else:
57  print(
58  "Failed to find `{1}' in {0}, which is `{2}' ({3})".
59  format(s, r, stream, len(stream))
60  )
61  sys.exit(2)
62  raise ValueError(
63  "Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'"
64  .format(r)
65  )
66  m = r.search(stream.decode(), flags)
67  if not m:
68  print(
69  "Failed to find `{1}' in {0}, which is is `{2}'".format(
70  s, r.pattern, stream
71  )
72  )
73  sys.exit(2)
74  stream = stream[m.end():]
75  if s == 'stdout':
76  self.stdo = stream
77  else:
78  self.stde = stream
79  return m
80 

References gnunet_pyexpect.pexpect.expect(), len, gnunet_pyexpect.pexpect.stde, and gnunet_pyexpect.pexpect.stdo.

Here is the call graph for this function:

◆ read() [2/2]

def gnunet_pyexpect.pexpect.read (   self,
  s,
  size = -1 
)

Definition at line 81 of file gnunet_pyexpect.py.

81  def read(self, s, size=-1):
82  stream = self.stdo if s == 'stdout' else self.stde
83  result = ""
84  if size < 0:
85  result = stream
86  new_stream = ""
87  else:
88  result = stream[0:size]
89  new_stream = stream[size:]
90  if s == 'stdout':
91  self.stdo = new_stream
92  else:
93  self.stde = new_stream
94  return result

References gnunet_pyexpect.pexpect.read(), gnunet_pyexpect.pexpect.stde, and gnunet_pyexpect.pexpect.stdo.

Here is the call graph for this function:

Field Documentation

◆ proc

gnunet_pyexpect.pexpect.proc

Definition at line 40 of file gnunet_pyexpect.py.

Referenced by gnunet_pyexpect.pexpect.spawn().

◆ stde

gnunet_pyexpect.pexpect.stde

◆ stdo

gnunet_pyexpect.pexpect.stdo

The documentation for this class was generated from the following file: