Fix issue with infinite recursion when service_names is empty

Signed-off-by: Chris Corbyn <chris@w3style.co.uk>
This commit is contained in:
d11wtq 2014-06-08 09:09:57 +00:00 committed by Chris Corbyn
parent 14cbe40543
commit 949df97726
1 changed files with 17 additions and 5 deletions

View File

@ -104,7 +104,10 @@ class Project(object):
Raises NoSuchService if any of the named services do not exist. Raises NoSuchService if any of the named services do not exist.
""" """
if service_names is None or len(service_names) == 0: if service_names is None or len(service_names) == 0:
return [s for s in self.services if s.options['auto_start']] return self.get_services(
service_names=[s.name for s in self.services if s.options['auto_start']],
include_links=include_links
)
else: else:
unsorted = [self.get_service(name) for name in service_names] unsorted = [self.get_service(name) for name in service_names]
services = [s for s in self.services if s in unsorted] services = [s for s in self.services if s in unsorted]
@ -156,10 +159,19 @@ class Project(object):
return l return l
def _prepend_with_links(self, acc, service): def _prepend_with_links(self, acc, service):
linked_services = self.get_services( if service in acc:
service_names=service.get_linked_names(), return acc
include_links=True
) linked_names = service.get_linked_names()
if len(linked_names) > 0:
linked_services = self.get_services(
service_names=linked_names,
include_links=True
)
else:
linked_services = []
linked_services.append(service) linked_services.append(service)
return acc + linked_services return acc + linked_services