diff Resources/Samples/ImportDicomFiles/ImportDicomFiles.py @ 3817:37e20bbf25f5

merge
author Alain Mazy <alain@mazy.be>
date Wed, 08 Apr 2020 14:50:06 +0200
parents c81ac6ff232b
children
line wrap: on
line diff
--- a/Resources/Samples/ImportDicomFiles/ImportDicomFiles.py	Wed Apr 08 14:49:54 2020 +0200
+++ b/Resources/Samples/ImportDicomFiles/ImportDicomFiles.py	Wed Apr 08 14:50:06 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")