Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a battery plugin by reported by Christophe Vandeplas

  • Loading branch information...
commit 9695c1198f8f9cb19c1b9cb859c1878835e20ac4 1 parent e64e5cf
Dag Wieers authored
32 WISHLIST
View
@@ -0,0 +1,32 @@
+If you want to thank me because my packages have saved you already
+a lot of work, or if one of my tools is making your work much more
+enjoyable (or even indirectly got you a raise!) If people praise
+your wisdom, but you actually copied it directly from my website,
+you owe me bigtime :-)
+
+There are several ways you can thank me, and each of them will
+encourage me to try to do my best.
+
+ 1. The easiest and cheapest way for you to thank me is by sending
+ a lousy email with a small thank you. I enjoy if people take the
+ time for that.
+
+ 2. Another way of thanking me is to help other people on one of the
+ related mailinglists so I don't have to. You will not only earn
+ my respect, but also be regarded highly by others.
+
+ 3. A much better way to thank me is to think about what improvements
+ I could make to my packages or tools and add that to your
+ Thank-you email. Again, you will help others too and end up in
+ a wall-of-fame changelog.
+
+ 4. And the final way to thank me and making my time packaging and
+ developing stuff more worthwhile, is by picking something from
+ my Amazon wishlist. This will not only keep me happy, but it may
+ convince relatives of the worthy cause that is eating all my free
+ time.
+
+ http://dag.wieers.com/personal/wishlist.php
+ http://www.amazon.co.uk/gp/registry/registry.html/202-4247851-9308633?id=2684V6SI0NLN0
+
+Also a combination of these earns you some extra karma points ! :-)
0  examples.txt → docs/examples.txt
View
File renamed without changes
13 plugins/dstat_battery.py
View
@@ -10,7 +10,13 @@ class dstat_battery(dstat):
def __init__(self):
self.name = 'battery'
self.format = ('f', 4, 34)
- self.vars = os.listdir('/proc/acpi/battery/')
+ self.vars = []
+ for battery in os.listdir('/proc/acpi/battery/'):
+ for line in dopen('/proc/acpi/battery/'+battery+'/state').readlines():
+ l = string.split(line)
+ if len(l) < 2: continue
+ if l[0] == 'present:' and l[1] == 'yes':
+ self.vars.append(battery)
# self.nick = [string.lower(name) for name in self.vars]
self.nick = []
for name in self.vars:
@@ -31,6 +37,9 @@ def extract(self):
if l[0] == 'remaining':
current = int(l[2])
break
- self.val[battery] = current * 100.0 / full
+ if current:
+ self.val[battery] = current * 100.0 / full
+ else:
+ self.val[battery] = -1
# vim:ts=4:sw=4
Please sign in to comment.
Something went wrong with that request. Please try again.