diff --git a/setup.py b/setup.py index 5f2c3fd82cc85b18f8b1b94214998c2b249ce516..c4df2f3e0df0a0a55ac8363f7c4ebc802077c446 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,26 @@ from setuptools import setup +import os +import re + + +def get_version(): + dir_path = os.path.dirname(os.path.realpath(__file__)) + + teawg_init = os.path.join(dir_path, 'teawg', '__init__.py') + + with open(teawg_init, 'r') as version_file: + # https://packaging.python.org/guides/single-sourcing-package-version/ + version_match = re.search(r"^__version__\s+=\s+['\"]([^'\"]*)['\"]", version_file.read(), re.M) + + if version_match: + return version_match.group(1) + else: + raise RuntimeError("Unable to find version string.") + setup( name='pytabor', - version='0.0.1', + version=get_version(), packages=['pytabor', 'teawg'], package_dir={'pytabor': 'pytabor', 'teawg': 'teawg'}, url='', diff --git a/teawg/__init__.py b/teawg/__init__.py index 19c930cc2cf715f3c0e35c6daf8902fa54518d72..f92fe44fdf4d7f4c6ef46aa8f0eb504a03451558 100644 --- a/teawg/__init__.py +++ b/teawg/__init__.py @@ -37,6 +37,8 @@ import time import posixpath from pyvisa.errors import VisaIOError, VI_ERROR_TMO +from pyvisa.resources import TCPIPSocket +from pyvisa.constants import InterfaceType import pytabor @@ -438,6 +440,13 @@ class TEWXAwg(object): '''Get the firmware version ''' return self._fw_ver + @property + def is_simulator(self): + '''True if IP address is localhost''' + if self.visa_inst and self.visa_inst.interface_type == InterfaceType.tcpip: + return '127.0.0.1' in self.visa_inst.resource_name or 'localhost' in self.visa_inst.resource_name + return False + @property def paranoia_level(self): '''Get the (default) paranoia-level