コード例 #1
0
def handle_result(operation, process_id, printer, result, thread):
    #print(thread.process_id)
    #print(thread.params)
    process_region = printer.panel.find(process_id,0)
    status_region = printer.panel.find('Result:',process_region.begin())

    try:
        result = json.loads(result)
        if operation == 'compile' and 'actions' in result and util.to_bool(result['success']) == False:
            diff_merge_settings = config.settings.get('mm_diff_server_conflicts', False)
            if diff_merge_settings:
                if sublime.ok_cancel_dialog(result["body"], result["actions"][0].title()):
                    printer.panel.run_command('write_operation_status', {"text": " Diffing with server", 'region': [status_region.end(), status_region.end()+10] })
                    th = MavensMateDiffThread(thread.window, thread.view, result['tmp_file_path'])
                    th.start()
                    
                else:
                    printer.panel.run_command('write_operation_status', {"text": " "+result["actions"][1].title(), 'region': [status_region.end(), status_region.end()+10] })
            else:
                if sublime.ok_cancel_dialog(result["body"], "Overwrite Server Copy"):
                    printer.panel.run_command('write_operation_status', {"text": " Overwriting server copy", 'region': [status_region.end(), status_region.end()+10] })
                    thread.params['action'] = 'overwrite'
                    sublime.set_timeout(lambda: call('compile', params=thread.params), 100)   
                else:
                    printer.panel.run_command('write_operation_status', {"text": " "+result["actions"][1].title(), 'region': [status_region.end(), status_region.end()+10] })
   
        else:
            print_result_message(operation, process_id, status_region, result, printer, thread) 
            if operation == 'new_metadata' and 'success' in result and util.to_bool(result['success']) == True:
                if 'messages' in result:
                    if type(result['messages']) is not list:
                        result['messages'] = [result['messages']]
                    for m in result['messages']:
                        if 'package.xml' not in m['fileName']:
                            file_name = m['fileName']
                            location = util.mm_project_directory() + "/" + file_name.replace('unpackaged/', 'src/')
                            sublime.active_window().open_file(location)
                            break
            if 'success' in result and util.to_bool(result['success']) == True:
                if printer != None and len(ThreadTracker.get_pending_mm_panel_threads(thread.window)) == 0:
                    printer.hide()  
            elif 'State' in result and result['State'] == 'Completed' and len(ThreadTracker.get_pending_mm_panel_threads(thread.window)) == 0:
                #tooling api
                if printer != None:
                    printer.hide()
            if operation == 'refresh':            
                sublime.set_timeout(lambda: sublime.active_window().active_view().run_command('revert'), 200)
                util.clear_marked_line_numbers()
    except AttributeError:   
        if printer != None:
            printer.write('\n[RESPONSE FROM MAVENSMATE]: '+result+'\n')
            msg = ' [OPERATION FAILED]: Whoops, unable to parse the response. Please report this issue at https://github.com/joeferraro/MavensMate-SublimeText\n'
            msg += '[RESPONSE FROM MAVENSMATE]: '+result
            printer.panel.run_command('write_operation_status', {'text': msg, 'region': [status_region.end(), status_region.end()+10] })
    except Exception:
        if printer != None:
            printer.write('\n[RESPONSE FROM MAVENSMATE]: '+result+'\n')
            msg = ' [OPERATION FAILED]: Whoops, unable to parse the response. Please report this issue at https://github.com/joeferraro/MavensMate-SublimeText\n'
            msg += '[RESPONSE FROM MAVENSMATE]: '+result
            printer.panel.run_command('write_operation_status', {'text': msg, 'region': [status_region.end(), status_region.end()+10] })
コード例 #2
0
 def __finish(self):
     try:
         if self.operation == 'refresh':
             sublime.set_timeout(lambda: sublime.active_window().active_view().run_command('revert'), 200)
             util.clear_marked_line_numbers()
     except:
         pass #TODO
コード例 #3
0
 def __finish(self):
     try:
         if self.operation == 'refresh':
             sublime.set_timeout(lambda: sublime.active_window().active_view().run_command('revert'), 200)
             util.clear_marked_line_numbers()
     except:
         pass #TODO
コード例 #4
0
 def __finish(self):
     if 'success' in self.result and util.to_bool(self.result['success']) == True:
         if self.printer != None and len(ThreadTracker.get_pending_mm_panel_threads(self.thread.window)) == 0:
             self.printer.hide() 
     elif 'State' in self.result and self.result['State'] == 'Completed' and len(ThreadTracker.get_pending_mm_panel_threads(self.thread.window)) == 0:
         if self.printer != None:
             self.printer.hide()
     if self.operation == 'refresh':            
         sublime.set_timeout(lambda: sublime.active_window().active_view().run_command('revert'), 200)
         util.clear_marked_line_numbers()
コード例 #5
0
 def __finish(self):
     try:
         if 'success' in self.result and util.to_bool(self.result['success']) == True:
             if self.printer != None and len(ThreadTracker.get_pending_mm_panel_threads(self.thread.window)) == 0:
                 self.printer.hide() 
         elif 'State' in self.result and self.result['State'] == 'Completed' and len(ThreadTracker.get_pending_mm_panel_threads(self.thread.window)) == 0:
             if self.printer != None:
                 self.printer.hide()
         if self.operation == 'refresh':            
             sublime.set_timeout(lambda: sublime.active_window().active_view().run_command('revert'), 200)
             util.clear_marked_line_numbers()
     except:
         pass #TODO
コード例 #6
0
def compile_callback(thread, result):
    try:
        result = json.loads(result)
        if 'success' in result and result['success'] == True:
            util.clear_marked_line_numbers(thread.view)
            #if settings.get('mm_autocomplete') == True:
            sublime.set_timeout(lambda: index_apex_code(thread), 100)
        elif 'State' in result and result['State'] == 'Completed':
            util.clear_marked_line_numbers(thread.view)
            #if settings.get('mm_autocomplete') == True:
            sublime.set_timeout(lambda: index_apex_code(thread), 100)
    except BaseException as e:
        debug('Issue handling compile result in callback')
        debug(e)
コード例 #7
0
def compile_callback(thread, result):
    try:
        result = json.loads(result)
        if 'success' in result and result['success'] == True:
            util.clear_marked_line_numbers(thread.view)
            #if settings.get('mm_autocomplete') == True: 
            sublime.set_timeout(lambda: index_apex_code(thread), 100)
        elif 'State' in result and result['State'] == 'Completed':
            util.clear_marked_line_numbers(thread.view)
            #if settings.get('mm_autocomplete') == True: 
            sublime.set_timeout(lambda: index_apex_code(thread), 100)
    except BaseException as e:
        debug('Issue handling compile result in callback')
        debug(e) 
コード例 #8
0
 def __finish(self):
     try:
         if "success" in self.result and util.to_bool(self.result["success"]) == True:
             if self.printer != None and len(ThreadTracker.get_pending_mm_panel_threads(self.thread.window)) == 0:
                 self.printer.hide()
         elif (
             "State" in self.result
             and self.result["State"] == "Completed"
             and len(ThreadTracker.get_pending_mm_panel_threads(self.thread.window)) == 0
         ):
             if self.printer != None:
                 self.printer.hide()
         if self.operation == "refresh":
             sublime.set_timeout(lambda: sublime.active_window().active_view().run_command("revert"), 200)
             util.clear_marked_line_numbers()
     except:
         pass  # TODO
コード例 #9
0
def compile_callback(thread, result):
    try:
        result = json.loads(result)
        if 'success' in result and result['success'] == True:
            util.clear_marked_line_numbers(thread.view)
            #if settings.get('mm_autocomplete') == True:
            sublime.set_timeout(lambda: index_apex_code(thread), 100)
        elif 'State' in result and result['State'] == 'Completed':
            util.clear_marked_line_numbers(thread.view)
            #if settings.get('mm_autocomplete') == True:
            sublime.set_timeout(lambda: index_apex_code(thread), 100)
            notify(title='Success',
                   subtitle=thread.active_file.rsplit('/', 1).pop(),
                   message='Compilation was successful!',
                   url='file://' + thread.active_file)
        else:
            notify(title='Failed',
                   subtitle=thread.active_file.rsplit('/', 1).pop(),
                   message='Compilation failed!',
                   url='file://' + thread.active_file)
    except BaseException as e:
        debug('Issue handling compile result in callback')
        debug(e)
コード例 #10
0
def handle_result(operation, process_id, printer, result, thread):
    #print(thread.process_id)
    #print(thread.params)
    process_region = printer.panel.find(process_id,0)
    status_region = printer.panel.find('Result:',process_region.begin())

    try:
        result = json.loads(result)
        if operation == 'compile' and 'actions' in result and util.to_bool(result['success']) == False:
            diff_merge_settings = config.settings.get('mm_diff_server_conflicts', False)
            if diff_merge_settings:
                if sublime.ok_cancel_dialog(result["body"], result["actions"][0].title()):
                    printer.panel.run_command('write_operation_status', {"text": " Diffing with server", 'region': [status_region.end(), status_region.end()+10] })
                    th = MavensMateDiffThread(thread.window, thread.view, result['tmp_file_path'])
                    th.start()
                    
                else:
                    printer.panel.run_command('write_operation_status', {"text": " "+result["actions"][1].title(), 'region': [status_region.end(), status_region.end()+10] })
            else:
                if sublime.ok_cancel_dialog(result["body"], "Overwrite Server Copy"):
                    printer.panel.run_command('write_operation_status', {"text": " Overwriting server copy", 'region': [status_region.end(), status_region.end()+10] })
                    thread.params['action'] = 'overwrite'
                    sublime.set_timeout(lambda: call('compile', params=thread.params), 100)   
                else:
                    printer.panel.run_command('write_operation_status', {"text": " "+result["actions"][1].title(), 'region': [status_region.end(), status_region.end()+10] })
   
        elif operation == 'test_async':
            responses = []
            if len(result) == 1:
                res = result[0]
                response_string = ""
                if 'detailed_results' in res:
                    all_tests_passed = True
                    for r in res['detailed_results']:
                        if r["Outcome"] != "Pass":
                            all_tests_passed = False
                            break

                    if all_tests_passed:
                        response_string += '[TEST RESULT]: PASS'
                    else:
                        response_string += '[TEST RESULT]: FAIL'
                    
                    for r in res['detailed_results']:
                        if r["Outcome"] == "Pass":
                            pass #dont need to write anything here...
                        else:
                            response_string += '\n'
                            rstring = "====METHOD RESULT===="
                            rstring += "\n"
                            rstring += "{0} : {1}".format(r["MethodName"], r["Outcome"])
                            
                            rstring += "\n\n"
                            rstring += "====STACK TRACE===="
                            rstring += "\n"
                            rstring += r["StackTrace"]

                            rstring += "\n\n"
                            rstring += "====MESSAGE===="
                            rstring += "\n"
                            rstring += r["Message"]
                            rstring += "\n"
                            #responses.append("{0} | {1} | {2} | {3}\n".format(r["MethodName"], r["Outcome"], r["StackTrace"], r["Message"]))
                            responses.append(rstring)
                    response_string += "\n"       
                    response_string += "\n\n".join(responses)
                    printer.panel.run_command('write_operation_status', {'text': response_string, 'region': [status_region.end(), status_region.end()+10] })
                    printer.scroll_to_bottom()
                else:
                    printer.panel.run_command('write_operation_status', {'text': json.dumps(result), 'region': [status_region.end(), status_region.end()+10] })
            else:
                pass #TODO
        
        elif operation == 'run_apex_script':
            if result["success"] == True and result["compiled"] == True:
                printer.panel.run_command('write_operation_status', {'text': " Success", 'region': [status_region.end(), status_region.end()+10] })
                thread.window.open_file(result["log_location"], sublime.TRANSIENT)
            elif result["success"] == False:
                message = " [OPERATION FAILED]: "
                if "compileProblem" in result and result["compileProblem"] != None:
                    message += "[Line: "+str(result["line"]) + ", Column: "+str(result["column"])+"] " + result["compileProblem"] + "\n"
                if "exceptionMessage" in result and result["exceptionMessage"] != None:
                    message += result["exceptionMessage"] + "\n"
                if "exceptionStackTrace" in result and result["exceptionStackTrace"] != None:
                    message += result["exceptionStackTrace"] + "\n"
                printer.panel.run_command('write_operation_status', {'text': message, 'region': [status_region.end(), status_region.end()+10] })
        else:
            print_result_message(operation, process_id, status_region, result, printer, thread) 
            if operation == 'new_metadata' and 'success' in result and util.to_bool(result['success']) == True:
                if 'messages' in result:
                    if type(result['messages']) is not list:
                        result['messages'] = [result['messages']]
                    for m in result['messages']:
                        if 'package.xml' not in m['fileName']:
                            file_name = m['fileName']
                            location = os.path.join(util.mm_project_directory(),file_name.replace('unpackaged/', 'src/'))
                            sublime.active_window().open_file(location)
                            break
            if 'success' in result and util.to_bool(result['success']) == True:
                if printer != None and len(ThreadTracker.get_pending_mm_panel_threads(thread.window)) == 0:
                    printer.hide()  
            elif 'State' in result and result['State'] == 'Completed' and len(ThreadTracker.get_pending_mm_panel_threads(thread.window)) == 0:
                #tooling api
                if printer != None:
                    printer.hide()
            if operation == 'refresh':            
                sublime.set_timeout(lambda: sublime.active_window().active_view().run_command('revert'), 200)
                util.clear_marked_line_numbers()
    except AttributeError as e:   
        if printer != None:
            printer.write('\n[RESPONSE FROM MAVENSMATE]: '+result+'\n')
            msg = ' [OPERATION FAILED]: Whoops, unable to parse the response. Please report this issue at https://github.com/joeferraro/MavensMate-SublimeText\n'
            msg += '[RESPONSE FROM MAVENSMATE]: '+result
            print(e)
            print(sys.exc_info()[0])
            printer.panel.run_command('write_operation_status', {'text': msg, 'region': [status_region.end(), status_region.end()+10] })
    except Exception as e:
        if printer != None:
            printer.write('\n[RESPONSE FROM MAVENSMATE]: '+result+'\n')
            msg = ' [OPERATION FAILED]: Whoops, unable to parse the response. Please report this issue at https://github.com/joeferraro/MavensMate-SublimeText\n'
            msg += '[RESPONSE FROM MAVENSMATE]: '+result
            print(e)
            print(sys.exc_info()[0])
            printer.panel.run_command('write_operation_status', {'text': msg, 'region': [status_region.end(), status_region.end()+10] })
