Ejemplo n.º 1
0
def get_active_session():
    try:
        if 'username' not in request_payload or request_payload[
                'username'] == None or request_payload['username'] == '':
            raise MMException('Please enter a Salesforce.com username')
        if 'password' not in request_payload or request_payload[
                'password'] == None or request_payload['password'] == '':
            raise MMException('Please enter a Salesforce.com password')
        if 'org_type' not in request_payload or request_payload[
                'org_type'] == None or request_payload['org_type'] == '':
            raise MMException('Please select an org type')

        client = MavensMateClient(
            credentials={
                "username": request_payload['username'],
                "password": request_payload['password'],
                "org_type": request_payload['org_type']
            })

        response = {
            "sid": client.sid,
            "user_id": client.user_id,
            "metadata_server_url": client.metadata_server_url,
            "server_url": client.server_url,
            "metadata": client.get_org_metadata(),
            "success": True
        }
        print util.generate_response(response)
    except BaseException, e:
        print util.generate_error_response(e.message)
Ejemplo n.º 2
0
Archivo: mm.py Proyecto: e-bacho/mm
    def get_active_session(self):
        try:
            if 'username' not in self.payload or self.payload['username'] == None or self.payload['username'] == '':
                raise MMException('Please enter a Salesforce.com username')
            if 'password' not in self.payload or self.payload['password'] == None or self.payload['password'] == '':
                raise MMException('Please enter a Salesforce.com password')
            if 'org_type' not in self.payload or self.payload['org_type'] == None or self.payload['org_type'] == '':
                raise MMException('Please select an org type')
            if 'org_type' in self.payload and self.payload['org_type'] == "custom" and "org_url" not in self.payload:
                raise MMException('To use a custom org type, please include a org_url parameter') 
            if 'org_type' in self.payload and self.payload['org_type'] == "custom" and "org_url" in self.payload and self.payload["org_url"] == "":
                raise MMException('Please specify the org url')    

            client = MavensMateClient(credentials={
                "username" : self.payload['username'],
                "password" : self.payload['password'],
                "org_type" : self.payload['org_type'],
                "org_url"  : self.payload.get('org_url', None)
            }) 
            
            response = {
                "sid"                   : client.sid,
                "user_id"               : client.user_id,
                "metadata_server_url"   : client.metadata_server_url,
                "server_url"            : client.server_url,
                "metadata"              : client.get_org_metadata(subscription=self.payload.get('subscription', None)),
                "success"               : True
            }
            print util.generate_response(response)
        except BaseException, e:
            print util.generate_error_response(e.message)
Ejemplo n.º 3
0
def get_active_session():
    try:
        if 'username' not in request_payload or request_payload['username'] == None or request_payload['username'] == '':
            raise MMException('Please enter a Salesforce.com username')
        if 'password' not in request_payload or request_payload['password'] == None or request_payload['password'] == '':
            raise MMException('Please enter a Salesforce.com password')
        if 'org_type' not in request_payload or request_payload['org_type'] == None or request_payload['org_type'] == '':
            raise MMException('Please select an org type')

        client = MavensMateClient(credentials={
            "username" : request_payload['username'],
            "password" : request_payload['password'],
            "org_type" : request_payload['org_type']
        }) 
        
        response = {
            "sid"                   : client.sid,
            "user_id"               : client.user_id,
            "metadata_server_url"   : client.metadata_server_url,
            "server_url"            : client.server_url,
            "metadata"              : client.get_org_metadata(),
            "success"               : True
        }
        print util.generate_response(response)
    except BaseException, e:
        print util.generate_error_response(e.message)
Ejemplo n.º 4
0
Archivo: mm.py Proyecto: vazexqi/mm
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-o', '--operation', help='The requested operation') #name of the operation being requested
    parser.add_argument('-c', '--client', help='The plugin client being used') #name of the plugin client ("SUBLIME_TEXT_2", "SUBLIME_TEXT_3", "TEXTMATE", "NOTEPAD_PLUS_PLUS", "BB_EDIT", etc.)
    parser.add_argument('--ui', action='store_true', default=False, 
        dest='ui_switch', help='Launch the default UI for the operation')
    parser.add_argument('--quiet', action='store_true', default=False, 
        dest='quiet', help='Suppresses mm.py output')
    parser.add_argument('--html', action='store_true', default=False, 
        dest='respond_with_html', help='Makes various commands return HTML')
    parser.add_argument('--v', '--verbose', action='store_true', default=False, 
        dest='verbose', help='Makes me really loud and annoying')
    args, unknown = parser.parse_known_args()
    payload = util.get_request_payload()
    try:
        r = MavensMateRequest(args=args, payload=payload, unknown_args=unknown)
        response = r.execute()

        r.output.close()
        sys.stdout = r.saved_stdout

        config.logger.debug('\n\n')
        config.logger.debug('---------------------')
        config.logger.debug('RESPONDING TO REQUEST')
        config.logger.debug('---------------------')
        config.logger.debug('\n')
        config.logger.debug(response)

        print response
    except Exception as e:
        print util.generate_error_response(e.message)
