From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: Stefan Stanacar <stefanx.stanacar@intel.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [RFC PATCH 4/8] lib/oeqa/utils/oetelnetlib.py: override Telnet class to use Unix domain sockets
Date: Wed, 03 Jul 2013 23:38:11 +0100 [thread overview]
Message-ID: <2012865.euj9qQ5pa7@helios> (raw)
In-Reply-To: <36e54d3b192d38100cdb795da0ff7b53ee2ad63c.1372413711.git.stefanx.stanacar@intel.com>
On Friday 28 June 2013 13:04:39 Stefan Stanacar wrote:
> Python's telnetlib Telnet class connects only to AF_INET sockets, but we
> want to use Unix domain socket for the qemu serial connection.
> Also add a new read_all_timeout method similar to Telnet's read_all
>
> Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
> ---
> meta/lib/oeqa/utils/oetelnetlib.py | 49
> ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
> create mode 100644 meta/lib/oeqa/utils/oetelnetlib.py
>
> diff --git a/meta/lib/oeqa/utils/oetelnetlib.py
> b/meta/lib/oeqa/utils/oetelnetlib.py new file mode 100644
> index 0000000..cdebac1
> --- /dev/null
> +++ b/meta/lib/oeqa/utils/oetelnetlib.py
> @@ -0,0 +1,49 @@
> +import socket
> +import time
> +import re
> +from telnetlib import Telnet
> +
> +class oeTelnet(Telnet):
> +
> + """
> + Override Telnet class to use unix domain sockets,
> + Telnet uses AF_INET for socket, we don't want that.
> + Also, provide a read_all variant with timeout, that
> + returns whatever output there is.
> + """
> +
> + def __init__(self, stream=None, logfile=None):
> +
> + Telnet.__init__(self, host=None)
> + self.stream = stream
> + self.logfile = logfile
> + if stream is not None:
> + self.open(stream)
> +
> + def log(self, msg):
> + if self.logfile:
> + with open(self.logfile, "a") as f:
> + f.write("%s\n" % msg)
> +
> + def open(self, stream):
> +
> + self.eof = 0
> + self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
> + self.sock.connect(stream)
> +
> + def read_all_timeout(self, match, timeout=120):
> + """Read until EOF or until timeout or until match.
> + """
> + ret = False
> + self.process_rawq()
> + endtime = time.time() + timeout
> + while not self.eof and time.time() < endtime:
> + self.fill_rawq()
> + self.process_rawq()
> + if re.search(match, self.cookedq):
> + ret = True
> + break
> + buf = self.cookedq
> + self.cookedq = ''
> + self.log(buf)
> + return (ret, buf)
Just a minor bit of feedback about this; I think it's probably best not to
call it something relating to "telnet" since it's no longer really telnet when
using unix domain sockets.
Cheers,
Paul
--
Paul Eggleton
Intel Open Source Technology Centre
next prev parent reply other threads:[~2013-07-03 22:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-28 10:04 [RFC PATCH 0/8] Proposed implementation of a new runtime tests framework Stefan Stanacar
2013-06-28 10:04 ` [RFC PATCH 1/8] classes/testimage.bbclass: new class for image tests Stefan Stanacar
2013-06-28 10:04 ` [RFC PATCH 2/8] lib/oeqa/oetest.py: base module for all runtime unittests Stefan Stanacar
2013-06-28 10:04 ` [RFC PATCH 3/8] lib/oeqa/utils/sshcontrol.py: helper module for running remote commands Stefan Stanacar
2013-06-28 10:04 ` [RFC PATCH 4/8] lib/oeqa/utils/oetelnetlib.py: override Telnet class to use Unix domain sockets Stefan Stanacar
2013-07-03 22:38 ` Paul Eggleton [this message]
2013-06-28 10:04 ` [RFC PATCH 5/8] lib/oeqa/utils/qemurunner.py: class to handle qemu instance Stefan Stanacar
2013-08-05 19:50 ` Colin Walters
2013-08-29 11:18 ` Stanacar, StefanX
2013-08-29 11:35 ` Colin Walters
2013-06-28 10:04 ` [RFC PATCH 6/8] lib/oeqa/utils/decorators.py: decorators for test methods Stefan Stanacar
2013-06-28 10:04 ` [RFC PATCH 7/8] lib/oeqa/runtime: image sanity tests Stefan Stanacar
2013-06-28 10:04 ` [RFC PATCH 8/8] lib/oeqa/runtime: add gcc test Stefan Stanacar
2013-06-28 22:06 ` [RFC PATCH 0/8] Proposed implementation of a new runtime tests framework Otavio Salvador
2013-06-28 22:29 ` Paul Eggleton
2013-07-04 6:51 ` Saul Wold
2013-07-04 9:10 ` Stanacar, StefanX
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2012865.euj9qQ5pa7@helios \
--to=paul.eggleton@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=stefanx.stanacar@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox