ase.logging

Utility functions for configuring logging.

Copyright (c) 2015-2018, Garth Zeglin. All rights reserved. Licensed under the terms of the BSD 3-clause license.

ase.logging.add_logging_arguments(parser)[source]

Add default logging control arguments to an argparse parser.

ase.logging.create_script_logger(scriptname, args)[source]

Create a top-level logger and a list of logging handlers specified by conventional command-line arguments.

Parameters:args – a Namespace returned by argparse
Returns:(logger, handlers) - a top-level logger and a list of handlers to add to other loggers

ase.events

Common event processing code for performance scripts.

Copyright (c) 2017-2018, Garth Zeglin. All rights reserved. Licensed under the terms of the BSD 3-clause license.

Scripted performances are easiest to understand when written as single-threaded scripts with normal subroutine and branching structure. In this context, continuing to service I/O while blocking or sleeping can be achieved by running an I/O event loop while blocking. These utility routines provide facilities for this.

ase.events.sleep(delay=0.0, transports=None)[source]

Sleep for a given interval while processing any data received on transports.

Parameters:
  • delay – time in seconds to poll before returning. Default: zero.
  • transports – list of transport objects. Each must implement fileno() and wait_for_data(). Default: None.
ase.events.wait_for_condition(predicate, transports=[])[source]

Wait until a callable predicate has returned true while processing any data received on transports. Note that this will block until data is received, so this only makes sense if the condition depends on received data.

ase.events.wait_for_keyboard_input(transports=[])[source]

Wait until a line of text has been entered on the keyboard while processing any data received on transports.

ase.events.wait_for_motion_completion(transports, protocols=None)[source]

Wait until all protocols report their motion is complete while processing any data received on transports. This uses an informal protocol in which protocols implement send_get_moving_state(callback).

Parameters:
  • transports – list of transports to monitor
  • protocols – optional list of protocols on which to wait. If None, all protocols attached to the transports are queried.

ase.SerialTransport

Encapsulating a pySerial object as a transport class.

Copyright (c) 2015-2018, Garth Zeglin. All rights reserved. Licensed under the terms of the BSD 3-clause license.

class ase.SerialTransport.SerialTransport(protocol, portname, rate=57600)[source]

Manage a serial port as a bidirectional transport which passes along received data to a Protocol object, and can pass along write requests to the underlying port.

Parameters:
  • protocol – object to received streamed data and generate messages
  • portname – string naming the serial device
  • rate – standard integer baud rate for communication. Default is 57600.
close()[source]

Shut down the serial connection to the Arduino, after which this object may no longer be used.

fileno()[source]
flush()[source]
flush_input()[source]
logger = None

logging object for controlling or capturing an event log

open()[source]

Open the serial port and initialize communications.

wait_for_data()[source]

Wait for at least one character of input from the serial port and process it, updating status variables. This will block if data is not ready; if using in an event-driven system, it is important to check the port for available data prior to calling.

write(data)[source]
ase.SerialTransport.print_serial_port_list()[source]