コード例 #11
0
    def __handle_compile_response(self, **kwargs):
        debug('HANDLING COMPILE!')
        debug(self.response)
        '''
            LIGHTNING:
            {
              "result": "markup:\/\/mm2:bar:3,19: ParseError at [row,col]:[4,19]\nMessage: XML document structures must start and end within the same entity.: Source",
              "success": false,
              "stack": "FIELD_INTEGRITY_EXCEPTION: markup:\/\/mm2:bar:3,19: ParseError at [row,col]:[4,19]\nMessage: XML document structures must start and end within the same entity.: Source\n    at onResponse (\/Users\/josephferraro\/Development\/Github\/MavensMate\/node_modules\/jsforce\/lib\/connection.js:368:13)\n    at _fulfilled (\/Users\/josephferraro\/Development\/Github\/MavensMate\/node_modules\/jsforce\/node_modules\/q\/q.js:798:54)\n    at self.promiseDispatch.done (\/Users\/josephferraro\/Development\/Github\/MavensMate\/node_modules\/jsforce\/node_modules\/q\/q.js:827:30)\n    at Promise.promise.promiseDispatch (\/Users\/josephferraro\/Development\/Github\/MavensMate\/node_modules\/jsforce\/node_modules\/q\/q.js:760:13)\n    at \/Users\/josephferraro\/Development\/Github\/MavensMate\/node_modules\/jsforce\/node_modules\/q\/q.js:574:44\n    at flush (\/Users\/josephferraro\/Development\/Github\/MavensMate\/node_modules\/jsforce\/node_modules\/q\/q.js:108:17)\n    at process._tickCallback (node.js:419:13)"
            }

            TOOLING/METADATA:
            {
              "result": {
                "checkOnly": false,
                "completedDate": "",
                "createdBy": "",
                "createdByName": "",
                "createdDate": "",
                "details": {
                  "componentSuccesses": [

                  ],
                  "runTestResult": {
                    "numFailures": "0",
                    "numTestsRun": "0",
                    "totalTime": "0.0"
                  },
                  "componentFailures": [
                    {
                      "attributes": {
                        "type": "ContainerAsyncRequest",
                        "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ContainerAsyncRequest\/1dro0000000mhNbAAI"
                      },
                      "Id": "1dro0000000mhNbAAI",
                      "MetadataContainerId": "1dco0000000JuxBAAS",
                      "MetadataContainerMemberId": null,
                      "State": "Failed",
                      "IsCheckOnly": false,
                      "DeployDetails": {
                        "allComponentMessages": [
                          {
                            "changed": false,
                            "columnNumber": -1,
                            "componentType": "ApexClass",
                            "created": false,
                            "createdDate": "2015-02-12T02:59:21.986+0000",
                            "deleted": false,
                            "fileName": "ChangePasswordController",
                            "forPackageManifestFile": false,
                            "fullName": "ChangePasswordController",
                            "id": "01po0000001iVdVAAU",
                            "knownPackagingProblem": false,
                            "lineNumber": 16,
                            "problem": "expecting right curly bracket, found '<EOF>'",
                            "problemType": "Error",
                            "requiresProductionTestRun": false,
                            "success": false,
                            "warning": false
                          }
                        ],
                        "componentFailures": [
                          {
                            "changed": false,
                            "columnNumber": -1,
                            "componentType": "ApexClass",
                            "created": false,
                            "createdDate": "2015-02-12T02:59:21.986+0000",
                            "deleted": false,
                            "fileName": "ChangePasswordController",
                            "forPackageManifestFile": false,
                            "fullName": "ChangePasswordController",
                            "id": "01po0000001iVdVAAU",
                            "knownPackagingProblem": false,
                            "lineNumber": 16,
                            "problem": "expecting right curly bracket, found '<EOF>'",
                            "problemType": "Error",
                            "requiresProductionTestRun": false,
                            "success": false,
                            "warning": false
                          }
                        ],
                        "componentSuccesses": [

                        ],
                        "runTestResult": null
                      },
                      "ErrorMsg": null
                    }
                  ]
                },
                "done": false,
                "id": "",
                "ignoreWarnings": false,
                "lastModifiedDate": "",
                "numberComponentErrors": 1,
                "numberComponentsDeployed": 0,
                "numberComponentsTotal": 0,
                "numberTestErrors": 0,
                "numberTestsCompleted": 0,
                "numberTestsTotal": 0,
                "rollbackOnError": false,
                "runTestsEnabled": "false",
                "startDate": "",
                "status": "",
                "success": false
              }
            }
        '''

        #diffing with server
        if 'status' in self.response['result'] and self.response['result'][
                'status'] == 'Conflict':
            conflicts = self.result['details']['conflicts']
            first_conflict_file_name = list(conflicts.keys())[0]
            first_conflict_data = conflicts[first_conflict_file_name]
            diff_merge_settings = config.settings.get(
                'mm_diff_server_conflicts', False)
            conflict_message = 'A conflict has been detected. ' + first_conflict_file_name + ' was last modified by ' + first_conflict_data[
                'remote']['LastModifiedBy'][
                    'Name'] + ' on ' + first_conflict_data['remote'][
                        'LastModifiedDate']
            if diff_merge_settings:
                if sublime.ok_cancel_dialog(conflict_message,
                                            'Diff with server'):
                    self.__print_to_panel(conflict_message +
                                          ". Diffing with server.")
                    th = MavensMateDiffThread(
                        self.thread.window, self.thread.view,
                        first_conflict_data['remote']['tempPath'])
                    th.start()
                else:
                    self.__print_to_panel('Operation canceled.')
            else:
                if sublime.ok_cancel_dialog(conflict_message,
                                            "Overwrite Server Copy"):
                    self.__print_to_panel(conflict_message +
                                          ". Overwriting server copy.")
                    args = {"paths": [self.thread.view.file_name()]}
                    sublime.set_timeout(
                        lambda: self.thread.window.run_command(
                            'force_compile_file', args), 100)
                else:
                    self.__print_to_panel('Operation canceled.')
        else:
            try:
                success = self.response['result']['success']
                if success:
                    util.clear_marked_line_numbers(self.thread.view)
                    self.__print_to_panel("Success")
                    self.printer.hide()
                    return

                msg = '[OPERATION FAILED]: '

                if type(self.response['result']['details']
                        ['componentFailures']) is not list:
                    self.response['result']['details']['componentFailures'] = [
                        self.response['result']['details']['componentFailures']
                    ]

                for res in self.response['result']['details'][
                        'componentFailures']:
                    if 'DeployDetails' in res and len(
                            res['DeployDetails']['componentFailures']) > 0:
                        for detail in res['DeployDetails'][
                                'componentFailures']:
                            debug(detail)
                            line_col = ''
                            line, col = 1, 1
                            if 'lineNumber' in detail:
                                line = int(detail['lineNumber'])
                                line_col = ' (Line: ' + str(line)
                                util.mark_line_numbers(self.thread.view,
                                                       [line], 'bookmark')
                            if 'columnNumber' in detail:
                                col = int(detail['columnNumber'])
                                line_col += ', Column: ' + str(col)
                            if len(line_col):
                                line_col += ')'

                            #scroll to the line and column of the exception
                            if settings.get('mm_compile_scroll_to_error',
                                            True):
                                view = self.thread.view
                                pt = view.text_point(line - 1, col - 1)
                                view.sel().clear()
                                view.sel().add(sublime.Region(pt))
                                view.show(pt)

                            msg += detail['fileName'] + ': ' + detail[
                                'problem'] + line_col + '\n'
                    elif 'ErrorMsg' in res and res['ErrorMsg'] != None:
                        msg += res['ErrorMsg'] + '\n'
                    else:  # metadata api?
                        msg += res['fullName'] + ': ' + res['problem'] + '\n'

                self.__print_to_panel(msg)

            except Exception as e:
                debug(e)
                debug(traceback.print_exc())
                debug(type(self.response))
                raise e
コード例 #12
0
    def __handle_compile_response(self, **kwargs):
        debug('HANDLING COMPILE!')
        debug(self.response)

        '''
            LIGHTNING:
            {
              "result": "markup:\/\/mm2:bar:3,19: ParseError at [row,col]:[4,19]\nMessage: XML document structures must start and end within the same entity.: Source",
              "success": false,
              "stack": "FIELD_INTEGRITY_EXCEPTION: markup:\/\/mm2:bar:3,19: ParseError at [row,col]:[4,19]\nMessage: XML document structures must start and end within the same entity.: Source\n    at onResponse (\/Users\/josephferraro\/Development\/Github\/MavensMate\/node_modules\/jsforce\/lib\/connection.js:368:13)\n    at _fulfilled (\/Users\/josephferraro\/Development\/Github\/MavensMate\/node_modules\/jsforce\/node_modules\/q\/q.js:798:54)\n    at self.promiseDispatch.done (\/Users\/josephferraro\/Development\/Github\/MavensMate\/node_modules\/jsforce\/node_modules\/q\/q.js:827:30)\n    at Promise.promise.promiseDispatch (\/Users\/josephferraro\/Development\/Github\/MavensMate\/node_modules\/jsforce\/node_modules\/q\/q.js:760:13)\n    at \/Users\/josephferraro\/Development\/Github\/MavensMate\/node_modules\/jsforce\/node_modules\/q\/q.js:574:44\n    at flush (\/Users\/josephferraro\/Development\/Github\/MavensMate\/node_modules\/jsforce\/node_modules\/q\/q.js:108:17)\n    at process._tickCallback (node.js:419:13)"
            }

            TOOLING/METADATA:
            {
              "result": {
                "checkOnly": false,
                "completedDate": "",
                "createdBy": "",
                "createdByName": "",
                "createdDate": "",
                "details": {
                  "componentSuccesses": [

                  ],
                  "runTestResult": {
                    "numFailures": "0",
                    "numTestsRun": "0",
                    "totalTime": "0.0"
                  },
                  "componentFailures": [
                    {
                      "attributes": {
                        "type": "ContainerAsyncRequest",
                        "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ContainerAsyncRequest\/1dro0000000mhNbAAI"
                      },
                      "Id": "1dro0000000mhNbAAI",
                      "MetadataContainerId": "1dco0000000JuxBAAS",
                      "MetadataContainerMemberId": null,
                      "State": "Failed",
                      "IsCheckOnly": false,
                      "DeployDetails": {
                        "allComponentMessages": [
                          {
                            "changed": false,
                            "columnNumber": -1,
                            "componentType": "ApexClass",
                            "created": false,
                            "createdDate": "2015-02-12T02:59:21.986+0000",
                            "deleted": false,
                            "fileName": "ChangePasswordController",
                            "forPackageManifestFile": false,
                            "fullName": "ChangePasswordController",
                            "id": "01po0000001iVdVAAU",
                            "knownPackagingProblem": false,
                            "lineNumber": 16,
                            "problem": "expecting right curly bracket, found '<EOF>'",
                            "problemType": "Error",
                            "requiresProductionTestRun": false,
                            "success": false,
                            "warning": false
                          }
                        ],
                        "componentFailures": [
                          {
                            "changed": false,
                            "columnNumber": -1,
                            "componentType": "ApexClass",
                            "created": false,
                            "createdDate": "2015-02-12T02:59:21.986+0000",
                            "deleted": false,
                            "fileName": "ChangePasswordController",
                            "forPackageManifestFile": false,
                            "fullName": "ChangePasswordController",
                            "id": "01po0000001iVdVAAU",
                            "knownPackagingProblem": false,
                            "lineNumber": 16,
                            "problem": "expecting right curly bracket, found '<EOF>'",
                            "problemType": "Error",
                            "requiresProductionTestRun": false,
                            "success": false,
                            "warning": false
                          }
                        ],
                        "componentSuccesses": [

                        ],
                        "runTestResult": null
                      },
                      "ErrorMsg": null
                    }
                  ]
                },
                "done": false,
                "id": "",
                "ignoreWarnings": false,
                "lastModifiedDate": "",
                "numberComponentErrors": 1,
                "numberComponentsDeployed": 0,
                "numberComponentsTotal": 0,
                "numberTestErrors": 0,
                "numberTestsCompleted": 0,
                "numberTestsTotal": 0,
                "rollbackOnError": false,
                "runTestsEnabled": "false",
                "startDate": "",
                "status": "",
                "success": false
              }
            }
        '''

        #diffing with server
        if 'status' in self.response['result'] and self.response['result']['status'] == 'Conflict':
            conflicts = self.result['details']['conflicts']
            first_conflict_file_name = list(conflicts.keys())[0]
            first_conflict_data = conflicts[first_conflict_file_name]
            diff_merge_settings = config.settings.get('mm_diff_server_conflicts', False)
            conflict_message = 'A conflict has been detected. '+first_conflict_file_name+' was last modified by '+first_conflict_data['remote']['LastModifiedBy']['Name']+' on '+first_conflict_data['remote']['LastModifiedDate']
            if diff_merge_settings:
                if sublime.ok_cancel_dialog(conflict_message, 'Diff with server'):
                    self.__print_to_panel(conflict_message + ". Diffing with server.")
                    th = MavensMateDiffThread(self.thread.window, self.thread.view, first_conflict_data['remote']['tempPath'])
                    th.start()
                else:
                    self.__print_to_panel('Operation canceled.')
            else:
                if sublime.ok_cancel_dialog(conflict_message, "Overwrite Server Copy"):
                    self.__print_to_panel(conflict_message + ". Overwriting server copy.")
                    args = {
                        "paths" : [self.thread.view.file_name()]
                    }
                    sublime.set_timeout(lambda: self.thread.window.run_command('force_compile_file', args), 100)
                else:
                    self.__print_to_panel('Operation canceled.')
        else:
            try:
                success = self.response['result']['success']
                if success:
                    util.clear_marked_line_numbers(self.thread.view)
                    self.__print_to_panel("Success")
                    self.printer.hide()
                    return

                msg = '[OPERATION FAILED]: '

                if type(self.response['result']['details']['componentFailures']) is not list:
                    self.response['result']['details']['componentFailures'] = [self.response['result']['details']['componentFailures']]

                for res in self.response['result']['details']['componentFailures']:
                    if 'DeployDetails' in res:
                        for detail in res['DeployDetails']['componentFailures']:
                            debug(detail)
                            line_col = ''
                            line, col = 1, 1
                            if 'lineNumber' in detail:
                                line = int(detail['lineNumber'])
                                line_col = ' (Line: '+str(line)
                                util.mark_line_numbers(self.thread.view, [line], 'bookmark')
                            if 'columnNumber' in detail:
                                col = int(detail['columnNumber'])
                                line_col += ', Column: '+str(col)
                            if len(line_col):
                                line_col += ')'

                            #scroll to the line and column of the exception
                            if settings.get('mm_compile_scroll_to_error', True):
                                view = self.thread.view
                                pt = view.text_point(line-1, col-1)
                                view.sel().clear()
                                view.sel().add(sublime.Region(pt))
                                view.show(pt)

                            msg += detail['fileName']+': '+ detail['problem'] + line_col + '\n'
                    else: # metadata api?
                        msg += res['fullName']+': '+ res['problem'] + '\n'

                self.__print_to_panel(msg)

            except Exception as e:
                debug(e)
                debug(traceback.print_exc())
                debug(type(self.response))
                raise e
コード例 #13
0
def handle_result(operation, process_id, printer, result, thread):
    #print(thread.process_id)
    #print(thread.params)
    process_region = printer.panel.find(process_id, 0)
    status_region = printer.panel.find('Result:', process_region.begin())

    try:
        result = json.loads(result)
        if operation == 'compile' and 'actions' in result and util.to_bool(
                result['success']) == False:
            diff_merge_settings = config.settings.get(
                'mm_diff_server_conflicts', False)
            if diff_merge_settings:
                if sublime.ok_cancel_dialog(result["body"],
                                            result["actions"][0].title()):
                    printer.panel.run_command(
                        'write_operation_status', {
                            "text":
                            " Diffing with server",
                            'region':
                            [status_region.end(),
                             status_region.end() + 10]
                        })
                    th = MavensMateDiffThread(thread.window, thread.view,
                                              result['tmp_file_path'])
                    th.start()

                else:
                    printer.panel.run_command(
                        'write_operation_status', {
                            "text":
                            " " + result["actions"][1].title(),
                            'region':
                            [status_region.end(),
                             status_region.end() + 10]
                        })
            else:
                if sublime.ok_cancel_dialog(result["body"],
                                            "Overwrite Server Copy"):
                    printer.panel.run_command(
                        'write_operation_status', {
                            "text":
                            " Overwriting server copy",
                            'region':
                            [status_region.end(),
                             status_region.end() + 10]
                        })
                    thread.params['action'] = 'overwrite'
                    sublime.set_timeout(
                        lambda: call('compile', params=thread.params), 100)
                else:
                    printer.panel.run_command(
                        'write_operation_status', {
                            "text":
                            " " + result["actions"][1].title(),
                            'region':
                            [status_region.end(),
                             status_region.end() + 10]
                        })

        elif operation == 'test_async':
            responses = []
            if len(result) == 1:
                res = result[0]
                response_string = ""
                if 'detailed_results' in res:
                    all_tests_passed = True
                    for r in res['detailed_results']:
                        if r["Outcome"] != "Pass":
                            all_tests_passed = False
                            break

                    if all_tests_passed:
                        response_string += '[TEST RESULT]: PASS'
                    else:
                        response_string += '[TEST RESULT]: FAIL'

                    for r in res['detailed_results']:
                        if r["Outcome"] == "Pass":
                            pass  #dont need to write anything here...
                        else:
                            response_string += '\n'
                            rstring = "====METHOD RESULT===="
                            rstring += "\n"
                            rstring += "{0} : {1}".format(
                                r["MethodName"], r["Outcome"])

                            rstring += "\n\n"
                            rstring += "====STACK TRACE===="
                            rstring += "\n"
                            rstring += r["StackTrace"]

                            rstring += "\n\n"
                            rstring += "====MESSAGE===="
                            rstring += "\n"
                            rstring += r["Message"]
                            rstring += "\n"
                            #responses.append("{0} | {1} | {2} | {3}\n".format(r["MethodName"], r["Outcome"], r["StackTrace"], r["Message"]))
                            responses.append(rstring)
                    response_string += "\n"
                    response_string += "\n\n".join(responses)
                    printer.panel.run_command(
                        'write_operation_status', {
                            'text':
                            response_string,
                            'region':
                            [status_region.end(),
                             status_region.end() + 10]
                        })
                    printer.scroll_to_bottom()
                else:
                    printer.panel.run_command(
                        'write_operation_status', {
                            'text':
                            json.dumps(result),
                            'region':
                            [status_region.end(),
                             status_region.end() + 10]
                        })
            else:
                pass  #TODO

        elif operation == 'run_apex_script':
            if result["success"] == True and result["compiled"] == True:
                printer.panel.run_command(
                    'write_operation_status', {
                        'text': " Success",
                        'region':
                        [status_region.end(),
                         status_region.end() + 10]
                    })
                thread.window.open_file(result["log_location"],
                                        sublime.TRANSIENT)
            elif result["success"] == False:
                message = " [OPERATION FAILED]: "
                if "compileProblem" in result and result[
                        "compileProblem"] != None:
                    message += "[Line: " + str(
                        result["line"]) + ", Column: " + str(
                            result["column"]
                        ) + "] " + result["compileProblem"] + "\n"
                if "exceptionMessage" in result and result[
                        "exceptionMessage"] != None:
                    message += result["exceptionMessage"] + "\n"
                if "exceptionStackTrace" in result and result[
                        "exceptionStackTrace"] != None:
                    message += result["exceptionStackTrace"] + "\n"
                printer.panel.run_command(
                    'write_operation_status', {
                        'text': message,
                        'region':
                        [status_region.end(),
                         status_region.end() + 10]
                    })
        else:
            print_result_message(operation, process_id, status_region, result,
                                 printer, thread)
            if operation == 'new_metadata' and 'success' in result and util.to_bool(
                    result['success']) == True:
                if 'messages' in result:
                    if type(result['messages']) is not list:
                        result['messages'] = [result['messages']]
                    for m in result['messages']:
                        if 'package.xml' not in m['fileName']:
                            file_name = m['fileName']
                            location = os.path.join(
                                util.mm_project_directory(),
                                file_name.replace('unpackaged/', 'src/'))
                            sublime.active_window().open_file(location)
                            break
            if 'success' in result and util.to_bool(result['success']) == True:
                if printer != None and len(
                        ThreadTracker.get_pending_mm_panel_threads(
                            thread.window)) == 0:
                    printer.hide()
            elif 'State' in result and result['State'] == 'Completed' and len(
                    ThreadTracker.get_pending_mm_panel_threads(
                        thread.window)) == 0:
                #tooling api
                if printer != None:
                    printer.hide()
            if operation == 'refresh':
                sublime.set_timeout(
                    lambda: sublime.active_window().active_view().run_command(
                        'revert'), 200)
                util.clear_marked_line_numbers()
    except AttributeError as e:
        if printer != None:
            printer.write('\n[RESPONSE FROM MAVENSMATE]: ' + result + '\n')
            msg = ' [OPERATION FAILED]: Whoops, unable to parse the response. Please report this issue at https://github.com/joeferraro/MavensMate-SublimeText\n'
            msg += '[RESPONSE FROM MAVENSMATE]: ' + result
            print(e)
            print(sys.exc_info()[0])
            printer.panel.run_command(
                'write_operation_status', {
                    'text': msg,
                    'region': [status_region.end(),
                               status_region.end() + 10]
                })
    except Exception as e:
        if printer != None:
            printer.write('\n[RESPONSE FROM MAVENSMATE]: ' + result + '\n')
            msg = ' [OPERATION FAILED]: Whoops, unable to parse the response. Please report this issue at https://github.com/joeferraro/MavensMate-SublimeText\n'
            msg += '[RESPONSE FROM MAVENSMATE]: ' + result
            print(e)
            print(sys.exc_info()[0])
            printer.panel.run_command(
                'write_operation_status', {
                    'text': msg,
                    'region': [status_region.end(),
                               status_region.end() + 10]
                })
