ly.server package

Module contents

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

Submodules

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]

Should edit the cursor in-place.

class ly.server.command.highlight[source]

Bases: ly.server.command._export_command

convert source to syntax colored HTML.

export(opts, cursor, exports)[source]

Should return the converted document as string.

class ly.server.command.indent[source]

Bases: ly.server.command._edit_command

run the indenter

edit(opts, cursor)[source]

Should edit the cursor in-place.

indenter(opts)[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

get_info(info)[source]

Should return the desired information from the docinfo object.

class ly.server.command.mode[source]

Bases: ly.server.command._info_command

retrieve mode from document

get_info(info)[source]

Should return the desired information from the docinfo object.

class ly.server.command.musicxml[source]

Bases: ly.server.command._export_command

convert source to MusicXML

export(opts, cursor, exports)[source]

Should return the converted document as string.

class ly.server.command.reformat[source]

Bases: ly.server.command.indent

reformat the document

edit(opts, cursor)[source]

Should edit the cursor in-place.

class ly.server.command.rel2abs[source]

Bases: ly.server.command._edit_command

convert relative music to absolute

edit(opts, cursor)[source]

Should edit the cursor in-place.

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]

Should edit the cursor in-place.

class ly.server.command.transpose(arg)[source]

Bases: ly.server.command._edit_command

transpose music

edit(opts, cursor)[source]

Should edit the cursor in-place.

class ly.server.command.version[source]

Bases: ly.server.command._info_command

retrieve version from document

get_info(info)[source]

Should return the desired information from the docinfo object.

ly.server.handler module

HTTP request handler

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

Bases: http.server.BaseHTTPRequestHandler

create_command(cmd)[source]

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.

do_POST()[source]

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.

process_json_request(request)[source]

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() ).

process_options(opts)[source]

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

read_json_request()[source]

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.

ly.server.main.die(message)[source]

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.

ly.server.main.main()[source]
ly.server.main.parse_command_line()[source]

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.

ly.server.main.usage()[source]

Print usage info.

ly.server.main.usage_short()[source]

Print short usage info.

ly.server.main.version()[source]

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