Skip to content

Commit

Permalink
Merge pull request #93 from klauer/fix_happi_search
Browse files Browse the repository at this point in the history
FIX: searching for happi devices was broken (SearchResults refactor)
  • Loading branch information
klauer authored Jul 7, 2021
2 parents d22f5c8 + b43d1b3 commit ce8bc8c
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions lucid/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
import logging
import pathlib

import happi
import typhos
from pydm import exception
from PyQtAds import QtAds
from qtpy import QtCore, QtWidgets, QtGui
from qtpy import QtCore, QtGui, QtWidgets
from qtpy.QtCore import Qt, Signal
from qtpy.QtWidgets import QMainWindow, QStyle, QSizePolicy

from pydm import exception
from qtpy.QtWidgets import QMainWindow, QSizePolicy, QStyle

import lucid

from . import utils

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -489,15 +488,12 @@ def _thread_screens_search(callback, *, general_search, category_search,
)


def _happi_dict_to_display(d):
name = d['name']
def _happi_searchresult_to_display(search_result):
name = search_result['name']

@LucidMainWindow.in_dock(title=f'[happi] {name}')
def wrapped():
client = utils.get_happi_client()
# dictionary -> device container -> device -> display
happi_device = client.find_device(**d)
device = happi.loader.from_container(happi_device)
device = search_result.get()
return utils.display_for_device(device)

wrapped()
Expand Down Expand Up @@ -535,7 +531,7 @@ def _thread_happi_search(callback, *, general_search, category_search,
name=item['name'],
item=item,
reason=f'{key}: {value}',
callback=lambda ct=item: _happi_dict_to_display(ct),
callback=lambda ct=item: _happi_searchresult_to_display(ct),
)


Expand Down

0 comments on commit ce8bc8c

Please sign in to comment.