Ejemplo n.º 5
0
def update_credentials():
    try:
        config.connection.project.username = request_payload['username']
        config.connection.project.password = request_payload['password']
        config.connection.project.org_type = request_payload['org_type']
        config.connection.project.update_credentials()
        print util.generate_success_response('Your credentials were updated successfully')
    except BaseException, e:
        print util.generate_error_response(e.message)
Ejemplo n.º 6
0
def update_credentials():
    try:
        config.connection.project.username = request_payload['username']
        config.connection.project.password = request_payload['password']
        config.connection.project.org_type = request_payload['org_type']
        config.connection.project.update_credentials()
        print util.generate_success_response('Your credentials were updated successfully')
    except BaseException, e:
        print util.generate_error_response(e.message)
Ejemplo n.º 7
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-o',
                        '--operation')  #name of the operation being requested
    parser.add_argument(
        '-c', '--client'
    )  #name of the plugin client ("SUBLIME_TEXT_2", "SUBLIME_TEXT_3", "TEXTMATE", "NOTEPAD_PLUS_PLUS", "BB_EDIT", etc.)
    parser.add_argument('-p', '--projectname')  #name of the project
    parser.add_argument('-d', '--projectdirectory')  #name of the project
    parser.add_argument(
        '--callback'
    )  #some terminal script to run upon completion of a command
    parser.add_argument(
        '--ui',
        action='store_true',
        default=False,
        dest='ui_switch',
        help='Include flag to launch the default UI for the operation')
    parser.add_argument('--html',
                        action='store_true',
                        default=False,
                        dest='respond_with_html',
                        help='Include flag if you want the response in HTML')
    args = parser.parse_args()
    operation = args.operation

    try:
        setup_connection(args)
    except Exception as e:
        print util.generate_error_response(e.message)
        return

    #if the arg switch argument is included, the request is to launch the out of box
    #MavensMate UI, so we generate the HTML for the UI and launch the process
    #example: mm -o new_project --ui
    if args.ui_switch == True:
        #os.system('killAll MavensMateWindowServer') #TODO: try/except?
        tmp_html_file = util.generate_ui(operation, request_payload)
        util.launch_ui(tmp_html_file)
        print util.generate_success_response('UI Generated Successfully')
    else:
        requested_function = operation_dict[operation]
        fspec = inspect.getargspec(requested_function)
        if type(fspec.args) is list and len(
                fspec.args) == 1 and fspec.args[0] == 'args':
            requested_function(eval(fspec.args[0]))
        elif type(fspec.args) is list and len(fspec.args) > 0:
            print util.generate_error_response('Invalid operation requested')
        else:
            requested_function()

    if args.callback != None:
        os.system(args.callback)
Ejemplo n.º 8
0
Archivo: mm.py Proyecto: e-bacho/mm
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-o', '--operation') #name of the operation being requested
    parser.add_argument('-c', '--client') #name of the plugin client ("SUBLIME_TEXT_2", "SUBLIME_TEXT_3", "TEXTMATE", "NOTEPAD_PLUS_PLUS", "BB_EDIT", etc.)
    parser.add_argument('--ui', action='store_true', default=False, 
        dest='ui_switch', help='Include flag to launch the default UI for the operation')
    parser.add_argument('--quiet', action='store_true', default=False, 
        dest='quiet', help='To suppress mm.py output, use this flag')
    parser.add_argument('--html', action='store_true', default=False, 
        dest='respond_with_html', help='Include flag if you want the response in HTML')
    args = parser.parse_args()
    payload = util.get_request_payload()
    
    try:
        r = MavensMateRequest(args=args, payload=payload)
        r.execute()
    except Exception as e:
        print util.generate_error_response(e.message)
Ejemplo n.º 9
0
Archivo: mm.py Proyecto: vazexqi/mm
 def update_credentials(self):
     try:
         config.connection.project.username = self.payload['username']
         config.connection.project.password = self.payload['password']
         config.connection.project.org_type = self.payload['org_type']
         config.connection.project.org_url  = self.payload.get('org_url', None)
         config.connection.project.update_credentials()
         return util.generate_success_response('Your credentials were updated successfully')
     except BaseException, e:
         return util.generate_error_response(e.message)
Ejemplo n.º 10
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-o', '--operation') #name of the operation being requested
    parser.add_argument('-c', '--client') #name of the plugin client ("SUBLIME_TEXT_2", "SUBLIME_TEXT_3", "TEXTMATE", "NOTEPAD_PLUS_PLUS", "BB_EDIT", etc.)
    parser.add_argument('-p', '--projectname') #name of the project
    parser.add_argument('-d', '--projectdirectory') #name of the project
    parser.add_argument('--callback') #some terminal script to run upon completion of a command
    parser.add_argument('--ui', action='store_true', default=False, 
        dest='ui_switch', help='Include flag to launch the default UI for the operation')
    parser.add_argument('--html', action='store_true', default=False, 
        dest='respond_with_html', help='Include flag if you want the response in HTML')
    args = parser.parse_args()
    operation = args.operation
    
    try:
        setup_connection(args)
    except Exception as e:
        print util.generate_error_response(e.message)
        return

    #if the arg switch argument is included, the request is to launch the out of box
    #MavensMate UI, so we generate the HTML for the UI and launch the process
    #example: mm -o new_project --ui
    if args.ui_switch == True:
        #os.system('killAll MavensMateWindowServer') #TODO: try/except?
        tmp_html_file = util.generate_ui(operation,request_payload)
        print tmp_html_file
        util.launch_ui(tmp_html_file, config.connection.chrome )
        print tmp_html_file
        print util.generate_success_response('UI Generated Successfully')
    else:        
        requested_function = operation_dict[operation]
        fspec = inspect.getargspec(requested_function)
        if type(fspec.args) is list and len(fspec.args) == 1 and fspec.args[0] == 'args':
            requested_function(eval(fspec.args[0]))
        elif type(fspec.args) is list and len(fspec.args) > 0:
            print util.generate_error_response('Invalid operation requested')
        else:
            requested_function()
        
    if args.callback != None:
        os.system(args.callback)
Ejemplo n.º 11
0
Archivo: mm.py Proyecto: e-bacho/mm
    def execute(self):
        try:
            self.setup_connection()
        except Exception as e:
            print util.generate_error_response(e.message)
            return

        #if the arg switch argument is included, the request is to launch the out of box
        #MavensMate UI, so we generate the HTML for the UI and launch the process
        #example: mm -o new_project --ui
        if self.args.ui_switch == True:
            tmp_html_file = util.generate_ui(self.operation,self.payload)
            util.launch_ui(tmp_html_file)
            print util.generate_success_response('UI Generated Successfully')
        else:        
            config.logger.debug(self.operation)
            if self.operation not in self.operation_dict:
                raise MMException('Unsupported operation')
            requested_function = self.operation_dict[self.operation]
            requested_function()
Ejemplo n.º 12
0
def index_apex_file_properties():
    print util.generate_error_response("Operation not currently supported")
Ejemplo n.º 13
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-o',
                        '--operation')  #name of the operation being requested
    parser.add_argument(
        '-c', '--client'
    )  #name of the plugin client ("SUBLIME_TEXT_2", "SUBLIME_TEXT_3", "TEXTMATE", "NOTEPAD_PLUS_PLUS", "BB_EDIT", etc.)
    parser.add_argument('-p', '--projectname')  #name of the project
    parser.add_argument('-d', '--projectdirectory')  #name of the project
    parser.add_argument(
        '--callback'
    )  #some terminal script to run upon completion of a command
    parser.add_argument(
        '--ui',
        action='store_true',
        default=False,
        dest='ui_switch',
        help='Include flag to launch the default UI for the operation')
    parser.add_argument('--html',
                        action='store_true',
                        default=False,
                        dest='respond_with_html',
                        help='Include flag if you want the response in HTML')
    args = parser.parse_args()
    operation = args.operation

    try:
        setup_connection(args)
    except Exception as e:
        print util.generate_error_response(e.message)
        return

    #if the arg switch argument is included, the request is to launch the out of box
    #MavensMate UI, so we generate the HTML for the UI and launch the process
    #example: mm -o new_project --ui
    if args.ui_switch == True:
        #os.system('killAll MavensMateWindowServer') #TODO: try/except?
        tmp_html_file = util.generate_ui(operation, request_payload)
        util.launch_ui(tmp_html_file)
        print util.generate_success_response('UI Generated Successfully')
    else:
        if operation == 'new_project':
            new_project()
        elif operation == 'edit_project':
            edit_project()
        elif operation == 'upgrade_project':
            upgrade_project()
        elif operation == 'checkout_project':
            checkout_project()
        elif operation == 'compile_project':
            compile_project()
        elif operation == 'new_metadata':
            new_metadata()
        elif operation == 'clean_project':
            clean_project()
        elif operation == 'synchronize':
            synchronize()
        elif operation == 'refresh':
            refresh()
        elif operation == 'refresh_properties':
            refresh_properties()
        elif operation == 'compile':
            compile_selected_metadata()
        elif operation == 'delete':
            delete_selected_metadata()
        elif operation == 'get_active_session':
            get_active_session()
        elif operation == 'update_credentials':
            update_credentials()
        elif operation == 'execute_apex':
            execute_apex()
        elif operation == 'deploy_to_server' or operation == 'deploy':
            deploy_to_server(args)
        elif operation == 'unit_test' or operation == 'test':
            run_unit_tests(args)
        elif operation == 'list_metadata':
            list_metadata()
        elif operation == 'index_metadata':
            index_metadata(args)
        elif operation == 'list_connections':
            list_connections()
        elif operation == 'new_connection':
            new_connection()
        elif operation == 'delete_connection':
            delete_connection()
        elif operation == 'index_apex_overlays':
            index_apex_overlays()
        elif operation == 'new_apex_overlay':
            new_apex_overlay()
        elif operation == 'delete_apex_overlay':
            delete_apex_overlay()
        elif operation == 'fetch_logs':
            fetch_logs()
        elif operation == 'new_project_from_existing_directory':
            new_project_from_existing_directory()
        elif operation == 'debug_log':
            TODO()
        elif operation == 'open_sfdc_url':
            open_sfdc_url()
        else:
            print util.generate_error_response('Invalid operation requested')

    if args.callback != None:
        os.system(args.callback)
Ejemplo n.º 14
0
def index_apex_file_properties():
    print util.generate_error_response("Operation not currently supported")
Ejemplo n.º 15
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-o', '--operation') #name of the operation being requested
    parser.add_argument('-c', '--client') #name of the plugin client ("SUBLIME_TEXT_2", "SUBLIME_TEXT_3", "TEXTMATE", "NOTEPAD_PLUS_PLUS", "BB_EDIT", etc.)
    parser.add_argument('-p', '--projectname') #name of the project
    parser.add_argument('-d', '--projectdirectory') #name of the project
    parser.add_argument('--callback') #some terminal script to run upon completion of a command
    parser.add_argument('--ui', action='store_true', default=False, 
        dest='ui_switch', help='Include flag to launch the default UI for the operation')
    parser.add_argument('--html', action='store_true', default=False, 
        dest='respond_with_html', help='Include flag if you want the response in HTML')
    args = parser.parse_args()
    operation = args.operation
    
    try:
        setup_connection(args)
    except Exception as e:
        print util.generate_error_response(e.message)
        return

    #if the arg switch argument is included, the request is to launch the out of box
    #MavensMate UI, so we generate the HTML for the UI and launch the process
    #example: mm -o new_project --ui
    if args.ui_switch == True:
        #os.system('killAll MavensMateWindowServer') #TODO: try/except?
        tmp_html_file = util.generate_ui(operation,request_payload)
        util.launch_ui(tmp_html_file)
        print util.generate_success_response('UI Generated Successfully')
    else:        
        if operation == 'new_project':
            new_project()
        elif operation == 'edit_project':
            edit_project()    
        elif operation == 'upgrade_project':
            upgrade_project()     
        elif operation == 'checkout_project':
            checkout_project()
        elif operation == 'compile_project':
            compile_project()
        elif operation == 'new_metadata':
            new_metadata()
        elif operation == 'clean_project':
            clean_project()
        elif operation == 'synchronize':
            synchronize()
        elif operation == 'refresh':
            refresh()
        elif operation == 'refresh_properties':
            refresh_properties()
        elif operation == 'compile':
            compile_selected_metadata()
        elif operation == 'delete':
            delete_selected_metadata()
        elif operation == 'get_active_session':
            get_active_session()
        elif operation == 'update_credentials':
            update_credentials()
        elif operation == 'execute_apex':
            execute_apex()
        elif operation == 'deploy_to_server' or operation == 'deploy':
            deploy_to_server(args)
        elif operation == 'unit_test' or operation == 'test':
            run_unit_tests(args)
        elif operation == 'list_metadata':
            list_metadata()
        elif operation == 'index_metadata':
            index_metadata(args)    
        elif operation == 'list_connections':
            list_connections()
        elif operation == 'new_connection':
            new_connection()
        elif operation == 'delete_connection':
            delete_connection()
        elif operation == 'index_apex_overlays':
            index_apex_overlays()
        elif operation == 'new_apex_overlay':
            new_apex_overlay()
        elif operation == 'delete_apex_overlay':
            delete_apex_overlay()
        elif operation == 'fetch_logs':
            fetch_logs()
        elif operation == 'new_project_from_existing_directory':
            new_project_from_existing_directory()
        elif operation == 'debug_log':
            TODO()
        elif operation == 'open_sfdc_url':
            open_sfdc_url()
        else:
            print util.generate_error_response('Invalid operation requested')

    if args.callback != None:
        os.system(args.callback)