Пример #1
0
 def __init__(self):
     config = ConfigReader()
     self._url = config.configSectionMap('url')['api']
     self.user = config.configSectionMap('user')['name']
     self._password = config.configSectionMap('user')['pass']
     self._headers = {'content-type':'application/json', 'accept':'application/json'}
     
     self.h = httplib2.Http(".cache")
     self.h.add_credentials(self.user, self._password)
Пример #2
0
    def __init__(self, parent):
        tk.Frame.__init__(self, parent)
        
        self.config_reader = ConfigReader(os.getcwd() + '/configs/rootConfig')
        self.development_mode = self.config_reader.is_development_mode()
        
        self.master.wm_title("Cold Control Heavy")
        self.addMenu()
        self.title = tk.Label(self, text="Cold Control Heavy", font=("Helvetica", 24))

        '''Load DAQ channels and cards from the config file.  Set up the DAQ_controller with these.'''
        self.daq_config_fname = self.config_reader.get_daq_config_fname()   
        self.daq_UI = DAQ_UI(self, self.daq_config_fname, development_mode=self.development_mode)

        '''Load a sequence and start the sequence UI (though it is hidden by default)'''
        self.sequence_fname = self.config_reader.get_sequence_fname()
        self.sequence_ui = Sequence_UI(self, self.sequence_fname, self.daq_UI.daq_controller.getChannelNumberNameDict(onlyVisable=False),
                                       self.daq_UI.daq_controller.getChannelCalibrationDict(), hidden=True)
        
        
        '''Start up the camera UI.'''
        self.camera_UI = Camera_UI(self, ic_imaging_control = None)
        
        '''Set up the experimental UI with pre-configured defaults from the appropriate config files.'''
        self.absorbtion_imaging_config_fname = self.config_reader.get_absorbtion_imaging_config_fname()
        self.photon_production_config_fname = self.config_reader.get_photon_production_config_fname()
        self.experimental_UI = Experimental_UI(self,
                                               self.daq_UI,
                                               self.sequence_ui, 
                                               self.photon_production_config_fname,
                                               self.absorbtion_imaging_config_fname,
                                               ic_imaging_control=self.camera_UI.ic_ic)
        
        '''Initialise the labook UI'''
        self.labbook_UI = Labbook_UI(self)

        '''Configure the interface and place the displays for each UI appropriately.'''
        self.grid_columnconfigure(0, weight=1, pad=3, uniform='cols')
        self.grid_columnconfigure(1, weight=1, pad=3, uniform='cols')
        self.grid_columnconfigure(2, weight=1, pad=3, uniform='cols')
        self.grid_columnconfigure(3, weight=1, pad=3, uniform='cols')
        
        gridOpts = {'padx': 10, 'pady':10}
        
        self.title.grid(row=0,column=0,columnspan=3, **gridOpts)
        self.daq_UI.grid(row=1,column=1,columnspan=2, sticky=tk.N+tk.E+tk.W, **gridOpts)
        self.experimental_UI.grid(row=2,column=1,columnspan=2, sticky=tk.N)
        self.camera_UI.grid(row=1,column=0, sticky=tk.N+tk.E+tk.W)
        self.labbook_UI.grid(row=1, column=3, sticky=tk.N+tk.E+tk.W)
               
        '''Bind closing the app to a clean up method.'''
        root.protocol( "WM_DELETE_WINDOW", self.onExit)
Пример #3
0
class Configuration(object):
    '''Configuration accessor object wrapping ConfigReader'''
    def __init__(self): 
        self.config = ConfigReader()
        
    def readConf(self):
        '''Read function for ConfigReader returning selected attributes
        @return: Dictionary containing comfiguration parameters
        '''
        conf = {}
        conf['url'] = self.config.configSectionMap('url')['api']
        conf['org'] = self.config.configSectionMap('user')['org']
        conf['user'] = self.config.configSectionMap('user')['name']
        conf['password'] = self.config.configSectionMap('user')['pass']
        conf['headers'] = {'content-type':'application/json', 'accept':'application/json'}
        return conf
Пример #4
0
    def __init__(self, config):
        '''Initialises API connector object with provided configuration.
        @param config: Dictionary of configuration values from CP
        '''
        self._url = config['url']
        self._password = ConfigReader.readp()
        self.user = config['user']
        self._headers = config['headers']

        self.h = httplib2.Http(".cache")
        self.h.add_credentials(self.user, self._password)
Пример #5
0
    def __init__(self,config):
        '''Initialises API connector object with provided configuration.
        @param config: Dictionary of configuration values from CP
        '''
        self._url = config['url']
        self._password = ConfigReader.readp()
        self.user = config['user']
        self._headers = config['headers']

        self.h = httplib2.Http(".cache")
        self.h.add_credentials(self.user, self._password)
