Skip to content

Commit b44f6c4

Browse files
committed
Revert "Add functionality and documentation for debug mode"
This reverts commit cd8e6c4.
1 parent cd8e6c4 commit b44f6c4

File tree

2 files changed

+3
-68
lines changed

2 files changed

+3
-68
lines changed

README.md

+1-53
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ The following commands are required, which are the same as the Stream Deck softw
157157

158158
- `-info`: Additional information (formatted as json) about the plugin environment, as provided by the Stream Deck software.
159159

160-
There are also two additional options for specifying action scripts to load. Note that you can't use both of these options together, and the Stream Deck software doesn't pass in these options.
160+
There are also two additional options for specifying action scripts to load. Note that you can't use both of these options together, and the Stream Deck software doesn't pass in these options.
161161

162162
- Plugin Directory: Pass the directory containing the plugin files as a positional argument:
163163

@@ -172,58 +172,6 @@ There are also two additional options for specifying action scripts to load. Not
172172
streamdeck --action-scripts actions1.py actions2.py
173173
```
174174

175-
In addition to these, there is an additional option to use debug mode, which is discussed below.
176-
177-
#### Debugging
178-
179-
The SDK supports remote debugging capabilities, allowing you to attach a debugger after the plugin has started. This is particularly useful since Stream Deck plugins run as separate processes.
180-
181-
To enable debug mode, pass in the option `--debug {debug port number}`, which tells the plugin to wait for a debugger to attach on that port number.
182-
183-
```bash
184-
streamdeck --debug 5675
185-
```
186-
187-
When running in debug mode, the plugin will pause for 10 seconds after initialization, giving you time to attach your debugger. You'll see a message in the logs indicating that the plugin is waiting for a debugger to attach.
188-
189-
If things get messy, and you have a prior instance already listening to that port, you should kill the process with something like the following command:
190-
191-
```bash
192-
kill $(lsof -t -i:$DEBUG_PORT)
193-
```
194-
195-
#### Debugging with VS Code
196-
197-
1. Create a launch configuration in `.vscode/launch.json`:
198-
199-
```json
200-
{
201-
"version": "0.2.0",
202-
"configurations": [
203-
{
204-
"name": "Python: Attach to Stream Deck Plugin",
205-
"type": "debugpy",
206-
"request": "attach",
207-
"connect": {
208-
"host": "localhost",
209-
"port": 5678
210-
}
211-
"pathMappings": [
212-
{
213-
"localRoot": "${workspaceFolder}",
214-
"remoteRoot": "."
215-
}
216-
],
217-
"justMyCode": false,
218-
}
219-
]
220-
}
221-
```
222-
223-
2. Start your plugin with debugging enabled
224-
3. When you see the "waiting for debugger" message, use VS Code's Run and Debug view to attach using the configuration above
225-
4. Set breakpoints and debug as normal
226-
227175

228176
#### Configuration
229177

streamdeck/__main__.py

+2-15
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
import logging
33
import sys
44
from pathlib import Path
5-
from typing import Annotated, Optional
5+
from typing import Annotated, Union
66

7-
import debugpy
87
import typer
98

109
from streamdeck.manager import PluginManager
@@ -19,23 +18,14 @@
1918
plugin = typer.Typer()
2019

2120

22-
def setup_debug_mode(debug_port: int) -> None:
23-
"""Setup the debug mode for the plugin and wait for the debugger to attach."""
24-
debugpy.listen(debug_port)
25-
logger.info("Starting in debug mode. Waiting for debugger to attach on port %d...", debug_port)
26-
debugpy.wait_for_client()
27-
logger.info("Debugger attached.")
28-
29-
3021
@plugin.command()
3122
def main(
3223
port: Annotated[int, typer.Option("-p", "-port")],
3324
plugin_registration_uuid: Annotated[str, typer.Option("-pluginUUID")],
3425
register_event: Annotated[str, typer.Option("-registerEvent")],
3526
info: Annotated[str, typer.Option("-info")],
3627
plugin_dir: Annotated[Path, typer.Option(file_okay=False, exists=True, readable=True)] = Path.cwd(), # noqa: B008
37-
action_scripts: Optional[list[str]] = None, # noqa: UP007
38-
debug_port: Annotated[Optional[int], typer.Option("--debug", "-d")] = None, # noqa: UP007
28+
action_scripts: Union[list[str], None] = None, # noqa: UP007
3929
) -> None:
4030
"""Start the Stream Deck plugin with the given configuration.
4131
@@ -53,9 +43,6 @@ def main(
5343
# a child logger with `logging.getLogger("streamdeck.mycomponent")`, all with the same handler/formatter configuration.
5444
configure_streamdeck_logger(name="streamdeck", plugin_uuid=plugin_uuid)
5545

56-
if debug_port:
57-
setup_debug_mode(debug_port)
58-
5946
pyproject = PyProjectConfigs.validate_from_toml_file(plugin_dir / "pyproject.toml", action_scripts=action_scripts)
6047
actions = pyproject.streamdeck_plugin_actions
6148

0 commit comments

Comments
 (0)