mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Lint fixes
This commit is contained in:
parent
899ba78e79
commit
30d8be877d
@ -31,7 +31,7 @@ def __virtual__():
|
||||
|
||||
def _get_current_scheme():
|
||||
cmd = "powercfg /getactivescheme"
|
||||
out = __salt__['cmd.run'](cmd, python_shell=False)
|
||||
out = __salt__['cmd.run'](cmd, python_shell=False)
|
||||
matches = re.search(r"GUID: (.*) \(", out)
|
||||
return matches.groups()[0].strip()
|
||||
|
||||
@ -42,7 +42,7 @@ def _get_powercfg_minute_values(scheme, guid, subguid):
|
||||
'''
|
||||
cmd = "powercfg /q {0} {1} {2}".format(scheme, guid, subguid)
|
||||
out = __salt__['cmd.run'](cmd, python_shell=False)
|
||||
raw_settings = re.findall(r"Power Setting Index: ([0-9a-fx]+)", out)
|
||||
raw_settings = re.findall(r"Power Setting Index: ([0-9a-fx]+)", out)
|
||||
return {"ac": int(raw_settings[0], 0) / 60, "dc": int(raw_settings[1], 0) / 60}
|
||||
|
||||
|
||||
@ -185,5 +185,3 @@ def get_hibernate_timeout():
|
||||
salt '*' powercfg.get_hibernate_timeout
|
||||
'''
|
||||
return _get_powercfg_minute_values(_get_current_scheme(), "SUB_SLEEP", "HIBERNATEIDLE")
|
||||
|
||||
|
||||
|
@ -86,10 +86,10 @@ def set_timeout(name, value, power="ac"):
|
||||
|
||||
values = check_func()
|
||||
if values[power] == value:
|
||||
comment.append ("{0} {1} is already set with the value {2}.".format(name, power, value))
|
||||
comment.append("{0} {1} is already set with the value {2}.".format(name, power, value))
|
||||
else:
|
||||
ret['changes'] = {name: {power: value}}
|
||||
set_func(value, power)
|
||||
|
||||
ret['comment'] = ' '.join(comment)
|
||||
return ret
|
||||
return ret
|
||||
|
@ -21,6 +21,7 @@ ensure_in_syspath('../../')
|
||||
|
||||
powercfg.__salt__ = {}
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class PowerCfgTestCase(TestCase):
|
||||
query_ouput = '''Subgroup GUID: 238c9fa8-0aad-41ed-83f4-97be242c8f20 (Hibernate)
|
||||
@ -64,7 +65,6 @@ class PowerCfgTestCase(TestCase):
|
||||
powercfg.set_standby_timeout(0, "dc")
|
||||
mock.assert_called_once_with('powercfg /x standby-timeout-dc 0', python_shell=False)
|
||||
|
||||
|
||||
def test_set_hibernate_timeout(self):
|
||||
'''
|
||||
Test to make sure we can set the hibernate timeout value
|
||||
@ -74,7 +74,6 @@ class PowerCfgTestCase(TestCase):
|
||||
powercfg.set_hibernate_timeout(0, "dc")
|
||||
mock.assert_called_once_with('powercfg /x hibernate-timeout-dc 0', python_shell=False)
|
||||
|
||||
|
||||
def test_get_monitor_timeout(self):
|
||||
'''
|
||||
Test to make sure we can get the monitor timeout value
|
||||
@ -92,7 +91,6 @@ class PowerCfgTestCase(TestCase):
|
||||
|
||||
self.assertEqual({'ac': 30, 'dc': 15}, ret)
|
||||
|
||||
|
||||
def test_get_disk_timeout(self):
|
||||
'''
|
||||
Test to make sure we can get the disk timeout value
|
||||
|
@ -20,6 +20,7 @@ ensure_in_syspath('../../')
|
||||
|
||||
powercfg.__salt__ = {}
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class PowerCfgTestCase(TestCase):
|
||||
'''
|
||||
@ -54,7 +55,6 @@ class PowerCfgTestCase(TestCase):
|
||||
ret = {'changes': {}, 'comment': 'fakesetting is not a valid setting', 'name': 'fakesetting', 'result': False}
|
||||
self.assertEqual(powercfg.set_timeout("fakesetting", 0), ret)
|
||||
|
||||
|
||||
def test_fail_invalid_power(self):
|
||||
'''
|
||||
Test to make sure we can set the monitor timeout value
|
||||
|
Loading…
Reference in New Issue
Block a user