def make_labconfig_file(install_folder):
    from labscript_utils.labconfig import LabConfig, default_config_path
    source_path = os.path.join(install_folder, 'labconfig', 'example.ini')
    target_path = default_config_path
    if os.path.exists(target_path):
        # Don't modify it, leave their config as it is:
        return
    print('making default labconfig file')
    with open(source_path) as infile, open(target_path, 'w') as outfile:
        data = infile.read()
        data = data.replace('\\', os.path.sep)
        outfile.write(data)
    # Now change some things about it:
    config = LabConfig()
    config.set('DEFAULT', 'labscript_suite', install_folder)
    if sys.platform == 'linux2':
        config.set('programs', 'text_editor', 'gedit')
    elif sys.platform == 'darwin':
        config.set('programs', 'text_editor', 'open')
        config.set('programs', 'text_editor_arguments', '-a TextEdit {file}')
    if sys.platform != 'win32':
        config.set('programs', 'hdf5_viewer', 'hdfview')
示例#2
0
def make_labconfig_file(install_folder):
    from labscript_utils.labconfig import LabConfig, default_config_path
    source_path = os.path.join(install_folder, 'labconfig', 'example.ini')
    target_path = default_config_path
    if os.path.exists(target_path):
        # Don't modify it, leave their config as it is:
        return
    print('making default labconfig file')
    with open(source_path) as infile, open(target_path, 'w') as outfile:
        data = infile.read()
        data = data.replace('\\', os.path.sep)
        outfile.write(data)
    # Now change some things about it:
    config = LabConfig()
    config.set('DEFAULT', 'labscript_suite', install_folder)
    if sys.platform == 'linux2':
        config.set('programs', 'text_editor', 'gedit')
    elif sys.platform == 'darwin':
        config.set('programs', 'text_editor', 'open')
        config.set('programs', 'text_editor_arguments', '-a TextEdit {file}')
    if sys.platform != 'win32':
        config.set('programs', 'hdf5_viewer', 'hdfview')
示例#3
0
        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