Updater improvements to send option component information (#7720)
* Setup to send component data is option is enabled * testcases, as well as moved to a single boolean, passed to the function * fixed pep8 failures * Clarify config option.
This commit is contained in:
parent
a119bd0056
commit
437ddb8dea
2 changed files with 40 additions and 10 deletions
|
@ -32,6 +32,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
ATTR_RELEASE_NOTES = 'release_notes'
|
||||
|
||||
CONF_REPORTING = 'reporting'
|
||||
CONF_COMPONENT_REPORTING = 'include_used_components'
|
||||
|
||||
DOMAIN = 'updater'
|
||||
|
||||
|
@ -41,7 +42,8 @@ UPDATER_URL = 'https://updater.home-assistant.io/'
|
|||
UPDATER_UUID_FILE = '.uuid'
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({DOMAIN: {
|
||||
vol.Optional(CONF_REPORTING, default=True): cv.boolean
|
||||
vol.Optional(CONF_REPORTING, default=True): cv.boolean,
|
||||
vol.Optional(CONF_COMPONENT_REPORTING, default=False): cv.boolean,
|
||||
}}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
RESPONSE_SCHEMA = vol.Schema({
|
||||
|
@ -83,10 +85,13 @@ def async_setup(hass, config):
|
|||
else:
|
||||
huuid = None
|
||||
|
||||
include_components = config.get(CONF_COMPONENT_REPORTING)
|
||||
|
||||
@asyncio.coroutine
|
||||
def check_new_version(now):
|
||||
"""Check if a new version is available and report if one is."""
|
||||
result = yield from get_newest_version(hass, huuid)
|
||||
result = yield from get_newest_version(hass, huuid,
|
||||
include_components)
|
||||
|
||||
if result is None:
|
||||
return
|
||||
|
@ -116,7 +121,7 @@ def async_setup(hass, config):
|
|||
|
||||
|
||||
@asyncio.coroutine
|
||||
def get_system_info(hass):
|
||||
def get_system_info(hass, include_components):
|
||||
"""Return info about the system."""
|
||||
info_object = {
|
||||
'arch': platform.machine(),
|
||||
|
@ -129,6 +134,9 @@ def get_system_info(hass):
|
|||
'virtualenv': os.environ.get('VIRTUAL_ENV') is not None,
|
||||
}
|
||||
|
||||
if include_components:
|
||||
info_object['components'] = list(hass.config.components)
|
||||
|
||||
if platform.system() == 'Windows':
|
||||
info_object['os_version'] = platform.win32_ver()[0]
|
||||
elif platform.system() == 'Darwin':
|
||||
|
@ -147,10 +155,10 @@ def get_system_info(hass):
|
|||
|
||||
|
||||
@asyncio.coroutine
|
||||
def get_newest_version(hass, huuid):
|
||||
def get_newest_version(hass, huuid, include_components):
|
||||
"""Get the newest Home Assistant version."""
|
||||
if huuid:
|
||||
info_object = yield from get_system_info(hass)
|
||||
info_object = yield from get_system_info(hass, include_components)
|
||||
info_object['huuid'] = huuid
|
||||
else:
|
||||
info_object = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue