From 4956e95347874ecb7d1afdc97b65148cbe0a1bc2 Mon Sep 17 00:00:00 2001 From: nsubiron Date: Fri, 22 Dec 2017 15:35:11 +0100 Subject: [PATCH 1/4] Add pylint continuous integration with travis-ci --- .travis.yml | 13 +++++++++++++ PythonClient/requirements.txt | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 .travis.yml create mode 100644 PythonClient/requirements.txt diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..0aec7cb1d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: python + +python: + - "2.7" + - "3.5" + - "3.6" + +install: + - pip install -r PythonClient/requirements.txt + - pip install pylint + +script: + - pylint --errors-only --ignored-modules=ConfigParser,numpy,pygame PythonClient/carla PythonClient/*.py diff --git a/PythonClient/requirements.txt b/PythonClient/requirements.txt new file mode 100644 index 000000000..1a697a692 --- /dev/null +++ b/PythonClient/requirements.txt @@ -0,0 +1,4 @@ +Pillow +numpy +protobuf +pygame From 30c54019ec84d533d0d3d5082b277c2c93040cbb Mon Sep 17 00:00:00 2001 From: nsubiron Date: Fri, 22 Dec 2017 15:40:07 +0100 Subject: [PATCH 2/4] Suppress pylint errors --- PythonClient/carla/client.py | 5 ++--- PythonClient/carla/planner/map.py | 13 +++++++------ PythonClient/manual_control.py | 14 ++++++++++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/PythonClient/carla/client.py b/PythonClient/carla/client.py index 748200928..fedf0e490 100644 --- a/PythonClient/carla/client.py +++ b/PythonClient/carla/client.py @@ -17,6 +17,7 @@ from . import util try: from . import carla_server_pb2 as carla_protocol + from carla_protocol import EpisodeReady except ImportError: raise RuntimeError('cannot import "carla_server_pb2.py", run the protobuf compiler to generate this file') @@ -96,7 +97,7 @@ class CarlaClient(object): data = self._world_client.read() if not data: raise RuntimeError('failed to read data from server') - pb_message = carla_protocol.EpisodeReady() + pb_message = EpisodeReady() pb_message.ParseFromString(data) if not pb_message.ready: raise RuntimeError('cannot start episode: server failed to start episode') @@ -159,8 +160,6 @@ class CarlaClient(object): raise RuntimeError('failed to read data from server') pb_message = carla_protocol.SceneDescription() pb_message.ParseFromString(data) - if len(pb_message.player_start_spots) < 1: - raise RuntimeError("received 0 player start spots") self._sensor_names = settings._get_sensor_names(carla_settings) self._is_episode_requested = True return pb_message diff --git a/PythonClient/carla/planner/map.py b/PythonClient/carla/planner/map.py index 142fc2a14..22c651118 100644 --- a/PythonClient/carla/planner/map.py +++ b/PythonClient/carla/planner/map.py @@ -89,12 +89,13 @@ class CarlaMap(object): return np.fliplr(self.map_image) def get_map_lanes(self, height=None): - if size is not None: - img = Image.fromarray(self.map_image_lanes.astype(np.uint8)) - img = img.resize((size[1], size[0]), Image.ANTIALIAS) - img.load() - return np.fliplr(np.asarray(img, dtype="int32")) - return np.fliplr(self.map_image_lanes) + # if size is not None: + # img = Image.fromarray(self.map_image_lanes.astype(np.uint8)) + # img = img.resize((size[1], size[0]), Image.ANTIALIAS) + # img.load() + # return np.fliplr(np.asarray(img, dtype="int32")) + # return np.fliplr(self.map_image_lanes) + raise NotImplementedError def get_position_on_map(self, world): """Get the position on the map for a certain world position.""" diff --git a/PythonClient/manual_control.py b/PythonClient/manual_control.py index 6933747ce..329d831a0 100755 --- a/PythonClient/manual_control.py +++ b/PythonClient/manual_control.py @@ -35,7 +35,17 @@ import time try: import pygame - from pygame.locals import * + from pygame.locals import K_DOWN + from pygame.locals import K_LEFT + from pygame.locals import K_RIGHT + from pygame.locals import K_SPACE + from pygame.locals import K_UP + from pygame.locals import K_a + from pygame.locals import K_d + from pygame.locals import K_q + from pygame.locals import K_r + from pygame.locals import K_s + from pygame.locals import K_w except ImportError: raise RuntimeError('cannot import pygame, make sure pygame package is installed') @@ -301,7 +311,7 @@ class CarlaGame(object): agent.vehicle.transform.location.y, agent.vehicle.transform.location.z]) w_pos = int(agent_position[0]*(float(WINDOW_HEIGHT)/float(self._map_shape[0]))) - h_pos =int(agent_position[1] *(new_window_width/float(self._map_shape[1]))) + h_pos =int(agent_position[1] *(new_window_width/float(self._map_shape[1]))) pygame.draw.circle(surface, [255, 0, 255, 255], (w_pos,h_pos), 4, 0) self._display.blit(surface, (WINDOW_WIDTH, 0)) From 1616ac440ee23f60ec2bbe9fad5c16d78ec718fa Mon Sep 17 00:00:00 2001 From: nsubiron Date: Fri, 22 Dec 2017 15:44:08 +0100 Subject: [PATCH 3/4] Suppress pylint warnings in Python 2 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0aec7cb1d..d4e7faedf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ install: - pip install pylint script: - - pylint --errors-only --ignored-modules=ConfigParser,numpy,pygame PythonClient/carla PythonClient/*.py + - pylint --errors-only --ignored-modules=ConfigParser,numpy,pygame,shutil,_socketobject PythonClient/carla PythonClient/*.py From c4cbff1521bb13ee0ab467474e73a027b7b3ea0d Mon Sep 17 00:00:00 2001 From: nsubiron Date: Fri, 22 Dec 2017 15:53:16 +0100 Subject: [PATCH 4/4] Create pylintrc --- .travis.yml | 2 +- PythonClient/.pylintrc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 PythonClient/.pylintrc diff --git a/.travis.yml b/.travis.yml index d4e7faedf..c41c171e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ install: - pip install pylint script: - - pylint --errors-only --ignored-modules=ConfigParser,numpy,pygame,shutil,_socketobject PythonClient/carla PythonClient/*.py + - pylint --errors-only --rcfile=PythonClient/.pylintrc PythonClient/carla PythonClient/*.py diff --git a/PythonClient/.pylintrc b/PythonClient/.pylintrc new file mode 100644 index 000000000..f369d5bde --- /dev/null +++ b/PythonClient/.pylintrc @@ -0,0 +1,3 @@ +[TYPECHECK] +ignored-modules=ConfigParser,numpy,pygame,shutil +ignored-classes=_socketobject