def list_resources(self, session: VISARMSession, query: str = "?*::INSTR") -> Tuple[str, ...]: """Return a tuple of all connected devices matching query. Parameters ---------- session : VISARMSession Unique logical identifier to the resource manager session. query : str Regular expression used to match devices. Returns ------- Tuple[str, ...] Resource names of all the connected devices matching the query. """ # For each session type, ask for the list of connected resources and # merge them into a single list. # HINT: the cast should not be necessary here resources: List[str] = [] for key, st in sessions.Session.iter_valid_session_classes(): resources += st.list_resources() return rname.filter(resources, query)
def list_resources(self, session: int, query='?*::INSTR') -> List[str]: resources_list = rname.filter(list(resources), query) if resources_list: return resources_list raise errors.VisaIOError( errors.StatusCode.error_resource_not_found.value)
def list_resources(self, session, query='?*::INSTR'): """Returns a tuple of all connected devices matching query. :param query: regular expression used to match devices. """ # For each session type, ask for the list of connected resources and # merge them into a single list. resources = sum([st.list_resources() for key, st in sessions.Session.iter_valid_session_classes()], []) resources = rname.filter(resources, query) return resources
def list_resources(self, session, query='?*::INSTR'): """Returns a tuple of all connected devices matching query. :param query: regular expression used to match devices. """ # For each session type, ask for the list of connected resources and merge them into a single list. resources = self.devices.list_resources() resources = rname.filter(resources, query) if resources: return resources raise errors.VisaIOError( errors.StatusCode.error_resource_not_found.value)
def _test_filter(self, expr, *correct): ok = tuple(self.run_list[n] for n in correct) self.assertEqual(rname.filter(self.run_list, expr), ok)
def test_bad_filter(self): with self.assertRaises(errors.VisaIOError) as e: rname.filter([], "?*(") self.assertIn("VI_ERROR_INV_EXPR", e.exception.args[0])
def test_bad_filter(self): with pytest.raises(errors.VisaIOError) as e: rname.filter([], "?*(") assert "VI_ERROR_INV_EXPR" in e.exconly()
def _test_filter(self, expr, *correct): ok = tuple(self.run_list[n] for n in correct) assert rname.filter(self.run_list, expr) == ok