# Path: igor/log.py
# def configure(fn):
# def backlog():
# def getLogger(name):
# 
# Path: igor/utils.py
# def run(cmd, with_retval=False):
#     import subprocess
#     logger.debug("Running: %s" % cmd)
#     child = subprocess.Popen(cmd, shell=True,
#                              stdout=subprocess.PIPE,
#                              stderr=subprocess.PIPE)
#     (stdout, stderr) = child.communicate()
#     # pylint: disable-msg=E1101
#     child.wait()
#     if stderr:
#         logger.warning(stderr)
#     r = str(stdout).strip()
#     if with_retval:
#         r = (child.returncode, str(stdout).strip())
#     # pylint: enable-msg=E1101
#     return r
# 
# def update_properties_only(obj, kwargs):
#     """Update the properties of obj according to kwargs if obj has a property
#     of these names
# 
#     Args:
#         obj: The object to update
#         kwargs: A dict mapping (prop, value)
# 
#     >>> class Foo(object):
#     ...     bar = None
#     ...     def baz(self):
#     ...         return "baz"
# 
#     >>> class Foo2(Foo):
#     ...     bar2 = None
# 
#     >>> kwargs = {"bar": True, "xyz": False, "baz": None, "bar2": True}
#     >>> obj = Foo2()
#     >>> obj.bar
# 
#     >>> update_properties_only(obj, kwargs)
# 
#     >>> obj.bar
#     True
#     >>> obj.bar2
#     True
#     >>> hasattr(obj, "xyz")
#     False
#     >>> callable(obj.baz)
#     True
#     """
# 
#     subt = type(obj)
#     tdict = {}
#     for t in subt.mro():
#         tdict.update(t.__dict__)
#     allowed_args = {k: v for k, v in kwargs.items()
#                     if k in tdict and not callable(tdict[k])}
#     logger.debug("Updating properties of %s: %s" % (obj, allowed_args))
#     if kwargs and not allowed_args:
#         logger.debug("Request to update props, but non are allowed")
#         logger.debug("Requested: '%s'" % kwargs)
#         logger.debug("Object props: '%s'" % tdict)
#     obj.__dict__.update(allowed_args)


from igor import log
from igor.utils import run, update_properties_only
import io
import os
import random
import tarfile
import tempfile
import time
        self.variables["planid"] = self.id
        logger.debug("Replacing vars in spec %s: %s" % (self.name,
                                                        self.variables))
        for layout in self.job_layouts:
            """A generator is used (yield), because a followup spec might
            depend on infos from a previous spec (e.g. a host gets created)
            """
            yield self.spec_from_layout(layout)

    def spec_from_layout(self, layout):
        spec = JobSpec()
        logger.debug("Creating spec for job layout '%s'" % layout)
        for k, func in [("testsuite", self.inventory.testsuites),
                        ("profile", self.inventory.profiles),
                        ("host", self.inventory.hosts),
                        ("additional_kargs", lambda x: x)]:
            kwargs = {}
            if k in layout and layout[k] is not None:
                v, kwargs = self._parse_toplevel_field_value(k, layout[k])
                layout[k] = v
            else:
                layout[k] = ""

            logger.debug("Handling top-level item '%s', with kwargs '%s'" %
                         (k, kwargs))

            item = func(v)

            logger.debug("New item: %s" % item)
            if kwargs and hasattr(item, "__dict__"):

# Path: igor/log.py
# def configure(fn):
# def backlog():
# def getLogger(name):
# 
# Path: igor/utils.py
# def run(cmd, with_retval=False):
#     import subprocess
#     logger.debug("Running: %s" % cmd)
#     child = subprocess.Popen(cmd, shell=True,
#                              stdout=subprocess.PIPE,
#                              stderr=subprocess.PIPE)
#     (stdout, stderr) = child.communicate()
#     # pylint: disable-msg=E1101
#     child.wait()
#     if stderr:
#         logger.warning(stderr)
#     r = str(stdout).strip()
#     if with_retval:
#         r = (child.returncode, str(stdout).strip())
#     # pylint: enable-msg=E1101
#     return r
# 
# def update_properties_only(obj, kwargs):
#     """Update the properties of obj according to kwargs if obj has a property
#     of these names
# 
#     Args:
#         obj: The object to update
#         kwargs: A dict mapping (prop, value)
# 
#     >>> class Foo(object):
#     ...     bar = None
#     ...     def baz(self):
#     ...         return "baz"
# 
#     >>> class Foo2(Foo):
#     ...     bar2 = None
# 
#     >>> kwargs = {"bar": True, "xyz": False, "baz": None, "bar2": True}
#     >>> obj = Foo2()
#     >>> obj.bar
# 
#     >>> update_properties_only(obj, kwargs)
# 
#     >>> obj.bar
#     True
#     >>> obj.bar2
#     True
#     >>> hasattr(obj, "xyz")
#     False
#     >>> callable(obj.baz)
#     True
#     """
# 
#     subt = type(obj)
#     tdict = {}
#     for t in subt.mro():
#         tdict.update(t.__dict__)
#     allowed_args = {k: v for k, v in kwargs.items()
#                     if k in tdict and not callable(tdict[k])}
#     logger.debug("Updating properties of %s: %s" % (obj, allowed_args))
#     if kwargs and not allowed_args:
#         logger.debug("Request to update props, but non are allowed")
#         logger.debug("Requested: '%s'" % kwargs)
#         logger.debug("Object props: '%s'" % tdict)
#     obj.__dict__.update(allowed_args)


# Path: igor/daemon/main.py
from igor import log
from igor.utils import run, update_properties_only
import io
import os
import random
import tarfile
import tempfile
import time

        self.variables["planid"] = self.id
        logger.debug("Replacing vars in spec %s: %s" % (self.name,
                                                        self.variables))
        for layout in self.job_layouts:
            """A generator is used (yield), because a followup spec might
            depend on infos from a previous spec (e.g. a host gets created)
            """
            yield self.spec_from_layout(layout)

    def spec_from_layout(self, layout):
        spec = JobSpec()
        logger.debug("Creating spec for job layout '%s'" % layout)
        for k, func in [("testsuite", self.inventory.testsuites),
                        ("profile", self.inventory.profiles),
                        ("host", self.inventory.hosts),
                        ("additional_kargs", lambda x: x)]:
            kwargs = {}
            if k in layout and layout[k] is not None:
                v, kwargs = self._parse_toplevel_field_value(k, layout[k])
                layout[k] = v
            else:
                layout[k] = ""

            logger.debug("Handling top-level item '%s', with kwargs '%s'" %
                         (k, kwargs))

            item = func(v)

            logger.debug("New item: %s" % item)
            if kwargs and hasattr(item, "__dict__"):

                update_properties_only(item, kwargs)