Skip to content

Commit

Permalink
Script improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sgeulette committed Dec 18, 2022
1 parent 9cf25ce commit 0fa469f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions scripts/run-del-files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-del-mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0fa469f

Please sign in to comment.