pyserv package

Submodules

Module contents

Simple HTTP server classes with GET path rewriting and request/header logging. Now includes a reference WSGI server and tftpdaemon script.

class pyserv.GetHandler(*args, directory=None, **kwargs)[source]

Bases: SimpleHTTPRequestHandler

Munge the incoming request path from Dialog OTA. Runs urlparse on the url and updates the GET handler path. We also log the result.

Parameters:

SimpleHTTPRequestHandler – imported from http.server

do_GET()[source]

Serve a GET request.

log_message(format, *args)[source]

We need a custom log handler, otherwise Get message goes to sys.stdout only.

class pyserv.GetServer(iface, port, directory)[source]

Bases: Thread

Threaded wrapper class for custom ThreadingHTTPServer instance.

Usage:

s = GetServer('', 8080)
s.start()
s.stop()
run()[source]

Start main server thread

stop()[source]

Stop main server thread

class pyserv.GetServerWSGI(flask_app, port, is_flask=False, validate=False)[source]

Bases: Thread

Threaded wrapper class for custom flask WSGIServer instance.

Usage:

s = GetServerWSGI(my_app, 8080, is_flask=True, validate=False)
s.start()
s.stop()
run()[source]

Start main server thread

stop()[source]

Stop main server thread

pyserv.munge_url(ota_url)[source]

Parse the url sent by OTA command for file path and host string.

Parameters:

ota_url – (possibly) broken GET path

Return tuple:

netloc and path from urlparse