コード例 #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
ファイル: high_level.py プロジェクト: sohailc/pyvisa-mock
    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
ファイル: highlevel.py プロジェクト: hgrecco/pyvisa-py
    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
ファイル: highlevel.py プロジェクト: yaoshouxiang/pyvisa-sim
    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)