def hard_blocked(idx):
"""
determines hard block state of device
:param idx: rkill index
:returns: True if device at idx is hard blocked, False otherwise
"""
if not os.path.exists(os.path.join(spath,"rfkill{0}".format(idx))):
raise pyric.error(errno.ENODEV,"No device at {0}".format(idx))
fin = None
try:
fin = open(os.path.join(spath,"rfkill{0}".format(idx),'hard'),'r')
return int(fin.read().strip()) == 1
except IOError:
raise pyric.error(errno.ENODEV,"No device at {0}".format(idx))
except ValueError:
raise pyric.error(pyric.EUNDEF,"Unexpected error")
finally:
if fin: fin.close()
评论列表
文章目录