def sysctl_kernel(key, value=None): """(Very) partial implementation of sysctl, for kernel params""" if value is not None: # write utils.write_one_line('/proc/sys/kernel/%s' % key, str(value)) else: # read out = utils.read_one_line('/proc/sys/kernel/%s' % key) return int(re.search(r'\d+', out).group(0))
def sysctl_kernel(key, value=None): """(Very) partial implementation of sysctl, for kernel params""" if value is not None: # write utils.write_one_line("/proc/sys/kernel/%s" % key, str(value)) else: # read out = utils.read_one_line("/proc/sys/kernel/%s" % key) return int(re.search(r"\d+", out).group(0))
def sysctl(key, value=None): """Generic implementation of sysctl, to read and write. @param key: A location under /proc/sys @param value: If not None, a value to write into the sysctl. @return The single-line sysctl value as a string. """ path = '/proc/sys/%s' % key if value is not None: utils.write_one_line(path, str(value)) return utils.read_one_line(path)
def sysctl(key, value=None): """Generic implementation of sysctl, to read and write. :param key: A location under /proc/sys :param value: If not None, a value to write into the sysctl. :return: The single-line sysctl value as a string. """ path = "/proc/sys/%s" % key if value is not None: utils.write_one_line(path, str(value)) return utils.read_one_line(path)
def get_write_one_line_output(self, content): test_file = mock.SaveDataAfterCloseStringIO() utils.open.expect_call("filename", "w").and_return(test_file) utils.write_one_line("filename", content) self.god.check_playback() return test_file.final_data
def set_power_state(state): """ Set the system power state to 'state'. """ utils.write_one_line('/sys/power/state', state)
def set_wake_alarm(alarm_time): """ Set the hardware RTC-based wake alarm to 'alarm_time'. """ utils.write_one_line('/sys/class/rtc/rtc0/wakealarm', str(alarm_time))
def set_power_state(state): """ Set the system power state to 'state'. """ utils.write_one_line("/sys/power/state", state)
def set_wake_alarm(alarm_time): """ Set the hardware RTC-based wake alarm to 'alarm_time'. """ utils.write_one_line("/sys/class/rtc/rtc0/wakealarm", str(alarm_time))