def get_config(): """Get relevant options from LabConfig, substituting defaults where appropriate and return as a dict""" global _cached_config # Cache the config so it is not loaded multiple times per process: if _cached_config is not None: return _cached_config labconfig = LabConfig() config = {} try: config['zlock_host'] = labconfig.get('servers', 'zlock') except (labconfig.NoOptionError, labconfig.NoSectionError): msg = "No zlock server specified in labconfig" raise RuntimeError(msg) try: config['zlock_port'] = labconfig.get('ports', 'zlock') except (labconfig.NoOptionError, labconfig.NoSectionError): config['zlock_port'] = zprocess.zlock.DEFAULT_PORT # We hard-code the zlog host and port, since zlog always runs on the computer with # the top-level process config['zlog_host'] = 'localhost' config['zlog_port'] = zprocess.zlog.DEFAULT_PORT try: config['zprocess_remote_port'] = labconfig.get('ports', 'zprocess_remote') except (labconfig.NoOptionError, labconfig.NoSectionError): config['zprocess_remote_port'] = zprocess.remote.DEFAULT_PORT try: shared_secret_file = labconfig.get('security', 'shared_secret') except (labconfig.NoOptionError, labconfig.NoSectionError): config['shared_secret'] = None config['shared_secret_file'] = None else: config['shared_secret'] = open(shared_secret_file).read().strip() config['shared_secret_file'] = shared_secret_file try: config['allow_insecure'] = labconfig.getboolean( 'security', 'allow_insecure') except (labconfig.NoOptionError, labconfig.NoSectionError): # Default will be set to False once the security rollout is complete: config['allow_insecure'] = True try: config['logging_maxBytes'] = labconfig.getint('logging', 'maxBytes') except (labconfig.NoOptionError, labconfig.NoSectionError): config['logging_maxBytes'] = 1024 * 1024 * 50 try: config['logging_backupCount'] = labconfig.getint( 'logging', 'backupCount') except (labconfig.NoOptionError, labconfig.NoSectionError): config['logging_backupCount'] = 1 _cached_config = config return config
h5_file, camera_name, 'device_properties') port = labscript_utils.properties.get( h5_file, camera_name, 'connection_table_properties')['BIAS_port'] print('Getting imaqdx_properties from device_properties:') imaqdx_properties = device_properties['added_properties'] # print(imaqdx_properties) # Get server settings server_kwargs = {} for option in ['image_path', 'named_exposures', 'imageify']: if lc.get('imaqdx_server', option, fallback=None): if option is 'image_path': val = lc.get('imaqdx_server', option) else: val = lc.getboolean('imaqdx_server', option) server_kwargs[option] = val print(f'Overriding {option} with {val}.') # Get the serial number serial_number = _ensure_str(device_properties['serial_number']) print(f'Instantiating IMAQdx_Camera (SN = {serial_number}).') camera = IMAQdx_Camera(sn=serial_number) if len(imaqdx_properties): print('Setting IMAQdx properties:') for key, val in imaqdx_properties.items(): print('{:}: {:}'.format(key, val)) print('\n') camera.set_attributes_dict(imaqdx_properties) print(f'Starting camera server on port {port}...')
key=lambda callback: getattr(callback, 'priority', DEFAULT_PRIORITY)) return callbacks exp_config = LabConfig() if not exp_config.has_section('BLACS/plugins'): exp_config.add_section('BLACS/plugins') modules = {} for module_name in os.listdir(PLUGINS_DIR): if os.path.isdir(os.path.join( PLUGINS_DIR, module_name)) and module_name != '__pycache__': # is it a new plugin? # If so lets add it to the config if not module_name in [ name for name, val in exp_config.items('BLACS/plugins') ]: exp_config.set('BLACS/plugins', module_name, str(module_name in default_plugins)) # only load activated plugins if exp_config.getboolean('BLACS/plugins', module_name): try: module = importlib.import_module('blacs.plugins.' + module_name) except Exception: logger.exception('Could not import plugin \'%s\'. Skipping.' % module_name) else: modules[module_name] = module