Пример #1
0
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
Пример #2
0
def temperature():
  t = int( contents_of("/sys/class/power_supply/battery/batt_temp") )
  return t / 10
Пример #3
0
def frequency():
  return int( contents_of("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq") ) >> 10
Пример #4
0
def level():
  return int( contents_of("/sys/class/power_supply/battery/level") )