def run(self): '''This wraps the http request function in a threading operation.''' pool.acquire() thread_conn = ih.http(httphost) # Enables loop that attempts to post file information and breaks if successful. # while True: request_dict = thread_conn.request(self.request_type, self.request, self.content, self.headers) location = request_dict['location'] data = request_dict['data'] status = request_dict['status'] message = "%s posted to %s. Status: %s. Reply: %s" % (self.filename, location, status, data) nees_logging.append_log(neeshub_log_filename, message) # If post fails, wait a second before retrying. # if status == '400': # time.sleep(3) # Once Post is Successful, end the loop. # elif status == '200': # break pool.release()
#Adapts the abstracted http layer to our NEEShub-specific interfaces. #Created by Val Gorbunov for the use of NEES@UCSB import time import utils import nees_logging import multipart_http import threading_http from config import * import interface.http as ih conn = ih.http(httphost) # # NEESHUB SPECIFIC GET FUNCTIONS # def get_experiment_id_dictionary(project_id): """Make NEEShub request for Experiment-IDs and Experiment Numbers. Args: project_id: NEEShub-given project id. Returns: dictionary of Experiment-IDs in the format of {'Experiment#':'ID#'...} """ request = "%s%s" % (neeshub_project_path, project_id,) authentic_request = utils.authenticate_request(request) request_dict = conn.request("GET", authentic_request) data = request_dict['data'] index = 0 experimentstring = "%s%s/Experiment/" % (neeshub_project_path, project_id,)