Пример #6
0
class ColdControl_UI(tk.Frame):
    '''
    The ColdControl_UI is the main tkinter frame into which assorted UI's are inset.
    Each if these UI's is responsible for creating, running and closing there own
    element of experimental control.  Namely:
    
        DAQ_UI: Interfaces with the DAQ cards that control static voltages to
                setup the system and play sequences to run experiments.
                
        Sequence_UI: Allows the user to load and edit the experimental sequence.
        
        Camera_UI: Runs the inbuilt camera for monitoring the experiment.
        
        Labook_UI: Provides access to read and write into the labbooks to document
                   the experiment.
    '''

    def __init__(self, parent):
        tk.Frame.__init__(self, parent)
        
        self.config_reader = ConfigReader(os.getcwd() + '/configs/rootConfig')
        self.development_mode = self.config_reader.is_development_mode()
        
        self.master.wm_title("Cold Control Heavy")
        self.addMenu()
        self.title = tk.Label(self, text="Cold Control Heavy", font=("Helvetica", 24))

        '''Load DAQ channels and cards from the config file.  Set up the DAQ_controller with these.'''
        self.daq_config_fname = self.config_reader.get_daq_config_fname()   
        self.daq_UI = DAQ_UI(self, self.daq_config_fname, development_mode=self.development_mode)

        '''Load a sequence and start the sequence UI (though it is hidden by default)'''
        self.sequence_fname = self.config_reader.get_sequence_fname()
        self.sequence_ui = Sequence_UI(self, self.sequence_fname, self.daq_UI.daq_controller.getChannelNumberNameDict(onlyVisable=False),
                                       self.daq_UI.daq_controller.getChannelCalibrationDict(), hidden=True)
        
        
        '''Start up the camera UI.'''
        self.camera_UI = Camera_UI(self, ic_imaging_control = None)
        
        '''Set up the experimental UI with pre-configured defaults from the appropriate config files.'''
        self.absorbtion_imaging_config_fname = self.config_reader.get_absorbtion_imaging_config_fname()
        self.photon_production_config_fname = self.config_reader.get_photon_production_config_fname()
        self.experimental_UI = Experimental_UI(self,
                                               self.daq_UI,
                                               self.sequence_ui, 
                                               self.photon_production_config_fname,
                                               self.absorbtion_imaging_config_fname,
                                               ic_imaging_control=self.camera_UI.ic_ic)
        
        '''Initialise the labook UI'''
        self.labbook_UI = Labbook_UI(self)

        '''Configure the interface and place the displays for each UI appropriately.'''
        self.grid_columnconfigure(0, weight=1, pad=3, uniform='cols')
        self.grid_columnconfigure(1, weight=1, pad=3, uniform='cols')
        self.grid_columnconfigure(2, weight=1, pad=3, uniform='cols')
        self.grid_columnconfigure(3, weight=1, pad=3, uniform='cols')
        
        gridOpts = {'padx': 10, 'pady':10}
        
        self.title.grid(row=0,column=0,columnspan=3, **gridOpts)
        self.daq_UI.grid(row=1,column=1,columnspan=2, sticky=tk.N+tk.E+tk.W, **gridOpts)
        self.experimental_UI.grid(row=2,column=1,columnspan=2, sticky=tk.N)
        self.camera_UI.grid(row=1,column=0, sticky=tk.N+tk.E+tk.W)
        self.labbook_UI.grid(row=1, column=3, sticky=tk.N+tk.E+tk.W)
               
        '''Bind closing the app to a clean up method.'''
        root.protocol( "WM_DELETE_WINDOW", self.onExit)
    
    def addMenu(self):
        '''Create a pulldown menu, and add it to the menu bar'''
        menubar = tk.Menu(self.master)

        filemenu = tk.Menu(menubar, tearoff=0)
        filemenu.add_command(label="Open", command=None)
        filemenu.add_command(label="Save", command=None)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.onExit)
        menubar.add_cascade(label="File", menu=filemenu)
    
        self.master.config(menu=menubar)
        
    def onExit(self):
        '''
        Called on closing ColdControl.  Confirms the exit and safely closes the various UI's.
        '''
        
        exitConfirmation = tkMessageBox.askquestion("Please confirm exit",\
                                                    "Are you sure you want to close Cold Control?\nThis will release all DAQ cards and exit the program - unsaved information will be lost?",
                                                    icon='warning')
        if exitConfirmation == 'yes':
            print 'Closing camera connections...'
            self.camera_UI.closeCameras()
            print '...all camera connections closed.'
            print 'Releasing DAQ cards...'
            if not self.development_mode: self.daq_UI.daq_controller.releaseAll()
            print '...all cards released.'
            print 'Saving labbook...'
            self.labbook_UI.write()
            print '...labbook saved'
            root.destroy()
            print 'Cold Control closed - bye!'
Пример #7
0
 def __init__(self):
     '''Initialises and sets sel attributes from configreader values in 'const' section'''
     CR = ConfigReader()
     for key in CR.configSectionMap('const'):
         val = CR.configSectionMap('const')[key]
         setattr(self, key.upper(), val)
Пример #8
0
 def __init__(self):
     '''Initialises and sets sel attributes from configreader values in 'const' section'''
     CR = ConfigReader()
     for key in CR.configSectionMap('const'):
         val = CR.configSectionMap('const')[key]
         setattr(self, key.upper(), val) 
Пример #9
0
#
################################################################################

import psycopg2
from Error import Error
import Config
from Config import ConfigReader
from AimsUI.AimsLogging import Logger

aimslog = Logger.setup()

_db = None
_autocommit = True
_restartRequired = False

config = ConfigReader()
_host = config.configSectionMap('db')['host']
_port = config.configSectionMap('db')['port']
_name = config.configSectionMap('db')['name']
_user = config.configSectionMap('db')['user']
_password = config.configSectionMap('db')['password']

_aimsSchema='reference'


def setup(d):
    aimslog.info('Setting DB, {}'.format(d))
    setHost(d['host'])
    setPort(d['port'])
    setDatabase(d['name']) 
    setAimsSchema(d['aimsschema'])
Пример #10
0
 def __init__(self): 
     self.config = ConfigReader()