'Wrap function as appropriate for calling by parallel_simple.'

def _make_parallel_wrapper(self, function, machines, log):

    is_forking = (not ((len(machines) == 1) and (self.machines == machines)))
    if (self._parse_job and is_forking and log):
        def wrapper(machine):
            self._parse_job += ('/' + machine)
            self._using_parser = True
            self.machines = [machine]
            self.push_execution_context(machine)
            os.chdir(self.resultdir)
            utils.write_keyval(self.resultdir, {'hostname': machine})
            self.init_parser()
            result = function(machine)
            self.cleanup_parser()
            return result
    elif ((len(machines) > 1) and log):
        def wrapper(machine):
            self.push_execution_context(machine)
            os.chdir(self.resultdir)
            machine_data = {'hostname': machine, 'status_version': str(self._STATUS_VERSION)}
            utils.write_keyval(self.resultdir, machine_data)
            result = function(machine)
            return result
    else:
        wrapper = function
    return wrapper
