endif
noinst_SCRIPTS = \
- gnunet_pyexpect/gnunet_pyexpect.py
+ gnunet_pyexpect.py
dist_pkgdata_DATA = \
gnunet-logo-color.png \
hostlist.cgi \
hostlist.php \
report.sh \
- gnunet_pyexpect/__init__.py \
- gnunet_pyexpect/gnunet_pyexpect.py.in
+ __init__.py \
+ gnunet_pyexpect.py.in
do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g'
-gnunet_pyexpect/gnunet_pyexpect.py: gnunet_pyexpect/gnunet_pyexpect.py.in Makefile
- $(do_subst) < $(srcdir)/gnunet_pyexpect/gnunet_pyexpect.py.in > gnunet_pyexpect/gnunet_pyexpect.py
- chmod +x gnunet_pyexpect/gnunet_pyexpect.py
- chmod +x gnunet_pyexpect/__init__.py
+gnunet_pyexpect.py: gnunet_pyexpect.py.in Makefile
+ $(do_subst) < $(srcdir)/gnunet_pyexpect.py.in > gnunet_pyexpect.py
+ chmod +x gnunet_pyexpect.py
+ chmod +x __init__.py
# init_gnunet_redhat \
--- /dev/null
+#!@PYTHON@\r
+# This file is part of GNUnet.\r
+# (C) 2010 Christian Grothoff (and other contributing authors)\r
+#\r
+# GNUnet is free software; you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published\r
+# by the Free Software Foundation; either version 2, or (at your\r
+# option) any later version.\r
+#\r
+# GNUnet is distributed in the hope that it will be useful, but\r
+# WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+# General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with GNUnet; see the file COPYING. If not, write to the\r
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,\r
+# Boston, MA 02111-1307, USA.\r
+#\r
+# Testcase for gnunet-peerinfo\r
+from __future__ import print_function\r
+import os\r
+import re\r
+import subprocess\r
+import sys\r
+import shutil\r
+import time\r
+\r
+class pexpect (object):\r
+ def __init__ (self):\r
+ super (pexpect, self).__init__ ()\r
+\r
+ def spawn (self, stdin, arglist, *pargs, **kwargs):\r
+ self.proc = subprocess.Popen (arglist, *pargs, **kwargs)\r
+ if self.proc is None:\r
+ print ("Failed to spawn a process {0}".format (arglist))\r
+ sys.exit (1)\r
+ if stdin is not None:\r
+ self.stdo, self.stde = self.proc.communicate (stdin)\r
+ else:\r
+ self.stdo, self.stde = self.proc.communicate ()\r
+ return self.proc\r
+\r
+ def expect (self, s, r, flags=0):\r
+ stream = self.stdo if s == 'stdout' else self.stde\r
+ if isinstance (r, str):\r
+ if r == "EOF":\r
+ if len (stream) == 0:\r
+ return True\r
+ else:\r
+ print ("Failed to find `{1}' in {0}, which is `{2}' ({3})".format (s, r, stream, len (stream)))\r
+ sys.exit (2)\r
+ raise ValueError ("Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'".format (r))\r
+ m = r.search (stream, flags)\r
+ if not m:\r
+ print ("Failed to find `{1}' in {0}, which is is `{2}'".format (s, r.pattern, stream))\r
+ sys.exit (2)\r
+ stream = stream[m.end ():]\r
+ if s == 'stdout':\r
+ self.stdo = stream\r
+ else:\r
+ self.stde = stream\r
+ return m\r
+\r
+ def read (self, s, size=-1):\r
+ stream = self.stdo if s == 'stdout' else self.stde\r
+ result = ""\r
+ if size < 0:\r
+ result = stream\r
+ new_stream = ""\r
+ else:\r
+ result = stream[0:size]\r
+ new_stream = stream[size:]\r
+ if s == 'stdout':\r
+ self.stdo = new_stream\r
+ else:\r
+ self.stde = new_stream\r
+ return result\r