Skip to content

Commit

Permalink
Merge pull request #58 from sonelu/pvl
Browse files Browse the repository at this point in the history
using nan instread of None and updated tests
  • Loading branch information
sonelu authored May 23, 2020
2 parents 7655369 + b995a1d commit 3e5fc2a
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 182 deletions.
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[pytest]
log_cli = True
log_cli_date_format = %Y-%m-%d %H:%M:%S
log_cli_format = %(asctime)s %(levelname)-7s %(threadName)-18s %(name)-32s %(message)s
log_cli_format = %(asctime)s %(levelname)-8s %(threadName)-18s %(name)-32s [%(funcName)s-%(lineno)d] %(message)s
log_cli_level = 60

; log_file = logs/pytest-logs.txt
Expand Down
17 changes: 9 additions & 8 deletions roboglia/base/bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def __init__(self, name='FILEBUS', robot=None, port='', auto=True,
**kwargs)
self.__fp = None
self.__last = {}
logger.debug(f'FileBus {self.name} initialized')
logger.debug(f'FileBus "{self.name}" initialized')

def open(self):
"""Opens the file associated with the ``FileBus``."""
Expand Down Expand Up @@ -228,15 +228,16 @@ def write(self, reg, value):
logger.error(f'attempt to write to closed bus {self.name}')
else:
self.__last[(reg.device.dev_id, reg.address)] = value
text = f'written {value} in register {reg.name} ' + \
f'({reg.address}) of device {reg.device.dev_id}'
text = f'written {value} in register "{reg.name}"" ' + \
f'({reg.address}) of device "{reg.device.name}" ' + \
f'({reg.device.dev_id})'
try:
self.__fp.write(text + '\n')
self.__fp.flush()
except Exception:
logger.error(f'error executing write and flush to file '
f'for bus: {self.name}')
logger.debug(f'FileBus {self.name} {text}')
logger.debug(f'FileBus "{self.name}" {text}')

def read(self, reg):
"""Reads the value from the buffer of ``FileBus`` and logs it.
Expand Down Expand Up @@ -272,15 +273,15 @@ def read(self, reg):
if (reg.device.dev_id, reg.address) not in self.__last:
self.__last[(reg.device.dev_id, reg.address)] = reg.default
val = self.__last[(reg.device.dev_id, reg.address)]
text = f'read {val} from register {reg.name} ){reg.address}) ' + \
f'of device {reg.device.dev_id}'
text = f'read {val} from register "{reg.name}" ({reg.address}) ' +\
f'of device "{reg.device.name}" ({reg.device.dev_id})'
try:
self.__fp.write(text + '\n')
self.__fp.write(text+'\n')
self.__fp.flush()
except Exception:
logger.error(f'error executing write and flush to file '
f'for bus: {self.name}')
logger.debug(f'FileBus {self.name} {text}')
logger.debug(f'FileBus "{self.name}" {text}')
return val

def __str__(self):
Expand Down
Loading

0 comments on commit 3e5fc2a

Please sign in to comment.