mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge pull request #37384 from rallytime/merge-2016.11
[2016.11] Merge forward from carbon to 2016.11
This commit is contained in:
commit
ba1e6cd1a6
@ -4,7 +4,9 @@ Module for editing power settings on Mac OS X
|
||||
|
||||
.. versionadded:: 2016.3.0
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import time
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
@ -238,7 +240,12 @@ def set_harddisk_sleep(minutes):
|
||||
value = _validate_sleep(minutes)
|
||||
cmd = 'systemsetup -setharddisksleep {0}'.format(value)
|
||||
salt.utils.mac_utils.execute_return_success(cmd)
|
||||
return str(value) in get_harddisk_sleep()
|
||||
|
||||
# Give macOS some time to change the setting
|
||||
for i in range(5):
|
||||
if str(value) in get_harddisk_sleep():
|
||||
return True
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
def get_wake_on_modem():
|
||||
|
@ -174,6 +174,7 @@ class NamespacedDictWrapper(collections.MutableMapping, dict):
|
||||
if override_name:
|
||||
self.__class__.__module__ = 'salt'
|
||||
self.__class__.__name__ = override_name
|
||||
super(NamespacedDictWrapper, self).__init__(self._dict())
|
||||
|
||||
def _dict(self):
|
||||
r = self.__dict
|
||||
|
@ -5,6 +5,7 @@
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import json
|
||||
import tornado.stack_context
|
||||
import tornado.gen
|
||||
from tornado.testing import AsyncTestCase, gen_test
|
||||
@ -185,3 +186,13 @@ class NamespacedDictWrapperTests(TestCase):
|
||||
self._dict['prefix'] = {'foo': {'bar': 'baz'}}
|
||||
w = NamespacedDictWrapper(self._dict, ('prefix', 'foo'))
|
||||
self.assertEqual(w['bar'], 'baz')
|
||||
|
||||
def test_json_dumps_single_key(self):
|
||||
self._dict['prefix'] = {'foo': {'bar': 'baz'}}
|
||||
w = NamespacedDictWrapper(self._dict, 'prefix')
|
||||
self.assertEqual(json.dumps(w), '{"foo": {"bar": "baz"}}')
|
||||
|
||||
def test_json_dumps_multiple_key(self):
|
||||
self._dict['prefix'] = {'foo': {'bar': 'baz'}}
|
||||
w = NamespacedDictWrapper(self._dict, ('prefix', 'foo'))
|
||||
self.assertEqual(json.dumps(w), '{"bar": "baz"}')
|
||||
|
Loading…
Reference in New Issue
Block a user