Mercurial > hg > orthanc
view Resources/Samples/Python/DownloadAnonymized.py @ 635:cd3b60f6e7d4
refactoring cmake
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Oct 2013 10:48:03 +0100 |
parents | 61e4c62b8c35 |
children | 44382c8bcd15 |
line wrap: on
line source
#!/usr/bin/python # -*- coding: utf-8 -*- URL = 'http://localhost:8042' # # This sample code will download a ZIP file for each patient that has # been anonymized in Orthanc. # import os import os.path import sys import RestToolbox # Loop over the patients for patient in RestToolbox.DoGet('%s/patients' % URL): # Ignore patients whose name starts with "Anonymized", as it is # the result of a previous anonymization infos = RestToolbox.DoGet('%s/patients/%s' % (URL, patient)) name = infos['MainDicomTags']['PatientName'].lower() if name.startswith('anonymized'): # Trigger the download print 'Downloading %s' % name zipContent = RestToolbox.DoGet('%s/patients/%s/archive' % (URL, patient)) f = open(os.path.join('/tmp', name + '.zip'), 'wb') f.write(zipContent) f.close()