def call(operation, use_mm_panel=True, **kwargs):
    settings = sublime.load_settings('mavensmate.sublime-settings')
    #if the mm tool is missing, we can't do anything
    if not os.path.exists(settings.get('mm_location')) and settings.get('mm_development_mode') == False:
        active_window_id = sublime.active_window().id()
        printer = PanelPrinter.get(active_window_id)
        printer.show()
        message = '[OPERATION FAILED]: Could not find MavensMate.app. Download MavensMate.app from http://www.joe-ferraro.com/mavensmate/MavensMate.app and place in /Applications. Also, please ensure mm_app_location and mm_location are set properly in Sublime Text (MavensMate --> Settings --> User)'
        printer.write('\n'+message+'\n')
        return

    #if it's a legacy project, need to intercept the call and open the upgrade ui
    #TODO: this should probably be handled in mm
    if operation != 'new_project' and operation != 'new_project_from_existing_directory' and util.is_project_legacy() == True:
        operation = 'upgrade_project'
    
    threads = []
    thread = MavensMateTerminalCall(
        operation, 
        project_name=util.get_project_name(kwargs.get('context', None)), 
        active_file=util.get_active_file(), 
        params=kwargs.get('params', None),
        context=kwargs.get('context', None),
        message=kwargs.get('message', None),
        use_mm_panel=use_mm_panel,
        process_id=util.get_random_string(10),
        mm_location=settings.get('mm_location'),
        callback=kwargs.get('callback', None)
    )
    if operation == 'index_apex':
        thread.daemon = True
    threads.append(thread)        
    thread.start()
def call(operation, use_mm_panel=True, **kwargs):
    settings = sublime.load_settings('mavensmate.sublime-settings')
    #if the mm tool is missing, we can't do anything
    if not os.path.exists(settings.get('mm_location')) and settings.get(
            'mm_development_mode') == False:
        active_window_id = sublime.active_window().id()
        printer = PanelPrinter.get(active_window_id)
        printer.show()
        message = '[OPERATION FAILED]: Could not find MavensMate.app. Download MavensMate.app from http://www.joe-ferraro.com/mavensmate/MavensMate.app and place in /Applications. Also, please ensure mm_app_location and mm_location are set properly in Sublime Text (MavensMate --> Settings --> User)'
        printer.write('\n' + message + '\n')
        return

    #if it's a legacy project, need to intercept the call and open the upgrade ui
    #TODO: this should probably be handled in mm
    if operation != 'new_project' and operation != 'new_project_from_existing_directory' and util.is_project_legacy(
    ) == True:
        operation = 'upgrade_project'

    threads = []
    thread = MavensMateTerminalCall(operation,
                                    project_name=util.get_project_name(
                                        kwargs.get('context', None)),
                                    active_file=util.get_active_file(),
                                    params=kwargs.get('params', None),
                                    context=kwargs.get('context', None),
                                    message=kwargs.get('message', None),
                                    use_mm_panel=use_mm_panel,
                                    process_id=util.get_random_string(10),
                                    mm_location=settings.get('mm_location'),
                                    callback=kwargs.get('callback', None))
    if operation == 'index_apex':
        thread.daemon = True
    threads.append(thread)
    thread.start()
    def __init__(self, operation, **kwargs):
        self.operation = operation  #operation being requested
        self.project_name = kwargs.get('project_name', None)
        self.active_file = kwargs.get('active_file', None)
        self.params = kwargs.get('params', None)
        self.context = kwargs.get('context', None)
        self.mm_path = kwargs.get('mm_path', None)
        self.message = kwargs.get('message', None)
        self.view = None
        self.window = None
        self.printer = None
        self.process_id = time.strftime("%a, %d %b %Y %H:%M:%S",
                                        time.localtime())
        self.use_mm_panel = kwargs.get('use_mm_panel', False)
        self.result = None  #result of operation
        self.callback = handle_result
        self.alt_callback = kwargs.get(
            'callback', None)  #this is a callback requested by a command
        self.window_id = None
        self.status_region = None

        self.settings = sublime.load_settings('mavensmate.sublime-settings')
        self.define_sublime_context()
        self.printer = PanelPrinter.get(self.window.id())

        if self.message == None:
            self.message = command_helper.get_message(self.params,
                                                      self.operation)

        if self.project_name == None:
            self.project_name = util.get_project_name(self.window)

        if self.use_mm_panel:
            self.printer.show()
            self.printer.writeln(' ')
            self.printer.writeln(
                '                                                                          '
            )
            self.printer.writeln('Operation: ' + self.message)
            self.printer.writeln('Timestamp: ' + self.process_id)
            self.printer.writeln('   Result:           ')
        elif 'index' not in self.operation:
            ThreadProgress(self, self.message, 'Operation complete')

        threading.Thread.__init__(self)
    def __init__(self, operation, **kwargs):
        self.operation      = operation #operation being requested
        self.project_name   = kwargs.get('project_name', None)
        self.active_file    = kwargs.get('active_file', None)
        self.params         = kwargs.get('params', None)
        self.context        = kwargs.get('context', None)
        self.mm_location    = kwargs.get('mm_location', None)
        self.message        = kwargs.get('message', None)
        self.view           = None
        self.window         = None
        self.printer        = None
        self.process_id     = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
        self.use_mm_panel   = kwargs.get('use_mm_panel', False)
        self.result         = None #result of operation
        self.callback       = handle_result
        self.alt_callback   = kwargs.get('callback', None) #this is a callback requested by a command
        self.window_id      = None
        self.status_region  = None

        self.settings = sublime.load_settings('mavensmate.sublime-settings')
        self.define_sublime_context()
        self.printer = PanelPrinter.get(self.window.id())

        if self.message == None:
            self.message = command_helper.get_message(self.params, self.operation)
        
        if self.project_name == None:
            self.project_name = util.get_project_name(self.window)

        if self.use_mm_panel:
            self.printer.show()
            self.printer.writeln(' ')
            self.printer.writeln('                                                                          ')
            self.printer.writeln('Operation: '+self.message)
            self.printer.writeln('Timestamp: '+self.process_id)
            self.printer.writeln('   Result:           ')
        elif 'index' not in self.operation:
            ThreadProgress(self, self.message, 'Operation complete')

        threading.Thread.__init__(self)
