ATLAS Offline Software
postprocessors/directory_cleaner.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaCommon import Logging
4 from ...decorators import timed
5 import glob
6 import os
7 
8 
9 logger = Logging.logging.getLogger("PowhegControl")
10 
11 
12 @timed("directory cleaner")
13 def directory_cleaner(process):
14  """! Clean up the directory after running.
15 
16  Remove any leftover files to avoid clutter.
17 
18  @author James Robinson <james.robinson@cern.ch>
19  """
20  nRemoved, nFailures = 0, 0
21  for file_name in sum([glob.glob(_f) for _f in process.files_for_cleanup], []):
22  logger.debug("... removing unneeded file: {}".format(file_name))
23  try:
24  os.remove(file_name)
25  except OSError:
26  logger.debug("... could not remove {}".format(file_name))
27  nFailures += 1
28  nRemoved += 1
29  logger.info("... removed {} unneeded files with a further {} failures".format(nRemoved, nFailures))
python.decorators.timed.timed
def timed(name)
Decorator to output function execution time.
Definition: timed.py:12
vtune_athena.format
format
Definition: vtune_athena.py:14
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
python.algorithms.postprocessors.directory_cleaner.directory_cleaner
def directory_cleaner(process)
Clean up the directory after running.
Definition: postprocessors/directory_cleaner.py:13