als.io package

Submodules

als.io.input module

Provides everything need to handle ALS main inputs : images.

We need to read file and in the future, get images from INDI

class als.io.input.FolderScanner[source]

Bases: watchdog.events.FileSystemEventHandler, als.io.input.InputScanner, PyQt5.QtCore.QObject

Watches file changes (creation, move) in a specific filesystem folder

the watched directory is retrieved from user config on scanner startup

on_created(event)[source]

Called when a file or directory is created.

Parameters

event (DirCreatedEvent or FileCreatedEvent) – Event representing file/directory creation.

on_moved(event)[source]

Called when a file or a directory is moved or renamed.

Parameters

event (DirMovedEvent or FileMovedEvent) – Event representing file/directory movement.

start()[source]

Starts scanning scan folder for new files

stop()[source]

Stops scanning scan folder for new files

exception als.io.input.InputError[source]

Bases: Exception

Base class for all Exception subclasses in this module

class als.io.input.InputScanner[source]

Bases: object

Base abstract class for all code responsible of ALS “image acquisition”.

Subclasses are responsible for :

  • replying to start & stop commands

  • reading images from actual source

  • creating Image objects

  • broadcasting every new image

broadcast_image(image: als.model.base.Image)[source]

Send a signal with newly read image to anyone who cares

Parameters

image (Image) – the new image

static create_scanner(scanner_type: str = 'FS')[source]

Factory for image scanners.

Parameters

scanner_type (str.) –

the type of scanner to create. Accepted values are :

  • ”FS” for a filesystem scanner

Returns

the right scanner implementation

Return type

InputScanner subclass

new_image_signal

Qt signal emitted when a new image is read by scanner

abstract start()[source]

Starts checking for new images

Raises

ScannerStartError if startup fails

abstract stop()[source]

Stops checking for new images

exception als.io.input.ScannerStartError[source]

Bases: als.io.input.InputError

Raised when folder scanner start is in error.

als.io.input.read_disk_image(path: pathlib.Path)[source]

Reads an image from disk

Parameters

path (pathlib.Path) – path to the file to load image from

Returns

the image read from disk or None if image is ignored or an error occurred

Return type

Image or None

als.io.network module

Provide networking features

class als.io.network.HTTPHandler(request, client_address, server)[source]

Bases: http.server.SimpleHTTPRequestHandler

This handler uses server.base_path instead of always using os.getcwd()

translate_path(path)[source]

Translate a /-separated PATH to the local filename syntax.

Components that mean special things to the local file system (e.g. drive or directory names) are ignored. (XXX They should probably be diagnosed.)

class als.io.network.HTTPServer(base_path, server_address, request_handler_class=<class 'als.io.network.HTTPHandler'>)[source]

Bases: http.server.HTTPServer

The main server, you pass in base_path which is the path you want to serve requests from

class als.io.network.WebServer(web_dir)[source]

Bases: threading.Thread

Thread class with a stop() method.

The thread itself has to check regularly for the stopped() condition.

serve()[source]

Continuously handles incomming HTTP requests.

stop()[source]

Stops the web server.

stopped()[source]

Checks if server is stopped.

Returns

True if server is stopped, False otherwise

als.io.network.get_ip()[source]

Retrieves machine’s IP address.

Returns

IP address

Return type

str

als.io.output module

Everything we need to perform outputs from ALS

For now, we only save some images to disk, but who knows…

class als.io.output.ImageSaver(save_queue: als.code_utilities.SignalingQueue)[source]

Bases: als.processing.QueueConsumer

Saves images according to commands posted to IMAGE_SAVE_QUEUE in its own thread

Module contents

Everything related to I/O in ALS