diff --git a/slapos/cli/console.py b/slapos/cli/console.py index dd421c3dbbfb36fd9cce097b52c23709280e0c37..e0c33d217796989266691e39d63a19751e144104 100644 --- a/slapos/cli/console.py +++ b/slapos/cli/console.py @@ -27,8 +27,6 @@ # ############################################################################## -import textwrap - from slapos.cli.config import ClientConfigCommand from slapos.client import init, do_console, ClientConfig diff --git a/slapos/cli/supervisorctl.py b/slapos/cli/supervisorctl.py index 7cc38f83a2741e6ccfddb18d4b11e1c438446155..971b7e09c919a6a7e59b2ef72c708c9c370a3ed4 100644 --- a/slapos/cli/supervisorctl.py +++ b/slapos/cli/supervisorctl.py @@ -34,8 +34,6 @@ from slapos.cli.command import check_root_user from slapos.cli.config import ConfigCommand from slapos.grid.svcbackend import launchSupervisord -from slapos.util import string_to_boolean - import supervisor.supervisorctl diff --git a/slapos/format.py b/slapos/format.py index 82f77f4a05bb3520886334f52d813f5f69c4e7e8..eaed8254d6c030c0ab6ff925bbebc59cf4c1988f 100644 --- a/slapos/format.py +++ b/slapos/format.py @@ -46,7 +46,6 @@ import subprocess import sys import threading import time -import traceback import zipfile import lxml.etree @@ -1210,7 +1209,6 @@ class FormatConfig(object): attr = getattr(self, option) if isinstance(attr, str): if attr.lower() == 'true': - root_needed = True setattr(self, option, True) elif attr.lower() == 'false': setattr(self, option, False) diff --git a/slapos/grid/SlapObject.py b/slapos/grid/SlapObject.py index 2de23ce9d091704da8beb96cccac1d12eb4bf5f6..4d6fec8fc6b1941d62f222e9988182786b62eb1e 100644 --- a/slapos/grid/SlapObject.py +++ b/slapos/grid/SlapObject.py @@ -468,7 +468,7 @@ class Partition(object): self.logger.warning("Falling back to default buildout %r" % buildout_binary) else: - if len(bootstrap_candidate_list) != 1: + if len(bootstrap_candidate_list) > 1: raise ValueError('More than one bootstrap candidate found.') # Reads uid/gid of path, launches buildout with thoses privileges bootstrap_file = os.path.abspath(os.path.join(bootstrap_candidate_dir, @@ -529,7 +529,7 @@ class Partition(object): if os.path.exists(self.service_path): if os.path.isdir(self.service_path): service_list = os.listdir(self.service_path) - if len(runner_list) == 0 and len(service_list) == 0: + if not runner_list and not service_list: self.logger.warning('No runners nor services found for partition %r' % self.partition_id) if os.path.exists(self.supervisord_partition_configuration_path): diff --git a/slapos/grid/slapgrid.py b/slapos/grid/slapgrid.py index 4946e17eddf74fb5c4eeee7ac9a6147e6afdaa64..f3a10da9580b4f4b71b1882c1050604c4d704ad8 100644 --- a/slapos/grid/slapgrid.py +++ b/slapos/grid/slapgrid.py @@ -329,15 +329,17 @@ class Slapgrid(object): self.buildout = buildout self.promise_timeout = promise_timeout self.develop = develop - if software_release_filter_list is not None: + + self.software_release_filter_list = [] + if software_release_filter_list: self.software_release_filter_list = \ software_release_filter_list.split(",") - else: - self.software_release_filter_list = [] + self.computer_partition_filter_list = [] - if computer_partition_filter_list is not None: + if computer_partition_filter_list: self.computer_partition_filter_list = \ computer_partition_filter_list.split(",") + self.maximum_periodicity = maximum_periodicity def getWatchdogLine(self): @@ -559,7 +561,7 @@ class Slapgrid(object): # Check if we defined explicit list of partitions to process. # If so, if current partition not in this list, skip. - if len(self.computer_partition_filter_list) > 0 and \ + if self.computer_partition_filter_list and \ (computer_partition_id not in self.computer_partition_filter_list): return @@ -877,7 +879,7 @@ class Slapgrid(object): self.logger.error(UnicodeError) raise UnicodeError("Failed to read %s: %s" % (computer_partition_usage.usage, exc)) except (etree.XMLSyntaxError, etree.DocumentInvalid) as exc: - self.logger.info("Failed to parse %s." % (computer_partition_usage.usage)) + self.logger.info("Failed to parse %s." % computer_partition_usage.usage) self.logger.error(exc) raise _formatXMLError(exc) except Exception as exc: @@ -985,7 +987,7 @@ class Slapgrid(object): clean_run = False failed_script_list.append("Script %r failed." % script) self.logger.warning('Failed to run %r' % invocation_list) - if len(failed_script_list): + if failed_script_list: computer_partition.error('\n'.join(failed_script_list), logger=self.logger) # Whatever happens, don't stop processing other instances except Exception: diff --git a/slapos/slap/slap.py b/slapos/slap/slap.py index 3465b68f0e1c4efc66a4c719afa96d58dc6693f4..751caa99290c7259072109ba2d64b771229b49b1 100644 --- a/slapos/slap/slap.py +++ b/slapos/slap/slap.py @@ -51,13 +51,6 @@ urllib3_logger = logging.getLogger('requests.packages.urllib3') urllib3_logger.setLevel(logging.WARNING) -# XXX fallback_logger to be deprecated together with the old CLI entry points. -fallback_logger = logging.getLogger(__name__) -fallback_handler = logging.StreamHandler() -fallback_logger.setLevel(logging.INFO) -fallback_logger.addHandler(fallback_handler) - - DEFAULT_SOFTWARE_TYPE = 'RootSoftwareInstance' class SlapDocument: @@ -133,7 +126,7 @@ class SoftwareRelease(SlapDocument): else: return self._software_release - def error(self, error_log, logger=None): + def error(self, error_log, logger): try: # Does not follow interface self._connection_helper.POST('softwareReleaseError', data={ @@ -141,7 +134,7 @@ class SoftwareRelease(SlapDocument): 'computer_id': self.getComputerId(), 'error_log': error_log}) except Exception: - (logger or fallback_logger).exception('') + logger.exception('') def available(self): self._connection_helper.POST('availableSoftwareRelease', data={ @@ -439,14 +432,14 @@ class ComputerPartition(SlapRequester): 'computer_partition_id': self.getId(), }) - def error(self, error_log, logger=None): + def error(self, error_log, logger): try: self._connection_helper.POST('softwareInstanceError', data={ 'computer_id': self._computer_id, 'computer_partition_id': self.getId(), 'error_log': error_log}) except Exception: - (logger or fallback_logger).exception('') + logger.exception('') def bang(self, message): self._connection_helper.POST('softwareInstanceBang', data={