def call(operation, use_mm_panel=True, **kwargs):
    debug('Calling mm_interface')
    debug('OPERATION: ' + operation)
    debug(kwargs)

    settings = sublime.load_settings('mavensmate.sublime-settings')

    if settings.get("mm_developer_mode", False) and not os.path.isfile(
            settings.get("mm_python_location")):
        active_window_id = sublime.active_window().id()
        printer = PanelPrinter.get(active_window_id)
        printer.show()
        message = '[OPERATION FAILED]: mm_developer_mode is set to true, but we could not find your system python install. Please set the location at mm_python_location'
        printer.write('\n' + message + '\n')
        return
    else:
        if settings.get('mm_path',
                        'default') != 'default' and not os.path.isfile(
                            settings.get('mm_path')):
            active_window_id = sublime.active_window().id()
            printer = PanelPrinter.get(active_window_id)
            printer.show()
            message = '[OPERATION FAILED]: Could not find the mm executable. If you wish to use the default location, ensure your mm_path setting is set to "default", then run MavensMate > Install/Update MavensMate API (mm). If you wish to run mm from a different location, ensure mm_path is pointed to that location on your local drive.'
            printer.write('\n' + message + '\n')
            return

        if sys.platform == 'linux' or sys.platform == 'darwin':
            if settings.get('mm_path',
                            'default') == 'default' and not os.path.isfile(
                                os.path.join(sublime.packages_path(), "User",
                                             "MavensMate", "mm", "mm")):
                active_window_id = sublime.active_window().id()
                printer = PanelPrinter.get(active_window_id)
                printer.show()
                message = '[OPERATION FAILED]: Could not find the mm executable. Please run MavensMate > Install/Update MavensMate API (mm) to install mm to your MavensMate for Sublime Text plugin directory.'
                printer.write('\n' + message + '\n')
                return
        else:
            if settings.get('mm_path',
                            'default') == 'default' and not os.path.isfile(
                                os.path.join(sublime.packages_path(), "User",
                                             "MavensMate", "mm", "mm.exe")):
                active_window_id = sublime.active_window().id()
                printer = PanelPrinter.get(active_window_id)
                printer.show()
                message = '[OPERATION FAILED]: Could not find the mm executable. Please run MavensMate > Install/Update MavensMate API (mm) to install mm to your MavensMate for Sublime Text plugin directory.'
                printer.write('\n' + message + '\n')
                return

    if 'linux' in sys.platform:
        if not os.path.isfile(settings.get('mm_subl_location')):
            active_window_id = sublime.active_window().id()
            printer = PanelPrinter.get(active_window_id)
            printer.show()
            message = '[OPERATION FAILED]: Could not locate Sublime Text "subl" executable. Please set mm_subl_location to location of "subl" on the disk.'
            printer.write('\n' + message + '\n')
            return

    if 'win32' in sys.platform:
        if not os.path.isfile(settings.get('mm_windows_subl_location')):
            active_window_id = sublime.active_window().id()
            printer = PanelPrinter.get(active_window_id)
            printer.show()
            message = '[OPERATION FAILED]: Could not locate Sublime Text. Please set mm_windows_subl_location to location of sublime_text.exe on the disk.'
            printer.write('\n' + message + '\n')
            return

    if not util.valid_workspace():
        active_window_id = sublime.active_window().id()
        printer = PanelPrinter.get(active_window_id)
        printer.show()
        message = '[OPERATION FAILED]: Please ensure mm_workspace is set to existing location(s) on your local drive'
        printer.write('\n' + message + '\n')
        return

    window, view = util.get_window_and_view_based_on_context(
        kwargs.get('context', None))

    #if it's a legacy project, need to intercept the call and open the upgrade ui
    #TODO: this should probably be handled in mm
    if operation != 'new_project' and operation != 'new_project_from_existing_directory' and util.is_project_legacy(
            window) == True:
        operation = 'upgrade_project'

    community.sync_activity(operation)

    threads = []
    thread = MavensMateTerminalCall(operation,
                                    project_name=util.get_project_name(window),
                                    active_file=util.get_active_file(),
                                    params=kwargs.get('params', None),
                                    context=kwargs.get('context', None),
                                    message=kwargs.get('message', None),
                                    use_mm_panel=use_mm_panel,
                                    process_id=util.get_random_string(10),
                                    mm_path=settings.get('mm_path'),
                                    callback=kwargs.get('callback', None))
    if operation == 'index_apex':
        thread.daemon = True
    threads.append(thread)
    thread.start()
