I'm working on an automatic, daily QA for our MRI systems. I set-up qatrack successfully and everything is working so far (thanks to the QAtrack Wiki and Google Groups posts).
I already managed (using a code snippet from one of the posts) to send numerical, boolean and strings to QATrack. However, I do not know how to get the file upload working (images, text file).
Any help or insights would be appreciated.
Thanks,
Ed
Hi,
here is the link I was referring to:
https://groups.google.com/forum/#!searchin/qatrack/$23197/qatrack/vO5H-zsfgsc/jeWS4qpxKRkJ
and helpful as well:
https://groups.google.com/forum/#!searchin/qatrack/python$20list/qatrack/-IpMpiS6-1c/xZI1Tesf2nIJ
both links contain posts which include python snippets.
--
You received this message because you are subscribed to the Google Groups "QATrack+" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qatrack+u...@googlegroups.com.
To post to this group, send email to qat...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import datetimeimport json
import requests
def get_csrf_token_from_url(url, session): session.get(url) return session.cookies['csrftoken']
root = "http://randlet.com/qatrack/"s = requests.Session()work_started = datetime.datetime.now().strftime("%d-%m-%Y %H:%M")test_list_url = root+"qa/utc/perform/25/"upload_test_id = 44
# perform the login ################################################login_url = root + "accounts/login/"login_data = { 'username':'demo', 'password':'demo', 'csrfmiddlewaretoken': get_csrf_token_from_url(login_url, s)}login_resp = s.post(login_url, data=login_data)
# upload data ######################################################test_list_token = get_csrf_token_from_url(test_list_url, s)img = "image.png"upload_url = root+"qa/upload/"files = {"upload": open(img, "rb")}upload_data = { 'test_id': upload_test_id, 'meta': json.dumps({ "work_started": work_started, "work_completed":"", }), 'csrfmiddlewaretoken': test_list_token}resp = s.post(upload_url, files=files, data=upload_data)data = json.loads(resp.text)
# encode your form data as stringstest_data = { 'csrfmiddlewaretoken': test_list_token, "work_started": work_started, "work_completed":"", "status":"", "form-TOTAL_FORMS":"2", "form-INITIAL_FORMS":"2", "form-MAX_NUM_FORMS":"1000", "form-0-string_value": data['temp_file_name'], "form-1-value": data['result']['mean'],}
# submit test dataresp = s.post(test_list_url, data=test_data)
To unsubscribe from this group and stop receiving emails from it, send an email to qatrack+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "QATrack+" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qatrack+unsubscribe@googlegroups.com.