'Execute code using a copy of namespace as a server control script.
Unless protect_namespace is explicitly set to False, the dict will not
be modified.
Args:
code_file: The filename of the control file to execute.
namespace: A dict containing names to make available during execution.
protect: Boolean.  If True (the default) a copy of the namespace dict
is used during execution to prevent the code from modifying its
contents outside of this function.  If False the raw dict is
passed in and modifications will be allowed.'

def _execute_code(self, code_file, namespace, protect=True):

    if protect:
        namespace = namespace.copy()
    self._fill_server_control_namespace(namespace, protect=protect)
    if (len(self.machines) > 1):
        machines_text = ('\n'.join(self.machines) + '\n')
        try:
            machines_f = open(MACHINES_FILENAME, 'r')
            existing_machines_text = machines_f.read()
            machines_f.close()
        except EnvironmentError:
            existing_machines_text = None
        if (machines_text != existing_machines_text):
            utils.open_write_close(MACHINES_FILENAME, machines_text)
    execfile(code_file, namespace, namespace)
