vacca.utils module

vacca.utils python module, by srubio@cells.es

vacca.utils contains several methods and classes for:

  • manage environment variables
  • loading config files
  • manipulate Qt color palettes
  • custom Taurus event filters

This file is part of Tango Control System

Environment Variables

Variables can be declared in OS or as Tango.VACCA free properties

VACCA_CONFIG: get_config_file()

The config file to be loaded, it can be absolute path or relative to VACCA_DIR.

e.g. /homelocal/sicilia/applications/vacca/tbl2401.py

VACCA_DIR: wdir(‘path/to/icon’)

The folder were VACCA should be executed, all paths within the application will be relative to it. It includes all custom icons that are not part of the vacca package.

If VACCA_CONFIG is defined, it defaults to the path to config file. At ALBA installations it defaults to the path of vaccagui library. Extra modules or plugins to be imported will be loaded from this directory.

e.g. /homelocal/sicilia/applications/vacca/

VACCA_PATH: vpath(‘path/to/icon’)

Not mandatory, it defaults to the path of vacca library. Used for launchers and default icons of vacca widgets.

e.g. /homelocal/sicilia/lib/python/site-packages/vacca

Classes

MyTaurusComponent

class vacca.utils.MyTaurusComponent(name='test')[source]

EventFilter

class vacca.utils.EventFilter(condition=None)[source]

Generic event filter for taurus

EventCounter

class vacca.utils.EventCounter(condition=None)[source]

Generic event counter for taurus

addCustomPanel2Gui

class vacca.utils.addCustomPanel2Gui(extra_panels=None)[source]

this Class is used to add new panel to existing TaurusGUI with the same Context. Each extra_panel class should have a ‘getPaneldescription’ and getDefaultIcon methods.

Pass a dictionary like this:
EXTRA_PANELS[‘VaccaProperties’] = {
‘class’: vacca.VaccaPropTable, ‘icon’: ‘:/places/network-server.svg’, }

DraggableLabel

class vacca.utils.DraggableLabel(parent=None, text='')[source]

WidgetAcceptDrops

class vacca.utils.WidgetAcceptDrops[source]

Template for Taurus widgets accepting drops, deprecated by fandango.qt.Dropable

dropEvent(event)[source]

reimplemented to support drag&drop of models. See QWidget

Draggable

class vacca.utils.Draggable[source]

Template for Taurus widgets accepting drops, deprecated by fandango.qt.Draggable

mouseMoveEvent(event)[source]

reimplemented to provide drag events

mousePressEvent(event)[source]

reimplemented to provide drag events

OnChangeOrTimeEventFilter

class vacca.utils.OnChangeOrTimeEventFilter[source]

The instances of this class will be callables that can be used as filters of repeated-value events. If the event type is Change or Periodic, it will only pass when its evt_value.value is different from that of the last event received from the same source and type. If evt_value.value is not available in the current event, the whole evt_value is used for comparison and as a future reference. But!, if setMaxDeltaTime is set, then any event that occurred more than Delta Time seconds after the last one will be allowed to pass through the chain.

This is useful to avoid processing repetitive events.

Note that you cannot use this class as a filter: you need to use an instance of it.

Note 2: Use a different instance each time you insert this filter into a different widget unless you really know what you are doing.

Example of usage::
evf = OnChangeOrTimeEventFilter() evf.setDeltaTime(60.) filters = [evf, IGNORE_CONFIG] MyTaurusComponentInstance.setEventFilters(filters,preqt=True) filterEvent(s, t, v, filters)

Functions

wdir

vacca.utils.wdir(s='')[source]

get_shared_data_manager

vacca.utils.get_shared_data_manager()[source]

sdm = get_shared_data_manager() #Qt.qApp.SDM Singletone sdm.connectReader(‘channelName’,objectInstance.method,readOnConnect=False) #Using instantiated object/function instead of names!! sdm.connectWriter(‘SelectedInstrument’,out_hook,’modelChanged’) #’Channel’, object, ‘qt signal name’

get_White_palette

vacca.utils.get_White_palette(palette=None)[source]

get_solid_brush

vacca.utils.get_solid_brush(r, g, b, pattern=None)[source]

get_env_variable

vacca.utils.get_env_variable(var, default='')[source]

It will try to get value from OS, then Tango.VACCA, then default

get_shared_data_signals

vacca.utils.get_shared_data_signals()[source]

Return the dictionary of signals and registered Qt objects.

_joiner

vacca.utils._joiner(a, s, b)[source]

get_main_window

vacca.utils.get_main_window(app=None)[source]

