def run(self):
        if self.use_mm_panel:
            if sys.version_info >= (3, 0):
                self.calculate_process_region()
            PanelThreadProgress(self)

        #last_thread = ThreadTracker.get_last_added(self.window)
        ThreadTracker.add(self)

        if self.settings.get('mm_debug_mode'):
            python_path = self.settings.get('mm_python_location')
            mm_loc = self.settings.get('mm_debug_location')
            print('[MAVENSMATE] executing DEBUG mm terminal call:')
            print("{0} {1} {2}".format(python_path, pipes.quote(mm_loc), self.get_arguments()))
            process = subprocess.Popen("{0} {1} {2}".format(python_path, pipes.quote(mm_loc), self.get_arguments()), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        else:
            print('[MAVENSMATE] executing mm terminal call:')
            print("{0} {1}".format(pipes.quote(self.mm_location), self.get_arguments()))
            process = subprocess.Popen("{0} {1}".format(self.mm_location, self.get_arguments()), cwd=sublime.packages_path(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        self.submit_payload(process)
        if process.stdout is not None: 
            mm_response = process.stdout.readlines()
        elif process.stderr is not None:
            mm_response = process.stderr.readlines()
        try:
            response_body = '\n'.join(mm_response)
        except:
            strs = []
            for line in mm_response:
                strs.append(line.decode('utf-8'))   
            response_body = '\n'.join(strs)

        print('[MAVENSMATE] response from mm: ' + response_body)
        self.result = response_body
        if self.operation == 'compile':
            compile_callback(self, response_body)
        
        #if self.operation == 'new_apex_overlay' or self.operation == 'delete_apex_overlay':
        #    sublime.set_timeout(lambda : index_overlays(self.window), 100)
        
        #if self.callback != None:
        #    print(self.callback)
        #    self.callback(response_body)

        if sys.version_info >= (3, 0):
            self.calculate_process_region()
            
        ThreadTracker.remove(self)
    def run(self):
        if self.use_mm_panel:
            if sys.version_info >= (3, 0):
                self.calculate_process_region()
            PanelThreadProgress(self)

        #last_thread = ThreadTracker.get_last_added(self.window)
        ThreadTracker.add(self)

        if self.settings.get('mm_debug_mode') or 'darwin' not in sys.platform:
            python_path = self.settings.get('mm_python_location')
            if 'darwin' in sys.platform or self.settings.get('mm_debug_location') != None:
                mm_loc = self.settings.get('mm_debug_location')
            else:
                mm_loc = os.path.join(config.mm_dir,"mm","mm.py") #mm.py is bundled with sublime text plugin
            
            if 'linux' in sys.platform or 'darwin' in sys.platform:
                #osx, linux
                debug('executing mm terminal call:')
                debug("{0} {1} {2}".format(python_path, pipes.quote(mm_loc), self.get_arguments()))
                process = subprocess.Popen('\'{0}\' \'{1}\' {2}'.format(python_path, mm_loc, self.get_arguments()), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
            else:
                #windows
                if self.settings.get('mm_debug_mode', False):
                    #user wishes to use system python
                    python_path = self.settings.get('mm_python_location')
                    process = subprocess.Popen('"{0}" "{1}" {2}'.format(python_path, mm_loc, self.get_arguments()), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
                else:
                    python_path = os.path.join(os.environ["ProgramFiles"],"MavensMate","App","python.exe")
                    if not os.path.isfile(python_path):
                        python_path = python_path.replace("Program Files", "Program Files (x86)")
                    debug('executing mm terminal call:')
                    debug('"{0}" -E "{1}" {2}'.format(python_path, mm_loc, self.get_arguments()))
                    process = subprocess.Popen('"{0}" -E "{1}" {2}'.format(python_path, mm_loc, self.get_arguments()), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        else:
            debug('executing mm terminal call:')
            debug("{0} {1}".format(pipes.quote(self.mm_location), self.get_arguments()))
            process = subprocess.Popen("{0} {1}".format(self.mm_location, self.get_arguments()), cwd=sublime.packages_path(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        self.submit_payload(process)
        if process.stdout is not None: 
            mm_response = process.stdout.readlines()
        elif process.stderr is not None:
            mm_response = process.stderr.readlines()
        try:
            response_body = '\n'.join(mm_response)
        except:
            strs = []
            for line in mm_response:
                strs.append(line.decode('utf-8'))   
            response_body = '\n'.join(strs)

        debug('response from mm: ' + response_body)
        self.result = response_body
        if self.operation == 'compile':
            compile_callback(self, response_body)
        
        #if self.operation == 'new_apex_overlay' or self.operation == 'delete_apex_overlay':
        #    sublime.set_timeout(lambda : index_overlays(self.window), 100)
        
        #if self.callback != None:
        #    debug(self.callback)
        #    self.callback(response_body)

        if sys.version_info >= (3, 0):
            self.calculate_process_region()
            
        ThreadTracker.remove(self)
    def run(self):
        if self.use_mm_panel:
            if sys.version_info >= (3, 0):
                self.calculate_process_region()
            PanelThreadProgress(self)

        #last_thread = ThreadTracker.get_last_added(self.window)
        ThreadTracker.add(self)

        if self.settings.get('mm_debug_mode'):
            python_path = self.settings.get('mm_python_location')
            mm_loc = self.settings.get('mm_debug_location')
            print('[MAVENSMATE] executing DEBUG mm terminal call:')
            print("{0} {1} {2}".format(python_path, pipes.quote(mm_loc),
                                       self.get_arguments()))
            process = subprocess.Popen("{0} {1} {2}".format(
                python_path, pipes.quote(mm_loc), self.get_arguments()),
                                       stdin=subprocess.PIPE,
                                       stdout=subprocess.PIPE,
                                       stderr=subprocess.STDOUT,
                                       shell=True)
        else:
            print('[MAVENSMATE] executing mm terminal call:')
            print("{0} {1}".format(pipes.quote(self.mm_location),
                                   self.get_arguments()))
            process = subprocess.Popen("{0} {1}".format(
                self.mm_location, self.get_arguments()),
                                       cwd=sublime.packages_path(),
                                       stdin=subprocess.PIPE,
                                       stdout=subprocess.PIPE,
                                       stderr=subprocess.STDOUT,
                                       shell=True)
        self.submit_payload(process)
        if process.stdout is not None:
            mm_response = process.stdout.readlines()
        elif process.stderr is not None:
            mm_response = process.stderr.readlines()
        try:
            response_body = '\n'.join(mm_response)
        except:
            strs = []
            for line in mm_response:
                strs.append(line.decode('utf-8'))
            response_body = '\n'.join(strs)

        print('[MAVENSMATE] response from mm: ' + response_body)
        self.result = response_body
        if self.operation == 'compile':
            compile_callback(self, response_body)

        #if self.operation == 'new_apex_overlay' or self.operation == 'delete_apex_overlay':
        #    sublime.set_timeout(lambda : index_overlays(self.window), 100)

        #if self.callback != None:
        #    print(self.callback)
        #    self.callback(response_body)

        if sys.version_info >= (3, 0):
            self.calculate_process_region()

        ThreadTracker.remove(self)