text
stringlengths
0
828
if self.error_occured:
self.logger.error(warning_template)
self.logger.error(REMOVE_WARNING)
except Exception:
self.logger.debug("""", exc_info=sys.exc_info())
et, ei, tb = sys.exc_info()
reraise(et, ei, tb)"
1384,"def deactivate(self):
"""""" deactivate the environment """"""
try:
self.phase = PHASE.DEACTIVATE
self.logger.info(""Deactivating environment %s..."" % self.namespace)
self.directory.rewrite_config = False
self.instantiate_features()
self._specialize()
for feature in self.features.run_order:
self.logger.info(""Deactivating %s..."" % feature[0])
self.run_action(feature, 'deactivate')
self.clear_all()
self._finalize()
except Exception:
self.logger.debug("""", exc_info=sys.exc_info())
et, ei, tb = sys.exc_info()
reraise(et, ei, tb)"
1385,"def validate(self):
"""""" Validate the target environment """"""
self.phase = PHASE.VALIDATE
self.logger.info(""Validating %s..."" % self.namespace)
self.instantiate_features()
context_dict = {}
if self.target:
for s in self.target.formula_sections():
context_dict[""%s:root_dir"" % s] = self.directory.install_directory(s)
context_dict['config:root_dir'] = self.directory.root_dir
context_dict['config:node'] = system.NODE
self.target.add_additional_context(context_dict)
for feature in self.features.run_order:
self.run_action(feature, 'validate', run_if_error=True)"
1386,"def clear_all(self):
"""""" clear all files that were to be injected """"""
self.injections.clear_all()
for config_file in CONFIG_FILES:
self.injections.clear(os.path.join(""~"", config_file))"
1387,"def write_debug_log(self, file_path):
"""""" Write the debug log to a file """"""
with open(file_path, ""wb+"") as fh:
fh.write(system.get_system_info().encode('utf-8'))
# writing to debug stream
self._debug_stream.seek(0)
fh.write(self._debug_stream.read().encode('utf-8'))
fh.write(""The following errors occured:\n"".encode('utf-8'))
for error in self._errors:
fh.write((error + ""\n"").encode('utf-8'))
for k, v in self._error_dict.items():
if len(v) > 0:
fh.write((""Error(s) in %s with formula %s:\n"" % k).encode('utf-8'))
for error in v:
fh.write((error + ""\n"").encode('utf-8'))"
1388,"def write_manifest(self):
"""""" Write the manifest to the file """"""
if os.path.exists(self.directory.manifest_path):
self.main_manifest.write(open(self.directory.manifest_path, ""w+""))"
1389,"def message_failure(self):
"""""" return a failure message, if one exists """"""
if not isinstance(self.main_manifest, Manifest):
return None
return self.main_manifest.get('config', 'message_failure', default=None)"
1390,"def warmup(self):
"""""" initialize variables necessary to perform a sprinter action """"""
self.logger.debug(""Warming up..."")
try:
if not isinstance(self.source, Manifest) and self.source:
self.source = load_manifest(self.source)
if not isinstance(self.target, Manifest) and self.target:
self.target = load_manifest(self.target)
self.main_manifest = self.target or self.source
except lib.BadCredentialsException:
e = sys.exc_info()[1]
self.logger.error(str(e))
raise SprinterException(""Fatal error! Bad credentials to grab manifest!"")
if not getattr(self, 'namespace', None):
if self.target:
self.namespace = self.target.namespace
elif not self.namespace and self.source:
self.namespace = self.source.namespace
else:
raise SprinterException(""No environment name has been specified!"")
self.directory_root = self.custom_directory_root
if not self.directory:
if not self.directory_root:
self.directory_root = os.path.join(self.root, self.namespace)
self.directory = Directory(self.directory_root,
shell_util_path=self.shell_util_path)
if not self.injections: