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