예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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
예제 #4
0
    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
예제 #5
0
    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)
예제 #6
0
 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)
예제 #7
0
파일: test_rname.py 프로젝트: xl-w/pyvisa
 def test_bad_filter(self):
     with self.assertRaises(errors.VisaIOError) as e:
         rname.filter([], "?*(")
     self.assertIn("VI_ERROR_INV_EXPR", e.exception.args[0])
예제 #8
0
파일: test_rname.py 프로젝트: tr76yr/pyvisa
 def test_bad_filter(self):
     with pytest.raises(errors.VisaIOError) as e:
         rname.filter([], "?*(")
     assert "VI_ERROR_INV_EXPR" in e.exconly()
예제 #9
0
파일: test_rname.py 프로젝트: tr76yr/pyvisa
 def _test_filter(self, expr, *correct):
     ok = tuple(self.run_list[n] for n in correct)
     assert rname.filter(self.run_list, expr) == ok
예제 #10
0
파일: test_rname.py 프로젝트: Roanmh/pyvisa
 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)