From d1c402b463349ad531da31fde10eb20efd49b1a0 Mon Sep 17 00:00:00 2001 From: Per Cederqvist <ceder@lysator.liu.se> Date: Sun, 12 Oct 2003 21:58:23 +0000 Subject: [PATCH] Adjusted to packagization of pcl_expect. --- demo/dualftp.py | 13 +++++++------ demo/ftp.py | 13 +++++++------ demo/ftp.pyex | 5 +++-- demo/ftptrad.py | 5 +++-- demo/telnet.py | 13 +++++++------ 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/demo/dualftp.py b/demo/dualftp.py index e2cff3e..e7ff0f0 100644 --- a/demo/dualftp.py +++ b/demo/dualftp.py @@ -10,12 +10,13 @@ import sys import time import pcl_expect +import pcl_expect.spawn -pcl_expect.stty_init = "-onlcr -ocrnl -echo" +pcl_expect.spawn.stty_init = "-onlcr -ocrnl -echo" time0 = time.time() -funet = pcl_expect.spawn("ftp ftp.funet.fi") -sunet = pcl_expect.spawn("ftp ftp.sunet.se") +funet = pcl_expect.spawn.spawn("ftp ftp.funet.fi") +sunet = pcl_expect.spawn.spawn("ftp ftp.sunet.se") def name_cb(ftp): ftp.send("anonymous\n") @@ -56,7 +57,7 @@ pcl_expect.expect_after([(pcl_expect.RE, funet, "Name.*:", name_cb), (pcl_expect.RE, funet, "(?s).*ftp> ", prompt_cb), (pcl_expect.RE, sunet, "(?s).*ftp> ", prompt_cb)]) -x = pcl_expect.impl() +x = pcl_expect.controller() while x.loop(): if x.timeout(): sys.stdout.write(".") @@ -69,7 +70,7 @@ funet.send("bye\n") pcl_expect.expect_after([]) -x = pcl_expect.impl() +x = pcl_expect.controller() while x.loop(): if x.eof(sunet): print "SUNET final output:", sunet.match @@ -80,7 +81,7 @@ while x.loop(): x.cont() continue -x = pcl_expect.impl() +x = pcl_expect.controller() while x.loop(): if x.eof(funet): print "FUNET final output:", funet.match diff --git a/demo/ftp.py b/demo/ftp.py index a7748db..39b1f2f 100644 --- a/demo/ftp.py +++ b/demo/ftp.py @@ -1,12 +1,13 @@ # The mandatory ftp example... +import pcl_expect.spawn import pcl_expect -pcl_expect.stty_init = "-onlcr -ocrnl" +pcl_expect.spawn.stty_init = "-onlcr -ocrnl" -ftp = pcl_expect.spawn("ftp ftp.funet.fi") +ftp = pcl_expect.spawn.spawn("ftp ftp.funet.fi") -x = pcl_expect.impl() +x = pcl_expect.controller() while x.loop(): if x.re(ftp, "Name.*:"): ftp.send("anonymous\n") @@ -21,21 +22,21 @@ while x.loop(): ftp.send("cd pub\n") -x = pcl_expect.impl() +x = pcl_expect.controller() while x.loop(): if x.re(ftp, "(?s).*ftp> "): pass ftp.send("passive\n") -x = pcl_expect.impl() +x = pcl_expect.controller() while x.loop(): if x.re(ftp, "(?s).*ftp> "): pass ftp.send("dir\n") -x = pcl_expect.impl() +x = pcl_expect.controller() while x.loop(): if x.re(ftp, "(?s).*ftp> "): print ftp.match.group() diff --git a/demo/ftp.pyex b/demo/ftp.pyex index baa2e7a..ca10ff4 100644 --- a/demo/ftp.pyex +++ b/demo/ftp.pyex @@ -1,10 +1,11 @@ # The mandatory ftp example... import pcl_expect +import pcl_expect.spawn -pcl_expect.stty_init = "-onlcr -ocrnl" +pcl_expect.spawn.stty_init = "-onlcr -ocrnl" -ftp = pcl_expect.spawn("ftp ftp.funet.fi") +ftp = pcl_expect.spawn.spawn("ftp ftp.funet.fi") expect: re(ftp, "Name.*:"): diff --git a/demo/ftptrad.py b/demo/ftptrad.py index 84028cf..b6f5ae6 100644 --- a/demo/ftptrad.py +++ b/demo/ftptrad.py @@ -1,10 +1,11 @@ # The mandatory ftp example, in traditional style. import pcl_expect +import pcl_expect.spawn -pcl_expect.stty_init = "-onlcr -ocrnl" +pcl_expect.spawn.stty_init = "-onlcr -ocrnl" -ftp = pcl_expect.spawn("ftp ftp.funet.fi") +ftp = pcl_expect.spawn.spawn("ftp ftp.funet.fi") def send_anon(exp): exp.send("anonymous\n") diff --git a/demo/telnet.py b/demo/telnet.py index e1e9037..6e219e8 100644 --- a/demo/telnet.py +++ b/demo/telnet.py @@ -6,6 +6,7 @@ import os import sys import pcl_expect +import pcl_expect.telnet host = sys.argv[1] user = sys.argv[2] @@ -23,19 +24,19 @@ print if len(password) > 0 and password[-1] == "\n": password = password[:-1] -t = pcl_expect.telnet(host, "23") +t = pcl_expect.telnet.telnet(host, "23") -x = pcl_expect.impl() +x = pcl_expect.controller() while x.loop(): if x.re(t, "ogin:"): t.send(user + "\n") -x = pcl_expect.impl() +x = pcl_expect.controller() while x.loop(): if x.re(t, "assword:"): t.send(password + "\n") -x = pcl_expect.impl() +x = pcl_expect.controller() while x.loop(): if x.re(t, ">|\\$|#"): t.send("uname -a\n") @@ -44,13 +45,13 @@ while x.loop(): t.close() sys.exit(1) -x = pcl_expect.impl() +x = pcl_expect.controller() while x.loop(): if x.re(t, "(.*)\r?\n.*(>|\\$|#)"): print "SYSTEM ID:", t.match.group(1) t.send("exit\n") -x = pcl_expect.impl() +x = pcl_expect.controller() while x.loop(): if x.eof(t): t.close() -- GitLab