def run_async_operation(request_handler, operation_name): gc.logger.debug('>>> running an async operation') request_id = util.generate_request_id() params, raw_post_body, plugin_client = get_request_params(request_handler) gc.logger.debug(request_id) gc.logger.debug(params) gc.logger.debug(raw_post_body) worker_thread = BackgroundWorker(operation_name, params, True, request_id, raw_post_body, plugin_client) gc.logger.debug('worker created') worker_thread.start() gc.logger.debug('worker thread started') async_request_queue[request_id] = worker_thread gc.logger.debug('placed into queue') #q = Queue() #on larger object puts, process would hang #using manager based on this recommendation: #http://stackoverflow.com/questions/11442892/python-multiprocessing-queue-failure # manager = Manager() # q = manager.Queue() #TODO: request is failing here many times # gc.logger.debug('finished with queue') #worker = BackgroundWorker(operation_name, params, True, request_id, raw_post_body, q) #gc.logger.debug('worker created') #p = multiprocessing.Process(target=process_request_in_background,args=(worker,)) #p.start() #gc.logger.debug('started process!') #add_to_request_queue(request_id, p, q) #gc.logger.debug('preparing to response with the async id!') return respond_with_async_request_id(request_handler, request_id)
def run_async_operation(request_handler, operation_name): gc.logger.debug('>>> running an async operation') request_id = util.generate_request_id() params, raw_post_body, plugin_client = get_request_params(request_handler) gc.logger.debug(request_id) gc.logger.debug(params) gc.logger.debug(raw_post_body) worker_thread = BackgroundWorker(operation_name, params, True, request_id, raw_post_body, plugin_client) gc.logger.debug('worker created') worker_thread.start() gc.logger.debug('worker thread started') async_request_queue[request_id] = worker_thread gc.logger.debug('placed into queue') #q = Queue() #on larger object puts, process would hang #using manager based on this recommendation: #http://stackoverflow.com/questions/11442892/python-multiprocessing-queue-failure # manager = Manager() # q = manager.Queue() #TODO: request is failing here many times # gc.logger.debug('finished with queue') #worker = BackgroundWorker(operation_name, params, True, request_id, raw_post_body, q) #gc.logger.debug('worker created') #p = multiprocessing.Process(target=process_request_in_background,args=(worker,)) #p.start() #gc.logger.debug('started process!') #add_to_request_queue(request_id, p, q) #gc.logger.debug('preparing to response with the async id!') return respond_with_async_request_id(request_handler, request_id)
def connections_delete_request(request_handler): request_id = util.generate_request_id() params, raw_post_body, plugin_client = get_request_params(request_handler) worker_thread = BackgroundWorker('delete_connection', params, False, request_id, raw_post_body, plugin_client) worker_thread.start() worker_thread.join() response = worker_thread.response respond(request_handler, response)
def connections_delete_request(request_handler): request_id = util.generate_request_id() params, raw_post_body, plugin_client = get_request_params(request_handler) worker_thread = BackgroundWorker('delete_connection', params, False, request_id, raw_post_body, plugin_client) worker_thread.start() worker_thread.join() response = worker_thread.response respond(request_handler, response)
def get_active_session_request(request_handler): ''' GET /[email protected]&password=force&org_type=developer ''' request_id = util.generate_request_id() params, json_body, plugin_client = get_request_params(request_handler) worker_thread = BackgroundWorker('get_active_session', params, False, request_id, json_body, plugin_client) worker_thread.start() worker_thread.join() response = worker_thread.response respond(request_handler, response)
def get_active_session_request(request_handler): ''' GET /[email protected]&password=force&org_type=developer ''' request_id = util.generate_request_id() params, json_body, plugin_client = get_request_params(request_handler) worker_thread = BackgroundWorker('get_active_session', params, False, request_id, json_body, plugin_client) worker_thread.start() worker_thread.join() response = worker_thread.response respond(request_handler, response)
def project_edit_subscription(request_handler): ''' POST /project/subscription { "project_name" : "my project name" "subscription" : ["ApexClass", "ApexPage"] } ''' request_id = util.generate_request_id() params, raw_post_body, plugin_client = get_request_params(request_handler) worker_thread = BackgroundWorker('update_subscription', params, False, request_id, raw_post_body, plugin_client) worker_thread.start() worker_thread.join() response = worker_thread.response respond(request_handler, response)
def refresh_metadata_index(request_handler): ''' GET /project/get_index/refresh { "project_name" : "my project name", "metadata_types" : ["ApexClass"] } call to refresh a certain type of metadata ''' request_id = util.generate_request_id() params, json_body, plugin_client = get_request_params(request_handler) worker_thread = BackgroundWorker('refresh_metadata_index', params, False, request_id, json_body, plugin_client) worker_thread.start() worker_thread.join() response = worker_thread.response respond(request_handler, response)
def get_metadata_index(request_handler): ''' GET /project/get_index { "project_name" : "my project name", "keyword" : "mykeyword" //optional } call to get the metadata index for a project ''' request_id = util.generate_request_id() params, json_body, plugin_client = get_request_params(request_handler) worker_thread = BackgroundWorker('get_indexed_metadata', params, False, request_id, json_body, plugin_client) worker_thread.start() worker_thread.join() response = worker_thread.response respond(request_handler, response)
def metadata_list_request(request_handler): ''' GET /metadata/list { "sid" : "", "metadata_type" : "", "murl" : "" } call to get a list of metadata of a certain type ''' request_id = util.generate_request_id() params, json_body, plugin_client = get_request_params(request_handler) worker_thread = BackgroundWorker('list_metadata', params, False, request_id, json_body, plugin_client) worker_thread.start() worker_thread.join() response = worker_thread.response respond(request_handler, response)
def metadata_list_request(request_handler): ''' GET /metadata/list { "sid" : "", "metadata_type" : "", "murl" : "" } call to get a list of metadata of a certain type ''' request_id = util.generate_request_id() params, json_body, plugin_client = get_request_params(request_handler) worker_thread = BackgroundWorker('list_metadata', params, False, request_id, json_body, plugin_client) worker_thread.start() worker_thread.join() response = worker_thread.response respond(request_handler, response)
def update_credentials_request(request_handler): ''' POST /project/creds { "project_name" : "my project name" "username" : "*****@*****.**", "password" : "force", "org_type" : "developer", } NOTE: project name should not be updated, as it is used to find the project in question TODO: maybe we assign a unique ID to each project which will give users the flexibility to change the project name?? TODO: we may need to implement a "clean" flag which will clean the project after creds have been updated ''' request_id = util.generate_request_id() params, raw_post_body, plugin_client = get_request_params(request_handler) worker_thread = BackgroundWorker('update_credentials', params, False, request_id, raw_post_body, plugin_client) worker_thread.start() worker_thread.join() response = worker_thread.response respond(request_handler, response)
def update_credentials_request(request_handler): ''' POST /project/creds { "project_name" : "my project name" "username" : "*****@*****.**", "password" : "force", "org_type" : "developer", } NOTE: project name should not be updated, as it is used to find the project in question TODO: maybe we assign a unique ID to each project which will give users the flexibility to change the project name?? TODO: we may need to implement a "clean" flag which will clean the project after creds have been updated ''' request_id = util.generate_request_id() params, raw_post_body, plugin_client = get_request_params(request_handler) worker_thread = BackgroundWorker('update_credentials', params, False, request_id, raw_post_body, plugin_client) worker_thread.start() worker_thread.join() response = worker_thread.response respond(request_handler, response)