Skip to content
Browse files

added float wrappers to values read from acpi/tpsmapi

  • Loading branch information...
1 parent 765e432 commit 2e232ec359f71c11a317b613338bcd6641969563 @teleshoes committed Jun 17, 2012
Showing with 16 additions and 16 deletions.
  1. +4 −4 src/battbalance.py
  2. +10 −10 src/battstatus.py
  3. +1 −1 src/dzenprinter.py
  4. +1 −1 src/gui.py
View
8 src/battbalance.py
@@ -65,8 +65,8 @@ def perhaps_inhibit_charge(self):
not b1.isInstalled())
charge0 = b0.isCharging()
charge1 = b1.isCharging()
- per0 = int(b0.remaining_percent)
- per1 = int(b1.remaining_percent)
+ per0 = int(float(b0.remaining_percent))
+ per1 = int(float(b1.remaining_percent))
strategy = self.prefs.charge_strategy
if should_not_inhibit or strategy == ChargeStrategy.SYSTEM:
if b0.isChargeInhibited():
@@ -106,8 +106,8 @@ def perhaps_force_discharge(self):
b1.isInstalled())
dis0 = b0.isDischarging()
dis1 = b1.isDischarging()
- per0 = int(b0.remaining_percent)
- per1 = int(b1.remaining_percent)
+ per0 = int(float(b0.remaining_percent))
+ per1 = int(float(b1.remaining_percent))
force0 = False
force1 = False
strategy = self.prefs.discharge_strategy
View
20 src/battstatus.py
@@ -43,11 +43,11 @@ def getBattInfo(self, batt_id):
def getPowerDisplay(self):
disp = self.prefs.display_power_usage.lower()
if disp == 'average' or (disp == 'now' and self.prefs.use_acpi):
- p0 = int(self.batt0.power_avg)
- p1 = int(self.batt1.power_avg)
+ p0 = int(float(self.batt0.power_avg))
+ p1 = int(float(self.batt1.power_avg))
elif disp == 'now':
- p0 = int(self.batt0.power_now)
- p1 = int(self.batt1.power_now)
+ p0 = int(float(self.batt0.power_now))
+ p1 = int(float(self.batt1.power_now))
else:
return ''
@@ -83,11 +83,11 @@ def getTotalRemainingPercent(self):
rem_cap = 0
max_cap = 0
if self.batt0.isInstalled():
- rem_cap = rem_cap + int(self.batt0.remaining_capacity)
- max_cap = max_cap + int(self.batt0.last_full_capacity)
+ rem_cap = rem_cap + int(float(self.batt0.remaining_capacity))
+ max_cap = max_cap + int(float(self.batt0.last_full_capacity))
if self.batt1.isInstalled():
- rem_cap = rem_cap + int(self.batt1.remaining_capacity)
- max_cap = max_cap + int(self.batt1.last_full_capacity)
+ rem_cap = rem_cap + int(float(self.batt1.remaining_capacity))
+ max_cap = max_cap + int(float(self.batt1.last_full_capacity))
if max_cap == 0:
return 0
return int(100 * (float(rem_cap) / float(max_cap)))
@@ -119,7 +119,7 @@ def isCharging(self):
def isDischarging(self):
return self.state == State.DISCHARGING
def isChargeInhibited(self):
- return int(self.inhibit_charge_minutes) > 0
+ return int(float(self.inhibit_charge_minutes)) > 0
def isForceDischarge(self):
return self.force_discharge == '1'
def update(self, prefs):
@@ -177,7 +177,7 @@ def isCharging(self):
def isDischarging(self):
return self.state == State.DISCHARGING
def isChargeInhibited(self):
- return int(self.inhibit_charge_minutes) > 0
+ return int(float(self.inhibit_charge_minutes)) > 0
def isForceDischarge(self):
return self.force_discharge == '1'
def acpiDir(self):
View
2 src/dzenprinter.py
@@ -38,7 +38,7 @@ def __init__(self, prefs, battStatus):
def selectImageByBattId(self, batt_id):
battInfo = self.battStatus.getBattInfo(batt_id)
return self.selectImage(battInfo.isInstalled(), battInfo.state,
- int(battInfo.remaining_percent))
+ int(float(battInfo.remaining_percent)))
def selectImage(self, installed, state, percent):
if not installed:
return IMAGE_DIR + "/none.xpm"
View
2 src/gui.py
@@ -103,7 +103,7 @@ def newPixbuf(self, filename):
def selectPixbufByBattId(self, batt_id):
battInfo = self.battStatus.getBattInfo(batt_id)
return self.selectPixbuf(battInfo.isInstalled(), battInfo.state,
- int(battInfo.remaining_percent))
+ int(float(battInfo.remaining_percent)))
def selectPixbuf(self, installed, state, percent):
if not installed:
return self.none

0 comments on commit 2e232ec

Please sign in to comment.
Something went wrong with that request. Please try again.