Mercurial > hg > orthanc-tests
comparison Tests/Toolbox.py @ 21:2a29bcff60a7
tests of image decoding
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 22 Jun 2015 14:14:37 +0200 |
parents | 7b69a561f4d3 |
children | 156c7ae164b5 |
comparison
equal
deleted
inserted
replaced
20:f3d08a75a636 | 21:2a29bcff60a7 |
---|---|
75 d = '' | 75 d = '' |
76 if len(data.keys()) > 0: | 76 if len(data.keys()) > 0: |
77 d = '?' + urlencode(data) | 77 d = '?' + urlencode(data) |
78 | 78 |
79 http = httplib2.Http() | 79 http = httplib2.Http() |
80 http.follow_redirects = False | |
80 _SetupCredentials(orthanc, http) | 81 _SetupCredentials(orthanc, http) |
81 | 82 |
82 resp, content = http.request(orthanc['Url'] + uri + d, 'GET', body = body, | 83 resp, content = http.request(orthanc['Url'] + uri + d, 'GET', body = body, |
83 headers = headers) | 84 headers = headers) |
84 if not (resp.status in [ 200 ]): | 85 if not (resp.status in [ 200 ]): |
89 except: | 90 except: |
90 return content | 91 return content |
91 | 92 |
92 def _DoPutOrPost(orthanc, uri, method, data, contentType, headers): | 93 def _DoPutOrPost(orthanc, uri, method, data, contentType, headers): |
93 http = httplib2.Http() | 94 http = httplib2.Http() |
95 http.follow_redirects = False | |
94 _SetupCredentials(orthanc, http) | 96 _SetupCredentials(orthanc, http) |
95 | 97 |
96 if isinstance(data, str): | 98 if isinstance(data, str): |
97 body = data | 99 body = data |
98 if len(contentType) != 0: | 100 if len(contentType) != 0: |
114 except: | 116 except: |
115 return content | 117 return content |
116 | 118 |
117 def DoDelete(orthanc, uri): | 119 def DoDelete(orthanc, uri): |
118 http = httplib2.Http() | 120 http = httplib2.Http() |
121 http.follow_redirects = False | |
119 _SetupCredentials(orthanc, http) | 122 _SetupCredentials(orthanc, http) |
120 | 123 |
121 resp, content = http.request(orthanc['Url'] + uri, 'DELETE') | 124 resp, content = http.request(orthanc['Url'] + uri, 'DELETE') |
122 if not (resp.status in [ 200 ]): | 125 if not (resp.status in [ 200 ]): |
123 raise Exception(resp.status) | 126 raise Exception(resp.status) |