Minor improvements to the python client

This commit is contained in:
nsubiron 2017-09-22 17:55:28 +02:00
parent ef82867b45
commit 3850f9e1c5
2 changed files with 9 additions and 6 deletions

View File

@ -40,7 +40,7 @@ class _Control(object):
@staticmethod
def _parse(atype, value):
if atype == bool:
false_keys = ['f', 'false', '0', 'n', 'no', 'disable']
false_keys = ['f', 'false', '0', 'n', 'no', 'disable', 'off']
return value not in false_keys
return atype(value)
@ -57,11 +57,16 @@ def get_default_carla_settings(args):
def edit_text(text):
editor = 'vim'
with tempfile.NamedTemporaryFile('w+', suffix='.ini') as fp:
fp.write(text)
fp.flush()
if 0 != subprocess.run(['vim', fp.name]).returncode:
print('Cancelled.')
try:
if 0 != subprocess.run([editor, fp.name]).returncode:
print('Cancelled.')
return None
except FileNotFoundError:
logging.error('error opening text editor, is %r installed?', editor)
return None
fp.seek(0)
return fp.read()

View File

@ -35,10 +35,8 @@ class _BasicTestBase(test.CarlaServerTest):
measurements, images = client.read_measurements()
number_of_agents = len(measurements.non_player_agents)
expected_number_of_agents = carla_settings.get_number_of_agents()
logging.debug('received data of %d/%d agents', number_of_agents, expected_number_of_agents)
logging.debug('received data of %d agents', number_of_agents)
logging.debug('received %d images', len(images))
if number_of_agents > expected_number_of_agents or number_of_agents + 10 < expected_number_of_agents:
raise RuntimeError('received data for %d agents, but %d was requested' % (number_of_agents, expected_number_of_agents))
if len(images) != len(carla_settings._cameras):
raise RuntimeError('received %d images, expected %d' % (len(images), len(carla_settings._cameras)))
logging.debug('sending control...')