Skip to main content

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

Project description

mopidy-debugrel

PyPI - Version GitHub Actions Workflow Status Codecov

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.

  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

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 in release.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

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-0.1.0.tar.gz (9.8 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-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

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

Hashes for mopidy_debugrel-0.1.0.tar.gz
Algorithm Hash digest
SHA256 90f85030909b424bbf82bd514f7249363064e3e4504f88351d77481cc18de70c
MD5 06a02ccebcdbd7bc6ba698bab1f9fed5
BLAKE2b-256 a8fda9887aead4e0edcf74d2172284e8afe4c162dcff9a25ffc2bcbffbc6f994

See more details on using hashes here.

Provenance

The following attestation bundles were made for mopidy_debugrel-0.1.0.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-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mopidy_debugrel-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9738285ace1ac8042ce4df4bcc78b4cb1e8baf2a66f3059fa0bc5841a99f2160
MD5 1c6c83e4ab3f74d8d48290a4bb87c1c1
BLAKE2b-256 d52fd4c02c990a5cbcac1ec8ea8835e1c7fa965304dd1368a7fefcf226bdd21c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mopidy_debugrel-0.1.0-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