diff --git a/scripts/run-del-files.py b/scripts/run-del-files.py index b78c382..b0e75af 100644 --- a/scripts/run-del-files.py +++ b/scripts/run-del-files.py @@ -20,21 +20,23 @@ pc = portal.portal_catalog brains = pc.unrestrictedSearchResults(portal_type=types) -for i, brain in enumerate(brains, start=1): +count = 0 +for brain in brains: # if i > 1001: # sys.exit(1) - if batch_value and i > batch_value: # so it is possible to run this step partially + count += 1 + if batch_value and count > batch_value: # so it is possible to run this step partially break fil = brain.getObject() try: api.content.delete(obj=fil, check_linkintegrity=False) except AssertionError as error: # in zc.relation logger.error("Cannot delete {}".format(fil.absolute_url())) - if doit and i % 1000 == 0: - logger.warn('Commit done on count {}'.format(i)) + if doit and count % 1000 == 0: + logger.warn('Commit done on count {}'.format(count)) transaction.commit() -logger.warn('Deleted {} files'.format(i)) +logger.warn('Deleted {} files'.format(count)) if doit: transaction.commit() diff --git a/scripts/run-del-mails.py b/scripts/run-del-mails.py index d6a1638..abb56cd 100644 --- a/scripts/run-del-mails.py +++ b/scripts/run-del-mails.py @@ -30,7 +30,7 @@ count = 0 old_parent = None -for i, brain in enumerate(brains, start=1): +for brain in brains: if brain.id == 'test_creation_modele': continue if batch_value and count > batch_value: # so it is possible to run this step partially