def call(operation, use_mm_panel=True, **kwargs):
    debug('Calling mm_interface')
    debug('OPERATION: '+operation)
    debug(kwargs)

    settings = sublime.load_settings('mavensmate.sublime-settings')
    
    if settings.get("mm_debug_mode") and not os.path.isfile(settings.get("mm_python_location")):
        active_window_id = sublime.active_window().id()
        printer = PanelPrinter.get(active_window_id)
        printer.show()
        message = '[OPERATION FAILED]: Could not find your system python install. Please set the location at mm_python_location'
        printer.write('\n'+message+'\n')
        return

    if 'darwin' in sys.platform:
        if not os.path.isfile(settings.get('mm_location')) and settings.get('mm_debug_mode') == False:
            active_window_id = sublime.active_window().id()
            printer = PanelPrinter.get(active_window_id)
            printer.show()
            message = '[OPERATION FAILED]: Could not find MavensMate.app. Download MavensMate.app from mavensmate.com and place in /Applications. Also, please ensure mm_app_location and mm_location are set properly in Sublime Text (MavensMate --> Settings --> User)'
            printer.write('\n'+message+'\n')
            return

    if 'linux' in sys.platform:
        if not os.path.isfile(settings.get('mm_subl_location')):
            active_window_id = sublime.active_window().id()
            printer = PanelPrinter.get(active_window_id)
            printer.show()
            message = '[OPERATION FAILED]: Could not locate Sublime Text "subl" executable. Please set mm_subl_location to location of "subl" on the disk.'
            printer.write('\n'+message+'\n')
            return

    if 'win32' in sys.platform:
        if not os.path.isfile(settings.get('mm_windows_subl_location')):
            active_window_id = sublime.active_window().id()
            printer = PanelPrinter.get(active_window_id)
            printer.show()
            message = '[OPERATION FAILED]: Could not locate Sublime Text. Please set mm_windows_subl_location to location of sublime_text.exe on the disk.'
            printer.write('\n'+message+'\n')
            return

    if not util.valid_workspace():
        active_window_id = sublime.active_window().id()
        printer = PanelPrinter.get(active_window_id)
        printer.show()
        message = '[OPERATION FAILED]: Please ensure mm_workspace is set to existing location(s) on your local drive'
        printer.write('\n'+message+'\n')
        return

    window, view = util.get_window_and_view_based_on_context(kwargs.get('context', None))

    #if it's a legacy project, need to intercept the call and open the upgrade ui
    #TODO: this should probably be handled in mm
    if operation != 'new_project' and operation != 'new_project_from_existing_directory' and util.is_project_legacy(window) == True:
        operation = 'upgrade_project'
    


    threads = []
    thread = MavensMateTerminalCall(
        operation, 
        project_name=util.get_project_name(window), 
        active_file=util.get_active_file(), 
        params=kwargs.get('params', None),
        context=kwargs.get('context', None),
        message=kwargs.get('message', None),
        use_mm_panel=use_mm_panel,
        process_id=util.get_random_string(10),
        mm_location=settings.get('mm_location'),
        callback=kwargs.get('callback', None)
    )
    if operation == 'index_apex':
        thread.daemon = True
    threads.append(thread)        
    thread.start()
