Mercurial > hg > orthanc
changeset 3815:c81ac6ff232b
ImportDicomFiles.py is now compatible
with both Python 2.7 and Python 3.x (tested
with >= 3.5)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 08 Apr 2020 14:01:37 +0200 |
parents | 2bf30ef727e3 |
children | 37e20bbf25f5 4f78da5613a1 |
files | Resources/Samples/ImportDicomFiles/ImportDicomFiles.py |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Resources/Samples/ImportDicomFiles/ImportDicomFiles.py Fri Apr 03 14:47:37 2020 +0200 +++ b/Resources/Samples/ImportDicomFiles/ImportDicomFiles.py Wed Apr 08 14:01:37 2020 +0200 @@ -72,7 +72,10 @@ # Authentication (for some weird reason, this method does # not always work) # http://en.wikipedia.org/wiki/Basic_access_authentication - headers['authorization'] = 'Basic ' + base64.b64encode(username + ':' + password) + creds_str = username + ':' + password + creds_str_bytes = creds_str.encode("ascii") + creds_str_bytes_b64 = b'Basic ' + base64.b64encode(creds_str_bytes) + headers['authorization'] = creds_str_bytes_b64.decode("ascii") resp, content = h.request(URL, 'POST', body = content, @@ -85,6 +88,8 @@ sys.stdout.write(" => failure (Is it a DICOM file? Is there a password?)\n") except: + type, value, traceback = sys.exc_info() + sys.stderr.write(str(value)) sys.stdout.write(" => unable to connect (Is Orthanc running? Is there a password?)\n")