Python way to printk?

Dan Stromberg drsalists at gmail.com
Wed Jun 9 18:25:52 EDT 2010


I'm not sure of the specifics, but you may find that you can do this with
the syslog module - may require reconfiguring syslog.conf or the equivalent
though.  If you hit an appropriate facility and level, you likely will see
syslog messages go to the kernel's dmesg ring buffer.

On Wed, Jun 9, 2010 at 2:40 PM, J <dreadpiratejeff at gmail.com> wrote:

> Does anyone know of a way, or have a recipe, to do a linux printk
> equivalent in Python?
>
> I've been googling for a while and not finding anything useful.
>
> The nutshell version of this is that I need to write a routine for a
> test tool I'm working on that will time the amount of time used to
> take a system and go from Live to Suspended and then from Suspended to
> Live.
>
> I can get all the times I need from the kernel message buffer (via
> dmesg) but one of the test cases involves doing 30 suspend/resume
> cycles, so I'll end up having to parse and weed out a lot of redundant
> data.
>
> One idea I had was to just flush the buffer (calling dmesg -c) but
> that's not the nicest way of doing things on an end user's system.
>
> SO, the thought I had was to just inject a marker like "START SUSPEND
> TEST hash" where hash is a unique identifier for that test run, either
> the number of the run (1 - 30) or a timestamp or whatever... it just
> has to be unique
> and then inject a "FINISHED SUSPEND TEST has" marker after the system
> is fully live.
>
> THEN I could just look for those two markers and parse the data in
> between them for the timestamps I need.
>
> but I can't find any way so far, in python to write kernel messages.
> Perhaps this is something for ctypes? (though I'm trying to keep from
> introducing non-python code if at all possible) and I've never used
> ctypes before and have no real idea how to use them (perhaps this
> would be a good, easy way to learn?)
>
> I'm going to start looking at ctypes after sending this and maybe
> learn something new today, but I also wanted to ask the list for
> suggestions as well.
>
> Cheers,
>
> Jeff
>
> And yes, this is not something that would be portable to a non-Linux
> OS, but that's ok, because this is strictly a Linux tool anyway.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100609/ec627530/attachment-0001.html>


More information about the Python-list mailing list