Mopidy extension that provides a debugging Read-Eval loop over http
Project description
mopidy-debugrel
Mopidy extension that provides a Read-Eval loop over http, for debugging purpose.
Warning: enabling this extension leaves your server vulnerable, make sure mopidy is not exposed to the web when enabling it, and disable it when you are done.
TODO: add a enable_until configuration, to ensure
Installation
Install by running:
python3 -m pip install mopidy-debugrel
See https://mopidy.com/ext/debugrel/ for alternative installation methods.
Configuration
This extension is disabled by default. To enable it, add the following to your mopidy configuration file:
[debugrel]
enabled = true
Usage
Overview
This extension exposes a single API endpoint, that will execute the python code that you pass in your request. For example:
import requests
MOPIDY_HOST = "localhost"
MOPIDY_PORT = "6680"
code = """
logger.info("hello")
"""
requests.post(f"http://{MOPIDY_HOST}:{MOPIDY_PORT}/debugrel/debug", json={"source": code})
Running this trigger the execution of code in mopidy, resulting in the following logs:
mopidy[1771]: INFO 2025-02-23 14:39:29,689 [1771:HttpServer] mopidy_debugrel
mopidy[1771]: hello
In the context of execution, you can access mopidy config with self.config, and mopidy core with self.core
Examples
Some examples of code that you can use.
- Access the backends
code = """
logger.info(self.core.backends.get())
"""
requests.post(f"http://{MOPIDY_HOST}:{MOPIDY_PORT}/debugrel/debug", json={"source": code})
Logs:
mopidy[1771]: INFO 2025-02-23 14:55:59,966 [1771:HttpServer] mopidy_debugrel
mopidy[1771]: [<ActorProxy for FileBackend (urn:uuid:55234968-8840-4618-8bdb-f990c084fcac), attr_path=()>, <ActorProxy for M3UBackend (urn:uuid:eb60e9fe-5db9-4d8f-8444-d586aaae8573), attr_path=()>, <ActorProxy for StreamBackend (urn:uuid:1050cc10-6178-4820-aaf8-d4ab14cec939), attr_path=()>, <ActorProxy for BookmarksBackend (urn:uuid:ade7e4bd-2130-421e-9c98-aadeeaa77863), attr_path=()>, <ActorProxy for TidalBackend (urn:uuid:6cbdb63d-b5a5-4bc5-8ceb-7511457ac98a), attr_path=()>]
- Instantiate a tidal backend
code = """
from mopidy_tidal.backend import TidalBackend
backend = TidalBackend(self.config, None)
logger.info(backend)
"""
requests.post("http://gidouille.local:6680/debugrel/debug", json={"source": code}) ```
Logs:
mopidy[1771]: INFO 2025-02-23 14:54:53,030 [1771:HttpServer] mopidy_debugrel
mopidy[1771]: TidalBackend (urn:uuid:b496ce6c-d856-4e37-939f-f311d067892d)
- Print config entries:
code = """
for key, value in self.config.items():
logger.info(f"{key}: {value}")
"""
requests.post("http://gidouille.local:6680/debugrel/debug", json={"source": code}) ```
Project resources
Development
Set up development environment
Clone the repo using, e.g. using gh:
gh repo clone sapristi/mopidy-debugrel
Enter the directory, and install dependencies using uv:
cd mopidy-debugrel/
uv sync
Setup before first release
Before the first release, you must enable trusted publishing on
PyPI
so that the release.yml GitHub Action can create the PyPI project and publish
releases to PyPI.
When following the instructions linked above, use the following values in the form at PyPI:
- Publisher: GitHub
- PyPI project name:
mopidy-debugrel - Owner:
sapristi - Repository name:
mopidy-debugrel - Workflow name:
release.yml - Environment name:
pypi(must match environment name inrelease.yml)
Making a release
To make a release to PyPI, go to the project's GitHub releases page and click the "Draft a new release" button.
In the "choose a tag" dropdown, select the tag you want to release or create a
new tag, e.g. v0.1.0. Add a title, e.g. v0.1.0, and a description of the changes.
Decide if the release is a pre-release (alpha, beta, or release candidate) or should be marked as the latest release, and click "Publish release".
Once the releease is created, the release.yml GitHub Action will automatically
build and publish the release to
PyPI.
Credits
- Original author: Mathias Millet
- Current maintainer: Mathias Millet
- Contributors
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mopidy_debugrel-0.1.0.tar.gz.
File metadata
- Download URL: mopidy_debugrel-0.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90f85030909b424bbf82bd514f7249363064e3e4504f88351d77481cc18de70c
|
|
| MD5 |
06a02ccebcdbd7bc6ba698bab1f9fed5
|
|
| BLAKE2b-256 |
a8fda9887aead4e0edcf74d2172284e8afe4c162dcff9a25ffc2bcbffbc6f994
|
Provenance
The following attestation bundles were made for mopidy_debugrel-0.1.0.tar.gz:
Publisher:
release.yml on sapristi/mopidy-debugrel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mopidy_debugrel-0.1.0.tar.gz -
Subject digest:
90f85030909b424bbf82bd514f7249363064e3e4504f88351d77481cc18de70c - Sigstore transparency entry: 173603331
- Sigstore integration time:
-
Permalink:
sapristi/mopidy-debugrel@27dd6c93ca15771fe06df6b7b8a2f3289061de22 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sapristi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@27dd6c93ca15771fe06df6b7b8a2f3289061de22 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mopidy_debugrel-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mopidy_debugrel-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9738285ace1ac8042ce4df4bcc78b4cb1e8baf2a66f3059fa0bc5841a99f2160
|
|
| MD5 |
1c6c83e4ab3f74d8d48290a4bb87c1c1
|
|
| BLAKE2b-256 |
d52fd4c02c990a5cbcac1ec8ea8835e1c7fa965304dd1368a7fefcf226bdd21c
|
Provenance
The following attestation bundles were made for mopidy_debugrel-0.1.0-py3-none-any.whl:
Publisher:
release.yml on sapristi/mopidy-debugrel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mopidy_debugrel-0.1.0-py3-none-any.whl -
Subject digest:
9738285ace1ac8042ce4df4bcc78b4cb1e8baf2a66f3059fa0bc5841a99f2160 - Sigstore transparency entry: 173603333
- Sigstore integration time:
-
Permalink:
sapristi/mopidy-debugrel@27dd6c93ca15771fe06df6b7b8a2f3289061de22 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sapristi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@27dd6c93ca15771fe06df6b7b8a2f3289061de22 -
Trigger Event:
release
-
Statement type: