Exemplo n.º 1
0
		def save_settings(user_settings: dict):
			new_settings = {
				'DIGIKEY_CLIENT_ID': api_values['client_id'],
				'DIGIKEY_CLIENT_SECRET': api_values['client_secret'],
			}
			user_settings = {**user_settings, **new_settings}
			config_interface.dump_file(user_settings, settings.CONFIG_DIGIKEY_API)
Exemplo n.º 2
0
def kicad_settings_window():
    ''' KiCad settings window '''
    kicad_user_settings = config_interface.load_file(settings.CONFIG_KICAD)
    KICAD_SYMBOLS_PATH = kicad_user_settings['KICAD_SYMBOLS_PATH']
    KICAD_TEMPLATES_PATH = kicad_user_settings['KICAD_TEMPLATES_PATH']
    KICAD_FOOTPRINTS_PATH = kicad_user_settings['KICAD_FOOTPRINTS_PATH']

    kicad_layout = [
        [
            sg.Text('Select Symbol Libraries Folder:'),
            sg.InputText(KICAD_SYMBOLS_PATH, key='library'),
            sg.FolderBrowse(target='library',
                            initial_folder=KICAD_SYMBOLS_PATH),
        ],
        [
            sg.Text('Select Symbol Templates Folder:'),
            sg.InputText(KICAD_TEMPLATES_PATH, key='template'),
            sg.FolderBrowse(target='template',
                            initial_folder=KICAD_TEMPLATES_PATH),
        ],
        [
            sg.Text('Select Footprint Libraries Folder:'),
            sg.InputText(KICAD_FOOTPRINTS_PATH, key='footprint'),
            sg.FolderBrowse(target='footprint',
                            initial_folder=KICAD_FOOTPRINTS_PATH),
        ],
        [
            sg.Button('Save', size=(10, 1)),
        ],
    ]
    kicad_window = sg.Window('KiCad Settings',
                             kicad_layout,
                             location=(500, 500))
    kcd_event, kcd_values = kicad_window.read()
    if kcd_event == sg.WIN_CLOSED:  # if user closes window
        pass
    else:
        new_settings = {
            'KICAD_SYMBOLS_PATH': kcd_values['library'],
            'KICAD_TEMPLATES_PATH': kcd_values['template'],
            'KICAD_FOOTPRINTS_PATH': kcd_values['footprint'],
        }
        for name, path in new_settings.items():
            if path == '':
                cprint(f'[INFO]\tWarning: KiCad {name} path is empty',
                       silent=settings.SILENT)
            # Check if path has trailing slash
            elif path[-1] != os.sep:
                new_settings[name] = path + os.sep
        # Read user settings file
        kicad_user_settings = {**kicad_user_settings, **new_settings}
        # Write to user settings file
        config_interface.dump_file(kicad_user_settings, settings.CONFIG_KICAD)

    kicad_window.close()
    return
Exemplo n.º 3
0
def set_kicad_enable_flag(value: bool, save=False):
	global ENABLE_KICAD
	ENABLE_KICAD = value
	if save:
		global CONFIG_KICAD
		kicad_user_settings = config_interface.load_inventree_user_settings(
			CONFIG_KICAD)
		kicad_user_settings['KICAD_ENABLE'] = value
		config_interface.dump_file(kicad_user_settings, CONFIG_KICAD)
	return
Exemplo n.º 4
0
def save_to_file(part_info, search_file):
    ''' Save Digi-Key part data to file '''

    # Check if search/results directory needs to be created
    if not os.path.exists(os.path.dirname(search_file)):
        os.mkdir(os.path.dirname(search_file))

    # Add timestamp
    part_info['search_timestamp'] = int(time.time())

    # Save data if cache enabled
    if settings.CACHE_ENABLED:
        try:
            config_interface.dump_file(part_info, search_file)
        except:
            raise Exception('Error saving Digi-key search data')