def execute(self, job, stats, localTempDir, globalTempDir, 
                memoryAvailable, cpuAvailable,
                defaultMemory, defaultCpu, depth):
        self.tempDirAccessed = False
        self.localTempDir = localTempDir
        self.globalTempDir = globalTempDir
        
        if stats != None:
            startTime = time.time()
            startClock = getTotalCpuTime()
        
        baseDir = os.getcwd()
        
        self.target.setStack(self)
        #Debug check that we have the right amount of CPU and memory for the job in hand
        targetMemory = self.target.getMemory()
        if targetMemory != sys.maxint:
            assert targetMemory <= memoryAvailable
        targetCpu = self.target.getCpu()
        if targetCpu != sys.maxint:
            assert targetCpu <= cpuAvailable
        #Run the target, first cleanup then run.
        self.target.run()
        #Change dir back to cwd dir, if changed by target (this is a safety issue)
        if os.getcwd() != baseDir:
            os.chdir(baseDir)
        #Cleanup after the target
        if self.tempDirAccessed:
            system("rm -rf %s/*" % self.localTempDir)
            self.tempDirAccessed = False
        #Handle the follow on
        followOn = self.target.getFollowOn()
        if followOn is not None: #Target to get rid of follow on when done.
            if self.target.isGlobalTempDirSet():
                followOn.setGlobalTempDir(self.target.getGlobalTempDir())
            followOnStack = Stack(followOn)
            job.followOnCommands.append((followOnStack.makeRunnable(self.globalTempDir),
                                         followOnStack.getMemory(defaultMemory),
                                         followOnStack.getCpu(defaultCpu),
                                         depth))
        
        #Now add the children to the newChildren stack
        newChildren = self.target.getChildren()
        newChildren.reverse()
        assert len(job.children) == 0
        while len(newChildren) > 0:
            childStack = Stack(newChildren.pop())
            job.children.append((childStack.makeRunnable(self.globalTempDir),
                     childStack.getMemory(defaultMemory),
                     childStack.getCpu(defaultCpu)))
        
         #Now build jobs for each child command
        for childCommand, runTime in self.target.getChildCommands():
            job.children.append((childCommand, defaultMemory, defaultCpu))
            
        for message in self.target.getMasterLoggingMessages():
            job.messages.append(message)
        
        #Finish up the stats
        if stats != None:
            stats = ET.SubElement(stats, "target")
            stats.attrib["time"] = str(startTime - time.time())
            totalCpuTime, totalMemoryUsage = getTotalCpuTimeAndMemoryUsage()
            stats.attrib["clock"] = str(totalCpuTime - startClock)
            stats.attrib["class"] = ".".join((self.target.__class__.__name__,))
            stats.attrib["memory"] = str(totalMemoryUsage)
dataset/ETHPy150Open benedictpaten/jobTree/scriptTree/stack.py/Stack.execute/swapped operands of `-`