def rild_pid(): # Shared code: belongs_to_rild = lambda fn: contents_of( fn).startswith("/system/bin/rild") try: last_known_pid = int( contents_of("/var/run/rild.pid") ) except IOError: last_known_pid = 1 # If rild no longer has a process ID of last_known_pid: if not belongs_to_rild("/proc/%i/cmdline"%last_known_pid): # find rild: for fn in glob("/proc/*/cmdline"): if belongs_to_rild( fn): last_known_pid = int( fn.split("/")[2] ) write_to_file( str(last_known_pid), "/var/run/rild.pid") return last_known_pid
def temperature(): t = int( contents_of("/sys/class/power_supply/battery/batt_temp") ) return t / 10
def frequency(): return int( contents_of("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq") ) >> 10
def level(): return int( contents_of("/sys/class/power_supply/battery/level") )