Commit be74286b authored by Marco Mariani's avatar Marco Mariani

removed dead code, petty cleanup

parent 8b829033
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
# #
############################################################################## ##############################################################################
import textwrap
from slapos.cli.config import ClientConfigCommand from slapos.cli.config import ClientConfigCommand
from slapos.client import init, do_console, ClientConfig from slapos.client import init, do_console, ClientConfig
......
...@@ -34,8 +34,6 @@ from slapos.cli.command import check_root_user ...@@ -34,8 +34,6 @@ from slapos.cli.command import check_root_user
from slapos.cli.config import ConfigCommand from slapos.cli.config import ConfigCommand
from slapos.grid.svcbackend import launchSupervisord from slapos.grid.svcbackend import launchSupervisord
from slapos.util import string_to_boolean
import supervisor.supervisorctl import supervisor.supervisorctl
......
...@@ -46,7 +46,6 @@ import subprocess ...@@ -46,7 +46,6 @@ import subprocess
import sys import sys
import threading import threading
import time import time
import traceback
import zipfile import zipfile
import lxml.etree import lxml.etree
...@@ -1210,7 +1209,6 @@ class FormatConfig(object): ...@@ -1210,7 +1209,6 @@ class FormatConfig(object):
attr = getattr(self, option) attr = getattr(self, option)
if isinstance(attr, str): if isinstance(attr, str):
if attr.lower() == 'true': if attr.lower() == 'true':
root_needed = True
setattr(self, option, True) setattr(self, option, True)
elif attr.lower() == 'false': elif attr.lower() == 'false':
setattr(self, option, False) setattr(self, option, False)
......
...@@ -468,7 +468,7 @@ class Partition(object): ...@@ -468,7 +468,7 @@ class Partition(object):
self.logger.warning("Falling back to default buildout %r" % self.logger.warning("Falling back to default buildout %r" %
buildout_binary) buildout_binary)
else: else:
if len(bootstrap_candidate_list) != 1: if len(bootstrap_candidate_list) > 1:
raise ValueError('More than one bootstrap candidate found.') raise ValueError('More than one bootstrap candidate found.')
# Reads uid/gid of path, launches buildout with thoses privileges # Reads uid/gid of path, launches buildout with thoses privileges
bootstrap_file = os.path.abspath(os.path.join(bootstrap_candidate_dir, bootstrap_file = os.path.abspath(os.path.join(bootstrap_candidate_dir,
...@@ -529,7 +529,7 @@ class Partition(object): ...@@ -529,7 +529,7 @@ class Partition(object):
if os.path.exists(self.service_path): if os.path.exists(self.service_path):
if os.path.isdir(self.service_path): if os.path.isdir(self.service_path):
service_list = os.listdir(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.logger.warning('No runners nor services found for partition %r' %
self.partition_id) self.partition_id)
if os.path.exists(self.supervisord_partition_configuration_path): if os.path.exists(self.supervisord_partition_configuration_path):
......
...@@ -329,15 +329,17 @@ class Slapgrid(object): ...@@ -329,15 +329,17 @@ class Slapgrid(object):
self.buildout = buildout self.buildout = buildout
self.promise_timeout = promise_timeout self.promise_timeout = promise_timeout
self.develop = develop 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 = \ self.software_release_filter_list = \
software_release_filter_list.split(",") software_release_filter_list.split(",")
else:
self.software_release_filter_list = []
self.computer_partition_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 = \ self.computer_partition_filter_list = \
computer_partition_filter_list.split(",") computer_partition_filter_list.split(",")
self.maximum_periodicity = maximum_periodicity self.maximum_periodicity = maximum_periodicity
def getWatchdogLine(self): def getWatchdogLine(self):
...@@ -559,7 +561,7 @@ class Slapgrid(object): ...@@ -559,7 +561,7 @@ class Slapgrid(object):
# Check if we defined explicit list of partitions to process. # Check if we defined explicit list of partitions to process.
# If so, if current partition not in this list, skip. # 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): (computer_partition_id not in self.computer_partition_filter_list):
return return
...@@ -877,7 +879,7 @@ class Slapgrid(object): ...@@ -877,7 +879,7 @@ class Slapgrid(object):
self.logger.error(UnicodeError) self.logger.error(UnicodeError)
raise UnicodeError("Failed to read %s: %s" % (computer_partition_usage.usage, exc)) raise UnicodeError("Failed to read %s: %s" % (computer_partition_usage.usage, exc))
except (etree.XMLSyntaxError, etree.DocumentInvalid) as 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) self.logger.error(exc)
raise _formatXMLError(exc) raise _formatXMLError(exc)
except Exception as exc: except Exception as exc:
...@@ -985,7 +987,7 @@ class Slapgrid(object): ...@@ -985,7 +987,7 @@ class Slapgrid(object):
clean_run = False clean_run = False
failed_script_list.append("Script %r failed." % script) failed_script_list.append("Script %r failed." % script)
self.logger.warning('Failed to run %r' % invocation_list) 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) computer_partition.error('\n'.join(failed_script_list), logger=self.logger)
# Whatever happens, don't stop processing other instances # Whatever happens, don't stop processing other instances
except Exception: except Exception:
......
...@@ -51,13 +51,6 @@ urllib3_logger = logging.getLogger('requests.packages.urllib3') ...@@ -51,13 +51,6 @@ urllib3_logger = logging.getLogger('requests.packages.urllib3')
urllib3_logger.setLevel(logging.WARNING) 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' DEFAULT_SOFTWARE_TYPE = 'RootSoftwareInstance'
class SlapDocument: class SlapDocument:
...@@ -133,7 +126,7 @@ class SoftwareRelease(SlapDocument): ...@@ -133,7 +126,7 @@ class SoftwareRelease(SlapDocument):
else: else:
return self._software_release return self._software_release
def error(self, error_log, logger=None): def error(self, error_log, logger):
try: try:
# Does not follow interface # Does not follow interface
self._connection_helper.POST('softwareReleaseError', data={ self._connection_helper.POST('softwareReleaseError', data={
...@@ -141,7 +134,7 @@ class SoftwareRelease(SlapDocument): ...@@ -141,7 +134,7 @@ class SoftwareRelease(SlapDocument):
'computer_id': self.getComputerId(), 'computer_id': self.getComputerId(),
'error_log': error_log}) 'error_log': error_log})
except Exception: except Exception:
(logger or fallback_logger).exception('') logger.exception('')
def available(self): def available(self):
self._connection_helper.POST('availableSoftwareRelease', data={ self._connection_helper.POST('availableSoftwareRelease', data={
...@@ -439,14 +432,14 @@ class ComputerPartition(SlapRequester): ...@@ -439,14 +432,14 @@ class ComputerPartition(SlapRequester):
'computer_partition_id': self.getId(), 'computer_partition_id': self.getId(),
}) })
def error(self, error_log, logger=None): def error(self, error_log, logger):
try: try:
self._connection_helper.POST('softwareInstanceError', data={ self._connection_helper.POST('softwareInstanceError', data={
'computer_id': self._computer_id, 'computer_id': self._computer_id,
'computer_partition_id': self.getId(), 'computer_partition_id': self.getId(),
'error_log': error_log}) 'error_log': error_log})
except Exception: except Exception:
(logger or fallback_logger).exception('') logger.exception('')
def bang(self, message): def bang(self, message):
self._connection_helper.POST('softwareInstanceBang', data={ self._connection_helper.POST('softwareInstanceBang', data={
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment