# HG changeset patch # User Sebastien Jodogne # Date 1471344578 -7200 # Node ID bec08e9236f5c33ee9ddd0a959abee579aab9bdf # Parent 4a151d26c98a10b1eac497cbb045f289894975e8 more robust AutoClassify.py sample diff -r 4a151d26c98a -r bec08e9236f5 Resources/Samples/Python/AutoClassify.py --- a/Resources/Samples/Python/AutoClassify.py Tue Aug 16 11:28:31 2016 +0200 +++ b/Resources/Samples/Python/AutoClassify.py Tue Aug 16 12:49:38 2016 +0200 @@ -110,13 +110,17 @@ if change['ChangeType'] == 'NewInstance': try: ClassifyInstance(change['ID']) + + # If requested, remove the instance once it has been + # properly handled by "ClassifyInstance()". Thanks to + # the "try/except" block, the instance is not removed + # if the "ClassifyInstance()" function fails. + if args.remove: + RestToolbox.DoDelete('%s/instances/%s' % (URL, change['ID'])) + except: print('Unable to write instance %s to the disk' % change['ID']) - # If requested, remove the instance once it has been copied - if args.remove: - RestToolbox.DoDelete('%s/instances/%s' % (URL, change['ID'])) - current = r['Last'] if r['Done']: