Python way to printk?

News123 news1234 at free.fr
Wed Jun 9 17:56:58 EDT 2010


Hi J,

J 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.


I'm rephrasing your question:
You would like to perform printk from user space.
I think this is not really intended.

You could write a small linux kernel module relaying user space messages
to the dmesg buffer.


Just look at
http://serverfault.com/questions/140354/how-to-add-message-that-will-be-read-with-dmesg
to get some ideas and continue googling for |"printk" and "user space".



More information about the Python-list mailing list