Skip to content
Snippets Groups Projects
Commit 84e5ffa9 authored by Simon Sebastian Humpohl's avatar Simon Sebastian Humpohl
Browse files

Dynamic __version__ read

Rudimentary is simulator check
parent 1c40f0ec
No related branches found
No related tags found
No related merge requests found
from setuptools import setup 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( setup(
name='pytabor', name='pytabor',
version='0.0.1', version=get_version(),
packages=['pytabor', 'teawg'], packages=['pytabor', 'teawg'],
package_dir={'pytabor': 'pytabor', 'teawg': 'teawg'}, package_dir={'pytabor': 'pytabor', 'teawg': 'teawg'},
url='', url='',
......
...@@ -37,6 +37,8 @@ import time ...@@ -37,6 +37,8 @@ import time
import posixpath import posixpath
from pyvisa.errors import VisaIOError, VI_ERROR_TMO from pyvisa.errors import VisaIOError, VI_ERROR_TMO
from pyvisa.resources import TCPIPSocket
from pyvisa.constants import InterfaceType
import pytabor import pytabor
...@@ -438,6 +440,13 @@ class TEWXAwg(object): ...@@ -438,6 +440,13 @@ class TEWXAwg(object):
'''Get the firmware version ''' '''Get the firmware version '''
return self._fw_ver 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 @property
def paranoia_level(self): def paranoia_level(self):
'''Get the (default) paranoia-level '''Get the (default) paranoia-level
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment