def post_experiment(project_id, title, description, start_date, experiment_num = ''): """This uses the webservices abstraction of httplib in the interface folder to post an experiment to NEES Args: project_id: NEEShub Project Specific IDs title: What you want the Experiment Title to be. description: How you'd like to describe it. start_date: start date (experiment_num): Chose experiment number (RECOMMNDED TO LEAVE BLANK!) Returns: string that is the experiment id for the created experiment.""" #Generate form for Experiment Name specification. name_form = utils.generate_experiment_name_xml(experiment_num) #Fill out the XML content form. content = """<Experiment viewable="MEMBERS" type="Structured" > """+name_form+""" <title>"""+title+"""</title> <ExperimentDomain id="1" /> <status>private</status> <description>"""+description+"""</description> <startDate>"""+start_date+"""</startDate> </Experiment>""" #Fill out the http header dictionary. headers = {'Host': httphost, 'Accept': 'application/xml', 'Content-Type': 'application/xml', 'Content-Length': str(len( content )) } #Generate NEES specific request path. request = "%s%s/Experiment" % (neeshub_project_path, project_id) authenticated_request = utils.authenticate_request(request) response_dictionary = conn.request("POST",authenticated_request, content, headers) triallocation = response_dictionary['location'] exp_id = utils.find_experiment_id(triallocation) return exp_id
def post_project(title, description, contact_name='', contact_email='', start_date='', fundorg='', nick_name='', fund_org='', fund_org_proj=''): """Creates a NEES webservices Project. Args: title: What you want the Project Title to be. description: How you'd like to describe it. start_date: start date (experiment_num): Chose experiment number (RECOMMNDED TO LEAVE BLANK!) Returns: string that is the experiment id for the created experiment.""" xml_form = utils.generate_project_title_xml(title, description, contact_name, contact_email, start_date, fundorg, nick_name, fund_org, fund_org_proj) headers = {'Host': httphost, 'Accept':'application/xml', 'Content-Type':'application/xml', 'Content-Length':str(len(xml_form))} request = "/REST/Project" authentic_request = utils.authenticate_request(request) response_dictionary = conn.request('POST',authentic_request,xml_form,headers) project_location = response_dictionary['location'] prj_id = utils.find_experiment_id(project_location) return prj_id