New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ptvsd debugger component. #23336
Merged
Merged
Ptvsd debugger component. #23336
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0a10cc3
ptvsd debugger component.
Swamp-Ig 564e564
Add test case
Swamp-Ig 5a3f658
ptvsd as test dependency
Swamp-Ig 5c1fa55
Fix for 3.5
Swamp-Ig 639c1d3
Fixed bootstrap test
Swamp-Ig 056d566
Use dict direct lookup.
Swamp-Ig 66a0bc2
Don't need to load dependencies.
Swamp-Ig 2025ac9
Get the test working.
Swamp-Ig 5fa9055
3.5 fix
Swamp-Ig be566c2
Set mock return value
Swamp-Ig 644e858
Put tests back, but skip them
Swamp-Ig 9f1f3da
Change log level
Swamp-Ig File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" | ||
Enable ptvsd debugger to attach to HA. | ||
|
||
Attach ptvsd debugger by default to port 5678. | ||
""" | ||
|
||
import logging | ||
from threading import Thread | ||
from asyncio import Event | ||
|
||
import voluptuous as vol | ||
|
||
from homeassistant.const import ( | ||
CONF_HOST, CONF_PORT) | ||
import homeassistant.helpers.config_validation as cv | ||
from homeassistant.helpers.typing import ConfigType, HomeAssistantType | ||
|
||
DOMAIN = 'ptvsd' | ||
|
||
CONF_WAIT = 'wait' | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
CONFIG_SCHEMA = vol.Schema({ | ||
DOMAIN: vol.Schema({ | ||
vol.Optional( | ||
CONF_HOST, default='0.0.0.0' | ||
): cv.string, | ||
vol.Optional( | ||
CONF_PORT, default=5678 | ||
): cv.port, | ||
vol.Optional( | ||
CONF_WAIT, default=False | ||
): cv.boolean, | ||
}) | ||
}, extra=vol.ALLOW_EXTRA) | ||
|
||
|
||
async def async_setup(hass: HomeAssistantType, config: ConfigType): | ||
"""Set up ptvsd debugger.""" | ||
import ptvsd | ||
|
||
conf = config[DOMAIN] | ||
host = conf[CONF_HOST] | ||
port = conf[CONF_PORT] | ||
|
||
ptvsd.enable_attach((host, port)) | ||
|
||
wait = conf[CONF_WAIT] | ||
if wait: | ||
_LOGGER.warning("Waiting for ptvsd connection on %s:%s", host, port) | ||
ready = Event() | ||
|
||
def waitfor(): | ||
ptvsd.wait_for_attach() | ||
hass.loop.call_soon_threadsafe(ready.set) | ||
Thread(target=waitfor).start() | ||
|
||
await ready.wait() | ||
else: | ||
_LOGGER.warning("Listening for ptvsd connection on %s:%s", host, port) | ||
|
||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"domain": "ptvsd", | ||
"name": "ptvsd", | ||
"documentation": "https://www.home-assistant.io/components/ptvsd", | ||
"requirements": [ | ||
"ptvsd==4.2.8" | ||
], | ||
"dependencies": [], | ||
"codeowners": ["@swamp-ig"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,7 @@ | |
'pilight', | ||
'pmsensor', | ||
'prometheus_client', | ||
'ptvsd', | ||
'pushbullet.py', | ||
'py-canary', | ||
'pyblackbird', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Tests for PTVSD Debugger""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Tests for PTVSD Debugger.""" | ||
|
||
from unittest.mock import patch | ||
from asynctest import CoroutineMock | ||
|
||
import homeassistant.components.ptvsd as ptvsd_component | ||
from homeassistant.bootstrap import _async_set_up_integrations | ||
|
||
|
||
async def test_ptvsd_bootstrap(hass): | ||
"""Test loading ptvsd component with wait.""" | ||
config = { | ||
ptvsd_component.DOMAIN: { | ||
ptvsd_component.CONF_WAIT: True | ||
} | ||
} | ||
|
||
with patch( | ||
'homeassistant.components.ptvsd.async_setup', | ||
CoroutineMock()) as setup_mock: | ||
await _async_set_up_integrations(hass, config) | ||
|
||
setup_mock.assert_called_once() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this in
info
, in case one of the debuggers block?