Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Battmon, Simple battery monitoring program
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Polskie forum (Polish)
View previous topic :: View next topic  
Author Message
nictki
n00b
n00b


Joined: 10 Jan 2007
Posts: 63
Location: somewhere else...

PostPosted: Fri Oct 12, 2012 5:15 pm    Post subject: Battmon, Simple battery monitoring program Reply with quote

Hej,

napisałem mały program w pythonie, który monitoruje stan baterii.
Głównym celem napisania tego programu było posiadanie monitoringu baterii pod jakikolwiek tiling WM, który daje monity.
Najlepiej odpalić z opcją -h/--help, by zobaczyć wszystkie opcje.

Jeżeliby ktoś miałby ochote postestować, podesłać jakiekolwiek ulepszenia, czy miałby jakiekolwiek pytania, prosze śmialo pisać :)

a tu link:
https://github.com/nictki/Battmon
Back to top
View user's profile Send private message
gexcite
Tux's lil' helper
Tux's lil' helper


Joined: 24 Sep 2005
Posts: 116

PostPosted: Fri Oct 12, 2012 8:39 pm    Post subject: Reply with quote

Takie tam
Code:
./battmon.py

** (process:14726): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'

** (process:14726): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'

** (process:14726): WARNING **: Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags'
Unable to import pynotify module, use notify-send instead, so no popup's update.
Traceback (most recent call last):
  File "./battmon.py", line 643, in <module>
    notify=options.notify, critical=options.critical, sound=options.sound, timeout=options.timeout)
  File "./battmon.py", line 339, in __init__
    self.checkVlock()
  File "./battmon.py", line 414, in checkVlock
    pynotify.init("No vlock")
NameError: global name 'pynotify' is not defined
Back to top
View user's profile Send private message
nictki
n00b
n00b


Joined: 10 Jan 2007
Posts: 63
Location: somewhere else...

PostPosted: Fri Oct 12, 2012 8:53 pm    Post subject: Reply with quote

musisz miec zainstalowane dev-python/notify-python, albo odpal z program z -N , ale wtedy nie bedziesz mial zadnych powidomien...
na weekendzie dodam monit, co do dev-python/notify-python

dzieki :)
Back to top
View user's profile Send private message
SlashBeast
Retired Dev
Retired Dev


Joined: 23 May 2006
Posts: 2922

PostPosted: Fri Oct 12, 2012 9:02 pm    Post subject: Reply with quote

