text
stringlengths
0
828
return False"
1377,"def getmethattr(obj, meth):
""""""
Returns either the variable value or method invocation
""""""
if hasmethod(obj, meth):
return getattr(obj, meth)()
elif hasvar(obj, meth):
return getattr(obj, meth)
return None"
1378,"def assure_obj_child_dict(obj, var):
""""""Assure the object has the specified child dict
""""""
if not var in obj or type(obj[var]) != type({}):
obj[var] = {}
return obj"
1379,"def warmup(f):
"""""" Decorator to run warmup before running a command """"""
@wraps(f)
def wrapped(self, *args, **kwargs):
if not self.warmed_up:
self.warmup()
return f(self, *args, **kwargs)
return wrapped"
1380,"def install_required(f):
"""""" Return an exception if the namespace is not already installed """"""
@wraps(f)
def wrapped(self, *args, **kwargs):
if self.directory.new:
raise SprinterException(""Namespace %s is not yet installed!"" % self.namespace)
return f(self, *args, **kwargs)
return wrapped"
1381,"def install(self):
"""""" Install the environment """"""
self.phase = PHASE.INSTALL
if not self.directory.new:
self.logger.info(""Namespace %s directory already exists!"" % self.namespace)
self.source = load_manifest(self.directory.manifest_path)
return self.update()
try:
self.logger.info(""Installing environment %s..."" % self.namespace)
self.directory.initialize()
self.install_sandboxes()
self.instantiate_features()
self.grab_inputs()
self._specialize()
for feature in self.features.run_order:
self.run_action(feature, 'sync')
self.inject_environment_config()
self._finalize()
except Exception:
self.logger.debug("""", exc_info=sys.exc_info())
self.logger.info(""An error occured during installation!"")
if not self.ignore_errors:
self.clear_all()
self.logger.info(""Removing installation %s..."" % self.namespace)
self.directory.remove()
et, ei, tb = sys.exc_info()
reraise(et, ei, tb)"
1382,"def update(self, reconfigure=False):
"""""" update the environment """"""
try:
self.phase = PHASE.UPDATE
self.logger.info(""Updating environment %s..."" % self.namespace)
self.install_sandboxes()
self.instantiate_features()
# We don't grab inputs, only on install
# updates inputs are grabbed on demand
# self.grab_inputs(reconfigure=reconfigure)
if reconfigure:
self.grab_inputs(reconfigure=True)
else:
self._copy_source_to_target()
self._specialize(reconfigure=reconfigure)
for feature in self.features.run_order:
self.run_action(feature, 'sync')
self.inject_environment_config()
self._finalize()
except Exception:
self.logger.debug("""", exc_info=sys.exc_info())
et, ei, tb = sys.exc_info()
reraise(et, ei, tb)"
1383,"def remove(self):
"""""" remove the environment """"""
try:
self.phase = PHASE.REMOVE
self.logger.info(""Removing environment %s..."" % self.namespace)
self.instantiate_features()
self._specialize()
for feature in self.features.run_order:
try:
self.run_action(feature, 'sync')
except FormulaException:
# continue trying to remove any remaining features.
pass
self.clear_all()
self.directory.remove()
self.injections.commit()