aboutsummaryrefslogtreecommitdiff
path: root/contrib/gnunet_pyexpect.py.in
diff options
context:
space:
mode:
authorNils Gillmann <ng0@n0.is>2018-05-19 14:43:13 +0000
committerNils Gillmann <ng0@n0.is>2018-05-19 14:43:13 +0000
commit6ab60d4920bb3199aee8cd872b930e9e3e808ba7 (patch)
tree3d761dbf8793a1d2422fbd14667255c7e0292ea4 /contrib/gnunet_pyexpect.py.in
parentc2f27dfe8218545c327ab49d225a49910347c5c6 (diff)
downloadgnunet-6ab60d4920bb3199aee8cd872b930e9e3e808ba7.tar.gz
gnunet-6ab60d4920bb3199aee8cd872b930e9e3e808ba7.zip
Restructure contrib folder.
contrib/pogen.sh -> bin/pogen.sh bootstrap: Use new pogen location and execute it. contrib/openvpn-tap32: Move to contrib/3rdparty/Windows/openvpn-tap32. contrib/gnunet-logo*: Move to contrib/branding/logo/ Delete old patches in contrib, predating git. Move buildbot data to contrib/ci/buildbot, move docker data to contrib/ci/docker. Create contrib/conf and populate it with config files found in contrib and bin. Move gns related data to contrib/gns. delete contrib/repeat.sh Move contrib/log.php into contrib/web/log.php. Create folder contrib/scripts and use it for most scripts in contrib. Remove trailing whitespace in doc/Makefile.am Signed-off-by: Nils Gillmann <ng0@n0.is>
Diffstat (limited to 'contrib/gnunet_pyexpect.py.in')
-rw-r--r--contrib/gnunet_pyexpect.py.in83
1 files changed, 0 insertions, 83 deletions
diff --git a/contrib/gnunet_pyexpect.py.in b/contrib/gnunet_pyexpect.py.in
deleted file mode 100644
index cfeb06d8d..000000000
--- a/contrib/gnunet_pyexpect.py.in
+++ /dev/null
@@ -1,83 +0,0 @@
1#!@PYTHON@
2# This file is part of GNUnet.
3# (C) 2010 Christian Grothoff (and other contributing authors)
4#
5# GNUnet is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published
7# by the Free Software Foundation; either version 2, or (at your
8# option) any later version.
9#
10# GNUnet is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with GNUnet; see the file COPYING. If not, write to the
17# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18# Boston, MA 02110-1301, USA.
19#
20# Testcase for gnunet-peerinfo
21from __future__ import print_function
22import os
23import re
24import subprocess
25import sys
26import shutil
27import time
28
29class pexpect (object):
30 def __init__ (self):
31 super (pexpect, self).__init__ ()
32
33 def spawn (self, stdin, arglist, *pargs, **kwargs):
34 env = kwargs.pop ('env', None)
35 if env is None:
36 env = os.environ.copy ()
37 # This messes up some testcases, disable log redirection
38 env.pop ('GNUNET_FORCE_LOGFILE', None)
39 self.proc = subprocess.Popen (arglist, *pargs, env=env, **kwargs)
40 if self.proc is None:
41 print ("Failed to spawn a process {0}".format (arglist))
42 sys.exit (1)
43 if stdin is not None:
44 self.stdo, self.stde = self.proc.communicate (stdin)
45 else:
46 self.stdo, self.stde = self.proc.communicate ()
47 return self.proc
48
49 def expect (self, s, r, flags=0):
50 stream = self.stdo if s == 'stdout' else self.stde
51 if isinstance (r, str):
52 if r == "EOF":
53 if len (stream) == 0:
54 return True
55 else:
56 print ("Failed to find `{1}' in {0}, which is `{2}' ({3})".format (s, r, stream, len (stream)))
57 sys.exit (2)
58 raise ValueError ("Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'".format (r))
59 m = r.search (stream.decode(), flags)
60 if not m:
61 print ("Failed to find `{1}' in {0}, which is is `{2}'".format (s, r.pattern, stream))
62 sys.exit (2)
63 stream = stream[m.end ():]
64 if s == 'stdout':
65 self.stdo = stream
66 else:
67 self.stde = stream
68 return m
69
70 def read (self, s, size=-1):
71 stream = self.stdo if s == 'stdout' else self.stde
72 result = ""
73 if size < 0:
74 result = stream
75 new_stream = ""
76 else:
77 result = stream[0:size]
78 new_stream = stream[size:]
79 if s == 'stdout':
80 self.stdo = new_stream
81 else:
82 self.stde = new_stream
83 return result