|
2013-02-16
, 12:16
|
Posts: 498 |
Thanked: 836 times |
Joined on Jun 2012
@ Finland
|
#622
|
~ # apt-get install python-qmsystem Reading package lists... Done Building dependency tree Reading state information... Done python-qmsystem is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
~ # sh /home/user/scripts/kayttoaika.py /home/user/scripts/kayttoaika.py: line 3: import: not found /home/user/scripts/kayttoaika.py: line 5: syntax error: unexpected "("
#!/usr/bin/python import QmSystem batt = QmSystem.QmBattery() if batt.getChargingState()==1: time = batt.getRemainingChargingTime() else: mode = QmSystem.QmBattery.NormalMode if QmSystem.QmDeviceMode().getPSMState() == 0 else QmSystem.QmBattery.PowersaveMode time = batt.getRemainingIdleTime(mode) time += batt.getRemainingTalkTime(mode) time = time/2 hours,mod = divmod(time,3600) mins,secs = divmod(mod,60) result = [] if hours == 1: result.append('%d hour' % hours) elif hours > 0: result.append('%d hours' % hours) if mins == 1: result.append('%d minute' % mins) elif mins > 0 or not result: result.append('%d minutes' % mins) print ' '.join(result)
|
2013-02-16
, 12:30
|
Posts: 498 |
Thanked: 836 times |
Joined on Jun 2012
@ Finland
|
#624
|
|
2013-02-16
, 13:02
|
|
Posts: 6,436 |
Thanked: 12,700 times |
Joined on Nov 2011
@ Ängelholm, Sweden
|
#625
|
#!/usr/bin/python import QmSystem batt = QmSystem.QmBattery() result = [] if batt.getChargingState()==1: time = batt.getRemainingChargingTime() result.append('Charging') else: mode = QmSystem.QmBattery.NormalMode if QmSystem.QmDeviceMode().getPSMState() == 0 else QmSystem.QmBattery.PowersaveMode time = batt.getRemainingIdleTime(mode) time += batt.getRemainingTalkTime(mode) time = time/2 result.append('Remaining') hours,mod = divmod(time,3600) mins,secs = divmod(mod,60) if hours == 1: result.append('%d hour' % hours) elif hours > 0: result.append('%d hours' % hours) if mins == 1: result.append('%d minute' % mins) elif mins > 0 or not result: result.append('%d minutes' % mins) print ' '.join(result)
The Following User Says Thank You to coderus For This Useful Post: | ||
|
2013-02-16
, 13:18
|
Posts: 498 |
Thanked: 836 times |
Joined on Jun 2012
@ Finland
|
#626
|
|
2013-02-16
, 22:19
|
|
Posts: 644 |
Thanked: 480 times |
Joined on Jul 2012
@ Finland
|
#627
|
#!/usr/bin/python import QmSystem batt = QmSystem.QmBattery() if batt.getBatteryState()==3: print "FULL" elif batt.getChargingState()==1: time = batt.getRemainingChargingTime() result = '+ ' else: #time = batt.getRemainingIdleTime(QmSystem.QmBattery.NormalMode) #time = QmSystem.QmBattery.getRemainingTalkTime(QmSystem.QmBattery.NormalMode) time = batt.getRemainingActiveTime(QmSystem.QmBattery.NormalMode) result = '~ ' hours,mod = divmod(time,3600) mins,secs = divmod(mod,60) if hours>0: result+=str(hours)+':' elif hours == 0: result+=str(hours)+':' if mins>10: result+=str(mins) elif mins<10: result+='0'+str(mins) elif mins == 0: result+='00'+str(mins) print result
The Following User Says Thank You to MK99 For This Useful Post: | ||
|
2013-02-17
, 11:48
|
|
Posts: 6,436 |
Thanked: 12,700 times |
Joined on Nov 2011
@ Ängelholm, Sweden
|
#630
|
Telegram | Openrepos | GitHub | Revolut donations