fix computing battery capacity on python2