Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 08:39:01

0001 import os
0002 import shutil
0003 import traceback
0004 from pathlib import Path
0005 
0006 from pandacommon.pandalogger.PandaLogger import PandaLogger
0007 
0008 from pandaserver.config import panda_config
0009 
0010 # logger
0011 _logger = PandaLogger().getLogger("cache_pilot_config")
0012 
0013 # list of source files to be copied
0014 source_file_list = [
0015     "/cvmfs/atlas.cern.ch/repo/sw/PandaPilot/tar/pilot2.tar.gz",
0016     "/cvmfs/atlas.cern.ch/repo/sw/PandaPilot/tar/pilot3.tar.gz",
0017 ]
0018 
0019 # default destination directory
0020 default_dest_dir = getattr(panda_config, "pilot_cache_dir", "/var/cache/pandaserver/pilot")
0021 
0022 
0023 def main(argv=tuple(), tbuf=None, **kwargs):
0024     _logger.debug("start")
0025     try:
0026         # ensure the destination directory
0027         dest_dir_path = Path(default_dest_dir)
0028         try:
0029             dest_dir_path.mkdir(mode=0o755, exist_ok=True)
0030         except Exception as e:
0031             _logger.error(f"failed to mkdir {dest_dir_path}: {e}")
0032         # copy
0033         for source_file in source_file_list:
0034             if not os.path.exists(source_file):
0035                 _logger.warning(f"source file {source_file} does not exist, skipped")
0036                 continue
0037             dest_file_path = shutil.copy(source_file, dest_dir_path)
0038             _logger.debug(f"copied {source_file} to {dest_file_path}")
0039     except Exception as e:
0040         err_str = traceback.format_exc()
0041         _logger.error(f"failed to copy files: {err_str}")
0042     # done
0043     _logger.debug("done")
0044 
0045 
0046 if __name__ == "__main__":
0047     main()