コード例 #14
0
def handle_result(operation, process_id, printer, result, thread):
    #print(thread.process_id)
    #print(thread.params)
    process_region = printer.panel.find(process_id, 0)
    status_region = printer.panel.find('Result:', process_region.begin())

    try:
        result = json.loads(result)
        if operation == 'compile' and 'actions' in result and util.to_bool(
                result['success']) == False:
            diff_merge_settings = config.settings.get(
                'mm_diff_server_conflicts', False)
            if diff_merge_settings:
                if sublime.ok_cancel_dialog(result["body"],
                                            result["actions"][0].title()):
                    printer.panel.run_command(
                        'write_operation_status', {
                            "text":
                            " Diffing with server",
                            'region':
                            [status_region.end(),
                             status_region.end() + 10]
                        })
                    th = MavensMateDiffThread(thread.window, thread.view,
                                              result['tmp_file_path'])
                    th.start()

                else:
                    printer.panel.run_command(
                        'write_operation_status', {
                            "text":
                            " " + result["actions"][1].title(),
                            'region':
                            [status_region.end(),
                             status_region.end() + 10]
                        })
            else:
                if sublime.ok_cancel_dialog(result["body"],
                                            "Overwrite Server Copy"):
                    printer.panel.run_command(
                        'write_operation_status', {
                            "text":
                            " Overwriting server copy",
                            'region':
                            [status_region.end(),
                             status_region.end() + 10]
                        })
                    thread.params['action'] = 'overwrite'
                    sublime.set_timeout(
                        lambda: call('compile', params=thread.params), 100)
                else:
                    printer.panel.run_command(
                        'write_operation_status', {
                            "text":
                            " " + result["actions"][1].title(),
                            'region':
                            [status_region.end(),
                             status_region.end() + 10]
                        })

        else:
            print_result_message(operation, process_id, status_region, result,
                                 printer, thread)
            if operation == 'new_metadata' and 'success' in result and util.to_bool(
                    result['success']) == True:
                if 'messages' in result:
                    if type(result['messages']) is not list:
                        result['messages'] = [result['messages']]
                    for m in result['messages']:
                        if 'package.xml' not in m['fileName']:
                            file_name = m['fileName']
                            location = util.mm_project_directory(
                            ) + "/" + file_name.replace('unpackaged/', 'src/')
                            sublime.active_window().open_file(location)
                            break
            if 'success' in result and util.to_bool(result['success']) == True:
                if printer != None and len(
                        ThreadTracker.get_pending_mm_panel_threads(
                            thread.window)) == 0:
                    printer.hide()
            elif 'State' in result and result['State'] == 'Completed' and len(
                    ThreadTracker.get_pending_mm_panel_threads(
                        thread.window)) == 0:
                #tooling api
                if printer != None:
                    printer.hide()
            if operation == 'refresh':
                sublime.set_timeout(
                    lambda: sublime.active_window().active_view().run_command(
                        'revert'), 200)
                util.clear_marked_line_numbers()
    except AttributeError:
        if printer != None:
            printer.write('\n[RESPONSE FROM MAVENSMATE]: ' + result + '\n')
            msg = ' [OPERATION FAILED]: Whoops, unable to parse the response. Please report this issue at https://github.com/joeferraro/MavensMate-SublimeText\n'
            msg += '[RESPONSE FROM MAVENSMATE]: ' + result
            printer.panel.run_command(
                'write_operation_status', {
                    'text': msg,
                    'region': [status_region.end(),
                               status_region.end() + 10]
                })
    except Exception:
        if printer != None:
            printer.write('\n[RESPONSE FROM MAVENSMATE]: ' + result + '\n')
            msg = ' [OPERATION FAILED]: Whoops, unable to parse the response. Please report this issue at https://github.com/joeferraro/MavensMate-SublimeText\n'
            msg += '[RESPONSE FROM MAVENSMATE]: ' + result
            printer.panel.run_command(
                'write_operation_status', {
                    'text': msg,
                    'region': [status_region.end(),
                               status_region.end() + 10]
                })