Esempio n. 1
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))
Esempio n. 2
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))
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
0
 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
Esempio n. 6
0
 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
Esempio n. 7
0
def set_power_state(state):
    """
    Set the system power state to 'state'.
    """
    utils.write_one_line('/sys/power/state', state)
Esempio n. 8
0
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))
Esempio n. 9
0
def set_power_state(state):
    """
    Set the system power state to 'state'.
    """
    utils.write_one_line("/sys/power/state", state)
Esempio n. 10
0
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))