Przyjmujesz, ze bedzie BAT0 a na niektorych urzadzeniach moze byc po prostu BAT badz np. same numerki (mam tak na jednym hpku). Znacznie lepszym podejciem byl by loop po /sys/class/power_supply/*/type i uzycie tego, gdzie jest 'Battery'. Samo /proc/acpi w ogole nie powinienes uzywac, podobnie jak znalezienie baterii tak samo mozesz AC znalezc, w type bedzie 'Mains', a w katalogu w sys plik 'online' z 1 jak jest AC, a 0 jak odlaczone.

Last edited by SlashBeast on Fri Oct 12, 2012 9:04 pm; edited 1 time in total
Back to top
View user's profile Send private message
gexcite
Tux's lil' helper
Tux's lil' helper


Joined: 24 Sep 2005
Posts: 116

PostPosted: Fri Oct 12, 2012 9:02 pm    Post subject: Reply with quote

po instalacji notify-python:
Code:
./battmon.py

** (process:22167): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'

** (process:22167): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'

** (process:22167): WARNING **: Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags'
Traceback (most recent call last):
  File "./battmon.py", line 643, in <module>
    notify=options.notify, critical=options.critical, sound=options.sound, timeout=options.timeout)
  File "./battmon.py", line 339, in __init__
    self.checkVlock()
  File "./battmon.py", line 415, in checkVlock
    self.notifier.sendNofiication('Is vlock intalled ?' ,
AttributeError: Application instance has no attribute 'notifier'


z opcją -N:
Code:
./battmon.py -N

** (process:22170): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'

** (process:22170): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'

** (process:22170): WARNING **: Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags'
Traceback (most recent call last):
  File "./battmon.py", line 643, in <module>
    notify=options.notify, critical=options.critical, sound=options.sound, timeout=options.timeout)
  File "./battmon.py", line 339, in __init__
    self.checkVlock()
  File "./battmon.py", line 415, in checkVlock
    self.notifier.sendNofiication('Is vlock intalled ?' ,
AttributeError: Application instance has no attribute 'notifier'
Back to top
View user's profile Send private message
nictki
n00b
n00b


Joined: 10 Jan 2007
Posts: 63
Location: somewhere else...

PostPosted: Fri Oct 12, 2012 9:06 pm    Post subject: Reply with quote

thx, za info
dodalem monit co do pynotify, powinien wyskoczyc popup, ze nie ma zainstalowanego pynotify
Back to top
View user's profile Send private message
nictki
n00b
n00b


Joined: 10 Jan 2007
Posts: 63
Location: somewhere else...

PostPosted: Fri Oct 12, 2012 9:12 pm    Post subject: Reply with quote

@SlashBeast dzieki, jakos w niedziele skoryguje
@gexite wychodzi, ze brak vlock, jak tetsowalem u mnie banglalo, rzuce okiem

dzieki


Last edited by nictki on Fri Oct 12, 2012 10:14 pm; edited 1 time in total
Back to top
View user's profile Send private message
nictki
n00b
n00b


Joined: 10 Jan 2007
Posts: 63
Location: somewhere else...

PostPosted: Fri Oct 12, 2012 9:56 pm    Post subject: Reply with quote

@gexite naprawione, powinno byc online
Back to top
View user's profile Send private message
gexcite
Tux's lil' helper
Tux's lil' helper


Joined: 24 Sep 2005
Posts: 116

PostPosted: Sat Oct 13, 2012 10:57 am    Post subject: Reply with quote

Tak jak napisał SlashBeast, musisz go jeszcze doszlifować. Moje uwagi:
1. Na stacjonarce uparcie chce się dobrać do stanu baterii a jej tam przecież nie ma
2. Na lapsie baterię bada w ścieżce
Code:
/proc/acpi/ac_adapter/AC/state

tymczasem w moim jest
Code:
/proc/acpi/ac_adapter/AC0/state

3. Poprawiony kod aby szukał w ..AC0.. wywala z kolei
Code:
Traceback (most recent call last):
  File "./battmon.py", line 644, in <module>
    ml.runMainLoop()
  File "./battmon.py", line 535, in runMainLoop
    if self.batteryValues.isAcAdapterPresent() == True and self.batteryValues.isBatteryFullyCharged() == True and self.batteryValues.isBatteryDischarging() == False:
  File "./battmon.py", line 182, in isBatteryFullyCharged
    fully_charged = os.popen("acpi").readlines()[0]
IndexError: list index out of range
Back to top
View user's profile Send private message
nictki
n00b
n00b


Joined: 10 Jan 2007
Posts: 63
Location: somewhere else...

PostPosted: Tue Oct 16, 2012 2:03 pm    Post subject: Reply with quote

@SlashBeast
'szukanie' baterii i adaptera poprawione
_________________
github
Back to top
View user's profile Send private message
nictki
n00b
n00b


Joined: 10 Jan 2007
Posts: 63
Location: somewhere else...

PostPosted: Fri Oct 19, 2012 5:00 pm    Post subject: Reply with quote

troche poprawek dodanych...
testowalem na dwoch roznych lapach, wsio dziala ok...
i jak napisalem: sugestie, pytania, poprawiki etc. bardzo mile widziane
_________________
github
Back to top
View user's profile Send private message
nictki
n00b
n00b


Joined: 10 Jan 2007
Posts: 63
Location: somewhere else...

PostPosted: Thu Nov 15, 2012 4:27 pm    Post subject: Reply with quote

update: acpi nie jest juz wiecej wymagane, wszystko leci przez sysfs
_________________
github
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Polskie forum (Polish) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum