<s> import subprocess <EOL> from ajenti . api import plugin <EOL> from ajenti . api . sensors import Sensor <EOL> from ajenti . plugins . dashboard . api import DashboardWidget <EOL> @ plugin <EOL> class UPSChargeSensor ( Sensor ) : <EOL> id = '<STR_LIT>' <EOL> timeout = <NUM_LIT:2> <EOL> def measure ( self , variant = None ) : <EOL> data = { } <EOL> for l in subprocess . check_output ( '<STR_LIT>' ) . splitlines ( ) : <EOL> if l and '<STR_LIT::>' in l : <EOL> k , v = l . split ( '<STR_LIT::>' , <NUM_LIT:1> ) <EOL> k = k . strip ( ) <EOL> v = v . strip ( ) <EOL> data [ k ] = v <EOL> return ( float ( data . get ( '<STR_LIT>' , '<STR_LIT>' ) . split ( ) [ <NUM_LIT:0> ] ) / <NUM_LIT> , data . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> @ plugin <EOL> class UPSWidget ( DashboardWidget ) : <EOL> name = '<STR_LIT>' <EOL> icon = '<STR_LIT>' <EOL> def init ( self ) : <EOL> self . sensor = Sensor . find ( '<STR_LIT>' ) <EOL> self . append ( self . ui . inflate ( '<STR_LIT>' ) ) <EOL> value = self . sensor . value ( ) <EOL> self . find ( '<STR_LIT>' ) . value = value [ <NUM_LIT:0> ] <EOL> self . find ( '<STR_LIT:time>' ) . text = value [ <NUM_LIT:1> ] </s>