vpath

vacca.utils.vpath(s='')[source]

add_menu

vacca.utils.add_menu(menuname, actions)[source]

The arguments must be a list of tuples with action names and action methods.

e.g.: EXTRA_MENUS = [ (‘Tools’,[

(‘LTB Gui’,lambda:os.system(‘vacca_LTB &’),None), (‘Jive’,lambda:os.system(‘jive &’),None), (‘Astor’,lambda:os.system(‘astor &’),None), (‘EPS Gui’,lambda:os.system(‘alba_EPS &’),None), (‘Valves’,lambda:valves.ValvesChooser().show(),None), (‘TaurusTrend’,lambda:os.system(‘taurustrend -a &’),None), ]),

replace_env

vacca.utils.replace_env(text, var, value=None)[source]

get_class_property

vacca.utils.get_class_property(dev_class, prop, extract=False)[source]

YesNoDialog

vacca.utils.YesNoDialog(title, message)[source]

get_vacca_property

vacca.utils.get_vacca_property(prop, extract=False)[source]

get_config_file

vacca.utils.get_config_file(config=None)[source]

get_halfWhite_palette

vacca.utils.get_halfWhite_palette(palette=None)[source]

load_config_properties

vacca.utils.load_config_properties(config, export=True)[source]

It will load env variables from VACCA.$config property

NOT USED!?

get_os_launcher

vacca.utils.get_os_launcher(cmd, args=[])[source]

Returns a Linux launcher method for “cmd”. @TODO: Study Taurus.ExternalApp and use the same methods used there.

get_fullWhite_palette

vacca.utils.get_fullWhite_palette(palette=None)[source]

get_taurus_gui

vacca.utils.get_taurus_gui(app=None)[source]

create_config_properties

vacca.utils.create_config_properties()[source]

get_config_properties

vacca.utils.get_config_properties(config='')[source]

class vacca.utils.Draggable[source]

Bases: object

Template for Taurus widgets accepting drops, deprecated by fandango.qt.Draggable

mouseMoveEvent(event)[source]

reimplemented to provide drag events

mousePressEvent(event)[source]

reimplemented to provide drag events

setDragEventCallback(hook)[source]
class vacca.utils.DraggableLabel(parent=None, text='')[source]

Bases: vacca.utils.Draggable, PyQt4.QtGui.QLabel

class vacca.utils.EventCounter(condition=None)[source]

Bases: vacca.utils.EventFilter

Generic event counter for taurus

class vacca.utils.EventFilter(condition=None)[source]

Bases: object

Generic event filter for taurus

class vacca.utils.MyTaurusComponent(name='test')[source]

Bases: taurus.qt.qtgui.base.taurusbase.TaurusBaseComponent, PyQt4.QtCore.QObject

fireEvent(evt_src=None, evt_type=None, evt_value=None)[source]
handleEvent(*args, **kwargs)[source]
setMyHandler(handler)[source]
class vacca.utils.OnChangeOrTimeEventFilter[source]

Bases: vacca.utils.EventFilter

The instances of this class will be callables that can be used as filters of repeated-value events. If the event type is Change or Periodic, it will only pass when its evt_value.value is different from that of the last event received from the same source and type. If evt_value.value is not available in the current event, the whole evt_value is used for comparison and as a future reference. But!, if setMaxDeltaTime is set, then any event that occurred more than Delta Time seconds after the last one will be allowed to pass through the chain.

This is useful to avoid processing repetitive events.

Note that you cannot use this class as a filter: you need to use an instance of it.

Note 2: Use a different instance each time you insert this filter into a different widget unless you really know what you are doing.

Example of usage::
evf = OnChangeOrTimeEventFilter() evf.setDeltaTime(60.) filters = [evf, IGNORE_CONFIG] MyTaurusComponentInstance.setEventFilters(filters,preqt=True) filterEvent(s, t, v, filters)
setDeltaTime(mindiff)[source]
setDeltaValue(mindiff)[source]
vacca.utils.VACCA_CONFIG = 'html'

VACCA_CONFIG:

The config file to be loaded, it can be absolute path or relative to WORKING_DIR. get_config_file() will import it and return the content as a python module.

e.g. /homelocal/sicilia/applications/vacca/tbl2401.py

vacca.utils.VACCA_DIR = '/homelocal/sicilia/lib/python/site-packages/vacca/../vaccagui'

VACCA_DIR: wdir(‘path/to/icon’)

The folder were VACCA should be executed, all paths within the application will be relative to it. It includes all custom icons that are not part of the vacca package.

Extra modules or plugins to be imported will be loaded from this directory.

e.g. /homelocal/sicilia/applications/vacca/

vacca.utils.VACCA_PATH = '/homelocal/sicilia/lib/python/site-packages/vacca'

VACCA_PATH: vpath(‘path/to/icon’)

Path to the VACCA library parent folder, tipically used for icons of vacca package Note, vpath(folder) will append /vacca to VACCA_PATH, to get internal vacca files.

e.g. VACCA_PATH = /homelocal/sicilia/lib/python/site-packages e.g. vpath = /homelocal/sicilia/lib/python/site-packages/vacca

vacca.utils.VACCA_PROFILES = {'DEFAULT': {}, 'TEST': {}}

VACCA_PROFILES:

Sets of environment variables declared as free properties in the Tango Database.
class vacca.utils.WidgetAcceptDrops[source]

Bases: object

Template for Taurus widgets accepting drops, deprecated by fandango.qt.Dropable

TAURUS_ATTR_MIME_TYPE = 'application/taurus-attribute'
TAURUS_DEV_MIME_TYPE = 'application/taurus-device'
TAURUS_MODEL_LIST_MIME_TYPE = 'text/uri-list'
TAURUS_MODEL_MIME_TYPE = 'application/taurus-model'
TEXT_MIME_TYPE = 'text/plain'
checkDrops()[source]
checkSupportedMimeType(event, accept=False)[source]
dragEnterEvent(event)[source]
dragMoveEvent(event)[source]
dropEvent(event)[source]

reimplemented to support drag&drop of models. See QWidget

getSupportedMimeTypes()[source]
setDropEventCallback(callback)[source]
setSupportedMimeTypes(mimes)[source]
vacca.utils.YesNoDialog(title, message)[source]
class vacca.utils.addCustomPanel2Gui(extra_panels=None)[source]

Bases: object

this Class is used to add new panel to existing TaurusGUI with the same Context. Each extra_panel class should have a ‘getPaneldescription’ and getDefaultIcon methods.

Pass a dictionary like this:
EXTRA_PANELS[‘VaccaProperties’] = {
‘class’: vacca.VaccaPropTable, ‘icon’: ‘:/places/network-server.svg’, }
vacca.utils.add_menu(menuname, actions)[source]

The arguments must be a list of tuples with action names and action methods.

e.g.: EXTRA_MENUS = [ (‘Tools’,[

(‘LTB Gui’,lambda:os.system(‘vacca_LTB &’),None), (‘Jive’,lambda:os.system(‘jive &’),None), (‘Astor’,lambda:os.system(‘astor &’),None), (‘EPS Gui’,lambda:os.system(‘alba_EPS &’),None), (‘Valves’,lambda:valves.ValvesChooser().show(),None), (‘TaurusTrend’,lambda:os.system(‘taurustrend -a &’),None), ]),
vacca.utils.create_config_properties()[source]
vacca.utils.get_White_palette(palette=None)[source]
vacca.utils.get_class_property(dev_class, prop, extract=False)[source]
vacca.utils.get_config_file(config=None)[source]
vacca.utils.get_config_properties(config='')[source]
vacca.utils.get_env_variable(var, default='')[source]

It will try to get value from OS, then Tango.VACCA, then default

vacca.utils.get_fullWhite_palette(palette=None)[source]
vacca.utils.get_halfWhite_palette(palette=None)[source]
vacca.utils.get_main_window(app=None)[source]
vacca.utils.get_os_launcher(cmd, args=[])[source]

Returns a Linux launcher method for “cmd”. @TODO: Study Taurus.ExternalApp and use the same methods used there.

vacca.utils.get_shared_data_manager()[source]

sdm = get_shared_data_manager() #Qt.qApp.SDM Singletone sdm.connectReader(‘channelName’,objectInstance.method,readOnConnect=False) #Using instantiated object/function instead of names!! sdm.connectWriter(‘SelectedInstrument’,out_hook,’modelChanged’) #’Channel’, object, ‘qt signal name’

vacca.utils.get_shared_data_signals()[source]

Return the dictionary of signals and registered Qt objects.

vacca.utils.get_solid_brush(r, g, b, pattern=None)[source]
vacca.utils.get_taurus_gui(app=None)[source]
vacca.utils.get_vacca_property(prop, extract=False)[source]
vacca.utils.load_config_properties(config, export=True)[source]

It will load env variables from VACCA.$config property

NOT USED!?

vacca.utils.replace_env(text, var, value=None)[source]
vacca.utils.vpath(s='')[source]
vacca.utils.wdir(s='')[source]