Mercurial > hg > orthanc
comparison Resources/Samples/Python/AutoClassify.py @ 2075:bec08e9236f5
more robust AutoClassify.py sample
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 16 Aug 2016 12:49:38 +0200 |
parents | 7e6afa0beaf6 |
children | a3a65de1840f |
comparison
equal
deleted
inserted
replaced
2074:4a151d26c98a | 2075:bec08e9236f5 |
---|---|
108 for change in r['Changes']: | 108 for change in r['Changes']: |
109 # We are only interested interested in the arrival of new instances | 109 # We are only interested interested in the arrival of new instances |
110 if change['ChangeType'] == 'NewInstance': | 110 if change['ChangeType'] == 'NewInstance': |
111 try: | 111 try: |
112 ClassifyInstance(change['ID']) | 112 ClassifyInstance(change['ID']) |
113 | |
114 # If requested, remove the instance once it has been | |
115 # properly handled by "ClassifyInstance()". Thanks to | |
116 # the "try/except" block, the instance is not removed | |
117 # if the "ClassifyInstance()" function fails. | |
118 if args.remove: | |
119 RestToolbox.DoDelete('%s/instances/%s' % (URL, change['ID'])) | |
120 | |
113 except: | 121 except: |
114 print('Unable to write instance %s to the disk' % change['ID']) | 122 print('Unable to write instance %s to the disk' % change['ID']) |
115 | |
116 # If requested, remove the instance once it has been copied | |
117 if args.remove: | |
118 RestToolbox.DoDelete('%s/instances/%s' % (URL, change['ID'])) | |
119 | 123 |
120 current = r['Last'] | 124 current = r['Last'] |
121 | 125 |
122 if r['Done']: | 126 if r['Done']: |
123 print('Everything has been processed: Waiting...') | 127 print('Everything has been processed: Waiting...') |