Example #7
0
 def __init__(self, action):
     self.action = action or ''
     self.project = util.get_project_name() or ''
     self.response = None
     threading.Thread.__init__(self)
def call(operation, use_mm_panel=True, **kwargs):
    debug('Calling mm_interface')
    debug('OPERATION: '+operation)
    debug(kwargs)

    settings = sublime.load_settings('mavensmate.sublime-settings')
    
    if settings.get("mm_developer_mode", False) and not os.path.isfile(settings.get("mm_python_location")):
        active_window_id = sublime.active_window().id()
        printer = PanelPrinter.get(active_window_id)
        printer.show()
        message = '[OPERATION FAILED]: mm_developer_mode is set to true, but we could not find your system python install. Please set the location at mm_python_location'
        printer.write('\n'+message+'\n')
        return
    else:
        if settings.get('mm_path', 'default') != 'default' and not os.path.isfile(settings.get('mm_path')):
            active_window_id = sublime.active_window().id()
            printer = PanelPrinter.get(active_window_id)
            printer.show()
            message = '[OPERATION FAILED]: Could not find the mm executable. If you wish to use the default location, ensure your mm_path setting is set to "default", then run MavensMate > Install/Update MavensMate API (mm). If you wish to run mm from a different location, ensure mm_path is pointed to that location on your local drive.'
            printer.write('\n'+message+'\n')
            return

        if sys.platform == 'linux' or sys.platform == 'darwin':
            if settings.get('mm_path', 'default') == 'default' and not os.path.isfile(os.path.join(sublime.packages_path(),"User","MavensMate","mm","mm")):
                active_window_id = sublime.active_window().id()
                printer = PanelPrinter.get(active_window_id)
                printer.show()
                message = '[OPERATION FAILED]: Could not find the mm executable. Please run MavensMate > Install/Update MavensMate API (mm) to install mm to your MavensMate for Sublime Text plugin directory.'
                printer.write('\n'+message+'\n')
                return
        else:
            if settings.get('mm_path', 'default') == 'default' and not os.path.isfile(os.path.join(sublime.packages_path(),"User","MavensMate","mm","mm.exe")):
                active_window_id = sublime.active_window().id()
                printer = PanelPrinter.get(active_window_id)
                printer.show()
                message = '[OPERATION FAILED]: Could not find the mm executable. Please run MavensMate > Install/Update MavensMate API (mm) to install mm to your MavensMate for Sublime Text plugin directory.'
                printer.write('\n'+message+'\n')
                return 

    if 'linux' in sys.platform:
        if not os.path.isfile(settings.get('mm_subl_location')):
            active_window_id = sublime.active_window().id()
            printer = PanelPrinter.get(active_window_id)
            printer.show()
            message = '[OPERATION FAILED]: Could not locate Sublime Text "subl" executable. Please set mm_subl_location to location of "subl" on the disk.'
            printer.write('\n'+message+'\n')
            return

    if 'win32' in sys.platform:
        if not os.path.isfile(settings.get('mm_windows_subl_location')):
            active_window_id = sublime.active_window().id()
            printer = PanelPrinter.get(active_window_id)
            printer.show()
            message = '[OPERATION FAILED]: Could not locate Sublime Text. Please set mm_windows_subl_location to location of sublime_text.exe on the disk.'
            printer.write('\n'+message+'\n')
            return

    if not util.valid_workspace():
        active_window_id = sublime.active_window().id()
        printer = PanelPrinter.get(active_window_id)
        printer.show()
        message = '[OPERATION FAILED]: Please ensure mm_workspace is set to existing location(s) on your local drive'
        printer.write('\n'+message+'\n')
        return

    window, view = util.get_window_and_view_based_on_context(kwargs.get('context', None))

    #if it's a legacy project, need to intercept the call and open the upgrade ui
    #TODO: this should probably be handled in mm
    if operation != 'new_project' and operation != 'new_project_from_existing_directory' and util.is_project_legacy(window) == True:
        operation = 'upgrade_project'
    
    community.sync_activity(operation)

    threads = []
    thread = MavensMateTerminalCall(
        operation, 
        project_name=util.get_project_name(window), 
        active_file=util.get_active_file(), 
        params=kwargs.get('params', None),
        context=kwargs.get('context', None),
        message=kwargs.get('message', None),
        use_mm_panel=use_mm_panel,
        process_id=util.get_random_string(10),
        mm_path=settings.get('mm_path'),
        callback=kwargs.get('callback', None)
    )
    if operation == 'index_apex':
        thread.daemon = True
    threads.append(thread)        
    thread.start()