libvdat – Stuff that isn’t GUI

Logging

Deal with loggers

vdat.libvdat.loggers.setup_main_logger(conf, name=u'logger')[source]

Setup the main vdat logger.

Add to the logger called name a standard output and a file logger

Parameters:

conf : ConfigParser instance

configuration options,

vdat.libvdat.loggers.make_logger(logger, conf=None, section=None)[source]

Create a handler using the instructions in the configuration section and add it to the logger.

It looks for the following options:

  • remove_old: if True remove all the previous handlers before adding the new one, default False
  • remove_std: if True remove all the previous StreamHandler`, default False
  • the ones used by make_handler()
Parameters:

logger : Logger instance

logger

conf : ConfigParser instance, optional

configuration options, if None use the default VDAT configuration object

section : string, default

name of the section containing the information to build the logger; defaults to logging.name, where name is the logger name

vdat.libvdat.loggers.astropy_handlers(conf)[source]

Tweak the astropy logger removing the existing (stream) handlers and setting a new one if required

Parameters:

conf : ConfigParser instance

configuration options,

vdat.libvdat.loggers.ginga_handlers(conf)[source]

Create/update the ginga logger removing existing handlers setting a new one if required

Parameters:

conf : ConfigParser instance

configuration options,

vdat.libvdat.loggers.cure_logger(name)[source]

Get the logger with name. The first time this function is called with a name, the logger writing to a file in the log directory and called name.log is created

Parameters:

name : string

name of the logger

Returns:

logging.Logger instance

string

name of the file where the logs are saved

Todo

redo it when finishing the implementation of the command interpreter

vdat.libvdat.loggers.setup_command_loggers()[source]

Set up the loggers for the commands connected or connectible to buttons

vdat.libvdat.loggers.conf_to_dict(conf, section, from_parent=[u'logdir', u'logger_level'])[source]

Extract the section and convert it to a dictionary.

If from_parent is a non empty list, it will get the name of the parent section, e.g. if section=logging.main.stdout, the parent section is logging. Then if any element in from_parent doesn’t exist in section, it tries to get to from the parent section. If it doesn’t exist there, it’s skipped.

Parameters:

conf : ConfigParser instance

configuration options,

section : string

name of the section in the configuration where to find all the info

Returns:

dict

vdat.libvdat.loggers.make_handler(conf)[source]

Create a handler following the instructions contained in section

It looks for the following options:

  • enabled: if False, doesn’t create a logger and returns None; default False
  • file_name: if not found, a StreamHandler is created, if exists, a FileHandler is created
  • logdir: directory where the log file goes; default ‘.’
  • format: formatting of the message, default %(levelname)s: %(message)s
  • level: level of the handler, default INFO
Parameters:

conf : dict

configuration options for the handler; it can be created using conf_to_dict()

Returns:

None, if enabled is False

StreamHandler: if not file name is given

FileHandler: otherwise

vdat.libvdat.loggers._to_log_level(level, default=20)[source]

Try to convert level to int or to extract the level level from the logging module. If both fail, return the default.

See here for more info about logging levels.

Parameters:

level : string

numerical or literal value of the level

Returns:

int

handler level

Background

Enqueue commands coming from users pushing buttons on the gui

class vdat.libvdat.callback.Worker(parent=None)[source]

Generic worker that runs the given function

run(func)[source]

Run the given function: it doesn’t have any argument

class vdat.libvdat.callback.Callback[source]

Class to deal with the user pushing buttons in the GUI. Causes the buttons to add commands to a queue, specified by the set_queue command.

Attributes

queue (vdat.gui.queue.Queue object) the queue the callback interacts with
queue = None
classmethod set_queue(queue)[source]

Set the queue that the callbacks post jobs too.

Parameters:

queue : vdat.gui.queue Queue object

the queue the callback interacts with

static make_callback_function(name, alias)[source]

Factory function, used to generate functions to attach to objects.

Parameters:

name : String

name of function to run on button click. Has to be in libvdat. Syntax is:

package_name:function_name

alias : String

a label for the job on the queue GUI.

immediate : bool (optional)

bypass the usual queue and run immediately