Notices


Reply
Thread Tools
Posts: 2,225 | Thanked: 3,822 times | Joined on Jun 2010 @ Florida
#141
skykooler, I'm either almost at the point where I can present you (and everyone else, really) with a working model of processor and memory usage monitoring in the clock style, OR I'm almost at the point where I throw my hands up in the air in frustration and go with your sleeps using thing. Memory was easy as hell, but this processor thing has hit a little snag.

I figured out a method that doesn't use sleeps, but as a result, the intervals between measuring /proc/stat values are so small, that it almost always gives 1 or 0 as the value to the equation of time CPU spent in non-idle processes, vs. time spent in total (or anything at all. If you do the cpumem applet route and compare ONLY idle, it never reports anything but 0, because there's no idle time in the time spent processing the script, I suspect, during the two moments it fetches info from /proc/stat. (I am pretty sure it's not a math screw up, because other than the idle times, all the others do have time to change, and under the right circumstances, 2, 3, and even up to 6 has shown up [when comparing differences between different moments of the first three numbers of /proc/stat together. Division of that difference by the difference in 'total' time also yields either 1, 0, or [until I figured out to account for possible zeroes in the 'total' time, which is the denominator] errors.)

Mathematically all of this basically comes down to exactly that: I can't make python wait long enough between checks for the stats in procs to accumulate enough 'Jiffies'/USER_HZ to change significantly. The only reason I got any changes at all was by placing one /proc/stat opening and closing before the opening and closing of /proc/meminfo, then calculating the mem part of the script, then fetching the second instance of /proc/stat.

The main thing tripping this up is needing to declare a variable in python before you can use it (it's probably not a problem in all of python, but I couldn't figure out how to do it within a clock-style once, without that first declaration either crashing the clock style, or being run every new iteration of the clock - you can put that down to lack of Python knowledge or some unintended behavior, I don't know.

But right now, this is what I was trying to do for about two days straight, before stumbling upon the above, which still isn't actually a practical solution (if you pad it with enough code between the two accessings of /proc/stat, it either just ends up wasting more processing power on running the padding, and it becomes more efficient to use your sleep approach.

Wonko: Am I missing something here? Is there a way I can set a variable from within the clock style once, just so that it's initialized, and then have later looping parts of the draw clock code use it?

To be clear, I'm going for something like this:

cpuprevious = 0 [or NoneType, doesn't matter]
[blah blah blah various code]
cpulist = file("/proc/stat", 'r')
[more code]
cpucurrent = [stuff taken from cpulist.readline().whatever]
cpu = cpucurrent - cpuprevious
cpuprevious = cpucurrent

The point being, I want the initializing cpuprevious = 0 code to just run once, and I want cpuprevious = cpucurrent to run every execution. That way the last run's current /proc/stat gets uses as the previous value for the next run, etc. The very first initial calculation ends up off, but you only see it during boot/restart of hildon-status-menu, and then processor load would be on-off anyway. I have tried putting "cpuprevious = 0" [my variable names are a bit different, but for example's sake, we're going with "cpuprevious"], in various places in the code. It always has to run before the cpuprevious = cpucurrent, because if it doesn't, Python will throw a fit about cpuprevious not being defined when it hits "cpu = cpucurrent - cpuprevious". Naturally making them equal each other before you run that "cpu =" is counter productive, because then it'll just make cpu = 0 the entire time, so again, you have to define cpuprevious before you run "cpu =", but the only places I've been able to put it within the clock style without crashing the clock causes that line to be run on every clock-refresh, thus wiping whatever the 'last' value may have been. I also tried using "try cpuprevious/except NameError/else/finally" combinations, but so far, they seem to get stuck on the one choice they're given. So, the clock style initializes, it hits the "try", hits the exception, and then runs the exception (defining the variable as whatever). Then it does the rest (cpuprevious = cpucurrent at the end), and I thought that from there, when it hits the next loop, it will have a defined cpuprevious, so the try/except thing won't get a name error, and would move on. But, apparently, it gets stuck running whatever the exception suite was, even when the exception is no longer valid. I also tried some stuff with while loops, but failed at that too, since I couldn't find anything in the last few days of non-stop working (literally, this has become addictive, most of my day is doing this) that would check for the variable not existing. I tried "while cpuprevious not in locals()" and "while cpuprevious not in globals()", but near as I could tell, that doesn't do it either.

I mean, I haven't literally done every conceivable combination of code possible, but pretty close, and I haven't found it to be doable within the clock style with my limited skills.

Oh, also, "from __future__ import division" didn't work from within my clock style. Anything I'm missing about python on the N900, that could explain why this didn't work for me? (Of course, I also manage to have a bunch of other stuff I thought I imitated just fine from other example python code just not work... so I'm sure there's something really important I just don't know about importing.)

- While I wrote this, Wonko posted about the new update -
Wonko, I'll tell you if I get any bugs tomorrow. I just spend an all-nighter again working on the above problem (this is day 4 or 5 I did that in a row now... lol), so I want to sleep.
 

The Following User Says Thank You to Mentalist Traceur For This Useful Post:
Posts: 456 | Thanked: 1,580 times | Joined on Dec 2009
#142
Originally Posted by Mentalist Traceur View Post
Wonko: Am I missing something here? Is there a way I can set a variable from within the clock style once, just so that it's initialized, and then have later looping parts of the draw clock code use it?
That's what the constructor (the __init__ method) is for.
There you can initialize member variables like this:
Code:
class DecimalClock(clock.Clock):
    def __init__(self, drawing_area):
        clock.Clock.__init__(self, drawing_area)
        self.my_member_variable = 0 #None, "some_string" whatsoever
And then later on you just use "self.my_member_variable" in your code to access it.


P.S.: I didn't read your complete post yet, just wanted to give you a quick feedback.
By the way, I seem to have missed what you're up to.
What exactly are you trying to do?

Edit: By the way, if you have the "Show Seconds" option disabled the clock is only updated once per minute.
Consequently, the draw_clock method is also only called once per minute.
__________________
 

The Following 2 Users Say Thank You to Wonko For This Useful Post:
Posts: 671 | Thanked: 1,630 times | Joined on Aug 2010
#143
Just upgraded from the old 0.3 to 0.9.2-1
and I seem to have lost the fonts somewhere,
as the binary clocks all work but the character-based clocks
are just blank.

This is on my stock-version unit (my test unit which
I normally use to check things out on is still not working)
so it has no special things going on aside from PR 1.3
and the usual stuff.

I see a very involved list of fonts to choose from but none seem
to show up in the clock - just a black blank.
I changed the color settings to make sure it was not
doing something silly like printing black on black but again no joy.
I tried just using sans and nokia sans and a few others from the list
but the results are always just a blank.
The binary and bcd and analog clocks are all ok,
only the clocks needing text are affected.

I am still looking for where this went off the rails,
uninstalling and rebooting had no effect, so I am guessing
I have a misconfigured gconf setting maybe?


Found it - I was doing something silly like
using the default text scaling setting of 1.
This might be better set to some nominal scale, perhaps?
I notice it always resets to 1 each time I open the dialogue,
which may be a problem for some users.

Anwhay - it works even better now thanks
__________________
Three n900s: One for stable working platform,
One for development testing Chopping Onions
One for saltwater immersion power testing resurrected ! parts scavenging

My Mods for Wonko's Advanced Clock Plugin:
ISO8601 clock mod and Momental_IST clock mod

Printing your Email with the N900

Last edited by theonelaw; 2011-01-01 at 16:56. Reason: Found it
 

The Following 2 Users Say Thank You to theonelaw For This Useful Post:
Posts: 671 | Thanked: 1,630 times | Joined on Aug 2010
#144
Weird - I just set text scaling to 80 or 90 and it jumps to 100.
Not a real problem but wondering what the mechanism for that is...

Also notice that when I add a personal clock it immediately
to /usr/lib/advanced... it immediately becomes available
for selection but it does not run when selected,
the previous selection runs.
I am guessing this is because only clocks found at boot are
available perhaps?

Rebooted and no clock now, will try uninstall and re-install and see
where I broke it

hildon-status-menu mantra - (this helps):
Code:
pkill -f /usr/bin/hildon-status-menu
back to testing my ISO mod
__________________
Three n900s: One for stable working platform,
One for development testing Chopping Onions
One for saltwater immersion power testing resurrected ! parts scavenging

My Mods for Wonko's Advanced Clock Plugin:
ISO8601 clock mod and Momental_IST clock mod

Printing your Email with the N900

Last edited by theonelaw; 2011-01-01 at 17:22. Reason: observations
 

The Following 2 Users Say Thank You to theonelaw For This Useful Post:
Posts: 18 | Thanked: 9 times | Joined on Aug 2010
#145
Great app! I'm interested in seeing the DateTime clock and the Decimal clock be configurable such that I could put an arbitrary strftime-compatible string in to get whatever date/time formats I want. Also, I would really like to see support for fractional days (probably I would pre-process %J into millidays so that it remains compatible with normal strftime syntax).

I am willing to write the code for this. Is a patch to this effect likely to get accepted? Is there a public source repository or other good thing or are hackers just extracting python from the .deb and using diff?
 

The Following 3 Users Say Thank You to singpolyma For This Useful Post:
Posts: 482 | Thanked: 550 times | Joined on Oct 2010
#146
Originally Posted by Mentalist Traceur View Post
skykooler, I'm either almost at the point where I can present you (and everyone else, really) with a working model of processor and memory usage monitoring in the clock style, OR I'm almost at the point where I throw my hands up in the air in frustration and go with your sleeps using thing. Memory was easy as hell, but this processor thing has hit a little snag.

I figured out a method that doesn't use sleeps, but as a result, the intervals between measuring /proc/stat values are so small, that it almost always gives 1 or 0 as the value to the equation of time CPU spent in non-idle processes, vs. time spent in total (or anything at all. If you do the cpumem applet route and compare ONLY idle, it never reports anything but 0, because there's no idle time in the time spent processing the script, I suspect, during the two moments it fetches info from /proc/stat. (I am pretty sure it's not a math screw up, because other than the idle times, all the others do have time to change, and under the right circumstances, 2, 3, and even up to 6 has shown up [when comparing differences between different moments of the first three numbers of /proc/stat together. Division of that difference by the difference in 'total' time also yields either 1, 0, or [until I figured out to account for possible zeroes in the 'total' time, which is the denominator] errors.)

Mathematically all of this basically comes down to exactly that: I can't make python wait long enough between checks for the stats in procs to accumulate enough 'Jiffies'/USER_HZ to change significantly. The only reason I got any changes at all was by placing one /proc/stat opening and closing before the opening and closing of /proc/meminfo, then calculating the mem part of the script, then fetching the second instance of /proc/stat.

The main thing tripping this up is needing to declare a variable in python before you can use it (it's probably not a problem in all of python, but I couldn't figure out how to do it within a clock-style once, without that first declaration either crashing the clock style, or being run every new iteration of the clock - you can put that down to lack of Python knowledge or some unintended behavior, I don't know.

But right now, this is what I was trying to do for about two days straight, before stumbling upon the above, which still isn't actually a practical solution (if you pad it with enough code between the two accessings of /proc/stat, it either just ends up wasting more processing power on running the padding, and it becomes more efficient to use your sleep approach.

Wonko: Am I missing something here? Is there a way I can set a variable from within the clock style once, just so that it's initialized, and then have later looping parts of the draw clock code use it?

To be clear, I'm going for something like this:

cpuprevious = 0 [or NoneType, doesn't matter]
[blah blah blah various code]
cpulist = file("/proc/stat", 'r')
[more code]
cpucurrent = [stuff taken from cpulist.readline().whatever]
cpu = cpucurrent - cpuprevious
cpuprevious = cpucurrent

The point being, I want the initializing cpuprevious = 0 code to just run once, and I want cpuprevious = cpucurrent to run every execution. That way the last run's current /proc/stat gets uses as the previous value for the next run, etc. The very first initial calculation ends up off, but you only see it during boot/restart of hildon-status-menu, and then processor load would be on-off anyway. I have tried putting "cpuprevious = 0" [my variable names are a bit different, but for example's sake, we're going with "cpuprevious"], in various places in the code. It always has to run before the cpuprevious = cpucurrent, because if it doesn't, Python will throw a fit about cpuprevious not being defined when it hits "cpu = cpucurrent - cpuprevious". Naturally making them equal each other before you run that "cpu =" is counter productive, because then it'll just make cpu = 0 the entire time, so again, you have to define cpuprevious before you run "cpu =", but the only places I've been able to put it within the clock style without crashing the clock causes that line to be run on every clock-refresh, thus wiping whatever the 'last' value may have been. I also tried using "try cpuprevious/except NameError/else/finally" combinations, but so far, they seem to get stuck on the one choice they're given. So, the clock style initializes, it hits the "try", hits the exception, and then runs the exception (defining the variable as whatever). Then it does the rest (cpuprevious = cpucurrent at the end), and I thought that from there, when it hits the next loop, it will have a defined cpuprevious, so the try/except thing won't get a name error, and would move on. But, apparently, it gets stuck running whatever the exception suite was, even when the exception is no longer valid. I also tried some stuff with while loops, but failed at that too, since I couldn't find anything in the last few days of non-stop working (literally, this has become addictive, most of my day is doing this) that would check for the variable not existing. I tried "while cpuprevious not in locals()" and "while cpuprevious not in globals()", but near as I could tell, that doesn't do it either.

I mean, I haven't literally done every conceivable combination of code possible, but pretty close, and I haven't found it to be doable within the clock style with my limited skills.

Oh, also, "from __future__ import division" didn't work from within my clock style. Anything I'm missing about python on the N900, that could explain why this didn't work for me? (Of course, I also manage to have a bunch of other stuff I thought I imitated just fine from other example python code just not work... so I'm sure there's something really important I just don't know about importing.)

- While I wrote this, Wonko posted about the new update -
Wonko, I'll tell you if I get any bugs tomorrow. I just spend an all-nighter again working on the above problem (this is day 4 or 5 I did that in a row now... lol), so I want to sleep.
What I did in the net speed monitor is create a small file in /tmp with the data you want. This stays there every time the clock is run and is updated each time. Since the file size is so small, the extra execution time due to the read/write is negligible.

Hope this helps!
 

The Following User Says Thank You to skykooler For This Useful Post:
Posts: 482 | Thanked: 550 times | Joined on Oct 2010
#147
Originally Posted by singpolyma View Post
Great app! I'm interested in seeing the DateTime clock and the Decimal clock be configurable such that I could put an arbitrary strftime-compatible string in to get whatever date/time formats I want. Also, I would really like to see support for fractional days (probably I would pre-process %J into millidays so that it remains compatible with normal strftime syntax).

I am willing to write the code for this. Is a patch to this effect likely to get accepted? Is there a public source repository or other good thing or are hackers just extracting python from the .deb and using diff?
You can post any package you want to extras-devel (that's what I did with my clock plugin). As for the source - I believe there is a public source repository, but why not just look at the installed python files (seeing as they are not compiled)? The clocks are in /usr/lib/advanced-clock-plugin/clocks; take a look at them and write your own versions.
 

The Following User Says Thank You to skykooler For This Useful Post:
Posts: 456 | Thanked: 1,580 times | Joined on Dec 2009
#148
I just uploaded version 0.10.0.
This version adds a simple "world clock" and an option for selecting the displayed time zone.
Also, this version hopefully fixes some issues which were mentioned here.

Originally Posted by theonelaw View Post
Weird - I just set text scaling to 80 or 90 and it jumps to 100.
Fixed in 0.10.0.
Was reading an integer from gconf whereas it should have been float.

Originally Posted by singpolyma
Is there a public source repository or other good thing or are hackers just extracting python from the .deb and using diff?
The complete source code can be found in the SVN repository at the garage site:
https://garage.maemo.org/projects/advclockplugin
Patches are also welcome (as long as they don't break any existing logic).
Or you could write your own addition as skykooler mentioned.
Advanced Clock Plugin is intended to be open for extension by others via custom "clock styles".

Originally Posted by singpolyma
I'm interested in seeing the DateTime clock and the Decimal clock be configurable such that I could put an arbitrary strftime-compatible string in to get whatever date/time formats I want.
For this use case I'd suggest to add another "clock style".
A good start would probably be to copy the existing DecimalClock.
Of course you would need some String input field in the configuration plugin and a method for adding that string to the clocks.
I could add a free text field and set it in a way such that the text is available when inheriting from the Clock base class.
This would others also to use that free text probably for even completely different purposes.

Currently, all options that can be set via the options frontend are accessible when inheriting from the Clock base class.
So anyone writing a custom clock can access these fields.
Have a look in clock.py to see what is currently available.
__________________

Last edited by Wonko; 2011-01-01 at 19:50. Reason: Fix typo.
 

The Following 2 Users Say Thank You to Wonko For This Useful Post:
Posts: 456 | Thanked: 1,580 times | Joined on Dec 2009
#149
While I was at it I just uploaded version 0.11.0 to extras devel.
Firstly, this version fixes a bug with respect to dependencies.
Secondly, this version adds a "Custom Format" setting which can be used for basically anything you are up to.
In clocks inheriting from Clock (in clock.py) the content of this field can be accessed via "self.custom_format".
__________________
 

The Following 7 Users Say Thank You to Wonko For This Useful Post:
pusak gaoq's Avatar
Posts: 723 | Thanked: 519 times | Joined on Nov 2010 @ Kuching:Malaysia
#150
Originally Posted by Wonko View Post
While I was at it I just uploaded version 0.11.0 to extras devel.
Firstly, this version fixes a bug with respect to dependencies.
Secondly, this version adds a "Custom Format" setting which can be used for basically anything you are up to.
In clocks inheriting from Clock (in clock.py) the content of this field can be accessed via "self.custom_format".
love your great works....i have been updating this plugin to the latest version....
can i give you a few idea to makes this plugin even better???
i only suggest two thing to adds for this plugins....

1.change the analog clock = i was hopping you can change the circle analog clock to square analog clock & makes the clock use all the space in the status bar so the square clock can looks bigger...

2.hide the clock = after every upgrading to any version you can see the clock disappear from the status bar (really looks nice) & will re-appear after you have reboot it....i hoping you can adds hide the clock function on this plugins....

hopes you can takes my idea as a considerations for the latest version next....
 

The Following User Says Thank You to pusak gaoq For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 02:47.