Skip to main content

Mopidy extension that provides a debugging Read-Eval loop over http

Project description

mopidy-debugrel

PyPI - Version

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.

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
# Adapt enabled_until to your needs
enabled_until = 2025-05-01

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.

  1. 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=()>]
  1. 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)
  1. 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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mopidy_debugrel-1.0.1.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mopidy_debugrel-1.0.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file mopidy_debugrel-1.0.1.tar.gz.

File metadata

  • Download URL: mopidy_debugrel-1.0.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mopidy_debugrel-1.0.1.tar.gz
Algorithm Hash digest
SHA256 95b2b4f175ea378eafdae2089fe434ed9f7ef13df7caf0ea0670bdab320602a7
MD5 60fa0c87ea60133c48bd64f27329d979
BLAKE2b-256 7a41e348e20f6bb99acd273e826f7ce29cb43616715d561243cdc356eb51f020

See more details on using hashes here.

Provenance

The following attestation bundles were made for mopidy_debugrel-1.0.1.tar.gz:

Publisher: release.yml on sapristi/mopidy-debugrel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mopidy_debugrel-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mopidy_debugrel-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 78056719c620cb536df092215ec7155aad0cc04a2eee83646012262a5571d58d
MD5 87cca6a4bef89480f26a94fef8f5f0fb
BLAKE2b-256 161c1aa9f15612d8936bb5aaa3bd0bf4cae17a0a1786b82d72f5a87ff2b1345d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mopidy_debugrel-1.0.1-py3-none-any.whl:

Publisher: release.yml on sapristi/mopidy-debugrel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page