# nobodd.server

This module contains the server and handler classes which make up the main nobodd-tftpd application, as well as the entry point for the application itself.

## Handler classes

class nobodd.server.BootHandler(request, client_address, server)

  A descendent of `TFTPBaseHandler` that resolves paths relative to the FAT file-system in the OS image associated with the Pi serial number which forms the initial directory.

  resolve_path(filename)

    Resolves filename relative to the OS image associated with the initial directory.

    In other words, if the request is for `1234abcd/config.txt`, the handler will look up the board with serial number `1234abcd` in `BootServer.boards`, find the associated OS image, the FAT file-system within that image, and resolve `config.txt` within that file-system.

## Server classes

class nobodd.server.BootServer(server_address, boards)

  A descendent of `TFTPBaseServer` that is configured with boards, a mapping of Pi serial numbers to `Board` instances, and uses `BootHandler` as the handler class.

  boards

    The mapping of Pi serial numbers to `Board` instances.

  server_close()

    Called to clean-up the server.

    May be overridden.

## Application functions

nobodd.server.main(args=None)

  The main entry point for the nobodd-tftpd application. Takes args, the sequence of command line arguments to parse. Returns the exit code of the application (0 for a normal exit, and non-zero otherwise).

  If `DEBUG=1` is found in the application’s environment, top-level exceptions will be printed with a full back-trace. `DEBUG=2` will launch PDB in post-mortem mode.

nobodd.server.request_loop(server_address, boards)

  The application’s request loop. Takes the server_address to bind to, which may be a `(address, port)` tuple, or an `int` file-descriptor passed by a service manager, and the boards configuration, a `dict` mapping serial numbers to `Board` instances.

  Raises `ReloadRequest` or `TerminateRequest` in response to certain signals, but is an infinite loop otherwise.

nobodd.server.get_parser()

  Returns the command line parser for the application, pre-configured with defaults from the application’s configuration file(s). See `ConfigArgumentParser()` for more information.

## Exceptions

exception nobodd.server.ReloadRequest

  Exception class raised in `request_loop()` to cause a reload. Handled in `main()`.

exception nobodd.server.TerminateRequest(returncode, message='')

  Exception class raised in `request_loop()` to cause service termination. Handled in `main()`. Takes the return code of the application as the first argument.