ly.server package

Module contents

A package implementing an HTTP server to process LilyPond input code.


ly.server.command module

The commands that are available to the command line.

class ly.server.command.abs2rel[source]

Bases: ly.server.command._edit_command

convert absolute music to relative

edit(opts, cursor)[source]
class ly.server.command.highlight[source]

Bases: ly.server.command._export_command

convert source to syntax colored HTML.

export(opts, cursor, exports)[source]
class ly.server.command.indent[source]

Bases: ly.server.command._edit_command

run the indenter

edit(opts, cursor)[source]

Get a ly.indent.Indenter initialized with our options.

class ly.server.command.language[source]

Bases: ly.server.command._info_command

retrieve language from document

class ly.server.command.mode[source]

Bases: ly.server.command._info_command

retrieve mode from document

class ly.server.command.musicxml[source]

Bases: ly.server.command._export_command

convert source to MusicXML

export(opts, cursor, exports)[source]
class ly.server.command.reformat[source]

Bases: ly.server.command.indent

reformat the document

edit(opts, cursor)[source]
class ly.server.command.rel2abs[source]

Bases: ly.server.command._edit_command

convert relative music to absolute

edit(opts, cursor)[source]
class ly.server.command.set_variable(arg)[source]

Bases: ly.server.command._command

set a configuration variable to a value

run(opts, data)[source]
class ly.server.command.translate(language)[source]

Bases: ly.server.command._edit_command

translate pitch names

edit(opts, cursor)[source]
class ly.server.command.transpose(arg)[source]

Bases: ly.server.command._edit_command

transpose music

edit(opts, cursor)[source]
class ly.server.command.version[source]

Bases: ly.server.command._info_command

retrieve version from document


ly.server.handler module

HTTP request handler

class ly.server.handler.RequestHandler(request, client_address, server)[source]

Bases: BaseHTTPServer.BaseHTTPRequestHandler


Parse one command from the JSON data, plus optionally some commands to set variables. Returns an array with command._command instances. Raises exceptions upon faulty data.


A POST request is expected to contain the task to be executed as a JSON object in the request body. The POST handler (currently) ignores the URL.


Configure the action(s) to be taken, based on the JSON object. Raise errors when the JSON object can’t be properly understood. Run the commands and return a string (from cursor.text() ).


Instantiate a copy of the default options and update with the given opts


Returns the message body parsed to a dictionary from JSON data. Raises - RuntimeWarning when no JSON data is present - ValueError when JSON parsing fails

ly.server.main module

The entry point for the ‘ly-server’ command.


Exit with message to STDERR. In ly-server this should only be called upon startup, not while processing requests. Then the error should be sent back to the client.


Returns a two-tuple(server_opts, cmd_opts)

server_opts is a ServerOptions instance configuring the server behaviour cmd_opts is an Options instance with default options for future command executions triggered by HTTP requests.

Also performs error handling and may exit on certain circumstances.


Print usage info.


Print short usage info.


Print version info.

ly.server.options module

Options configuring the commands’ behaviour

class ly.server.options.Options[source]

Bases: object

Store all the startup options and their defaults.

set_variable(name, value)[source]
class ly.server.options.ServerOptions[source]

Bases: object

Options configuring the server itself, not the individual commands