# HG changeset patch # User Benjamin Golinvaux # Date 1586347297 -7200 # Node ID c81ac6ff232b378f8fc4257b1bb418fe8a236464 # Parent 2bf30ef727e3c0c0498be75eecb253efbb3c1070 ImportDicomFiles.py is now compatible with both Python 2.7 and Python 3.x (tested with >= 3.5) diff -r 2bf30ef727e3 -r c81ac6ff232b Resources/Samples/ImportDicomFiles/ImportDicomFiles.py --- 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")