33import logging
44import os
55import shlex
6+ from pathlib import Path
67
78from DIRAC .ConfigurationSystem .Client .Helpers .Operations import Operations
89from DIRAC .Core .Utilities .ReturnValues import SErrorException , returnSingleResult , returnValueOrRaise
@@ -75,7 +76,7 @@ def _execute(self, job_path: os.PathLike[str], workflow_commons: WorkflowCommons
7576 _prepareRequest (self .request , workflow_commons .job_id )
7677
7778 try :
78- file_list = returnValueOrRaise (systemCall (0 , shlex .split ("ls -al" )))
79+ file_list = returnValueOrRaise (systemCall (0 , shlex .split (f "ls -al { str ( job_path ) } " )))
7980 if file_list :
8081 logger .info ("The contents of the working directory..." )
8182 logger .info (str (file_list [1 ]))
@@ -85,7 +86,7 @@ def _execute(self, job_path: os.PathLike[str], workflow_commons: WorkflowCommons
8586 logger .error ("Failed to list the log directory\n %s" , e )
8687
8788 workflow_commons .log_dir = os .path .realpath (
88- os . path . join (job_path , f"./job/ log/ { workflow_commons .production_id } / { workflow_commons .prod_job_id } " )
89+ Path (job_path ). joinpath ( "job" , " log" , workflow_commons .production_id , workflow_commons .production_id )
8990 )
9091 logger .info ("Selected log files will be temporarily stored in %s" , workflow_commons .log_dir )
9192
@@ -94,7 +95,7 @@ def _execute(self, job_path: os.PathLike[str], workflow_commons: WorkflowCommons
9495 logger .info ("Determining the files to be saved in the logs." )
9596
9697 try :
97- selected_files = returnValueOrRaise (_determineRelevantFiles (log_extensions ))
98+ selected_files = returnValueOrRaise (_determineRelevantFiles (log_extensions , path = job_path ))
9899 except SErrorException as e :
99100 logger .error ("Completely failed to select relevant log files." , exc_info = e )
100101 return # Does not fail
@@ -123,7 +124,7 @@ def _execute(self, job_path: os.PathLike[str], workflow_commons: WorkflowCommons
123124
124125 # zip all files
125126 try :
126- zip_file_name = returnValueOrRaise (_zip_files (workflow_commons .prod_job_id , selected_files ))
127+ zip_file_name = returnValueOrRaise (_zip_files (workflow_commons .prod_job_id , selected_files , path = job_path ))
127128 except SErrorException as e :
128129 logger .error ("Failed to create zip of log files %s" , e )
129130 self .job_report .setApplicationStatus ("Failed to create zip of log files" )
@@ -133,7 +134,7 @@ def _execute(self, job_path: os.PathLike[str], workflow_commons: WorkflowCommons
133134
134135 # logFilePath is something like /lhcb/MC/2016/LOG/00095376/0000/
135136 # the zipFileName should have the same name, e.g. 00000381.zip
136- zip_path = os . path . join (workflow_commons .log_file_path , zip_file_name )
137+ zip_path = Path ( job_path ). joinpath (workflow_commons .log_file_path , zip_file_name )
137138 log_https_url = _get_log_url (log_se , zip_path )
138139
139140 logger .info ("putFile %s to %s" , zip_file_name , log_se )
@@ -150,10 +151,7 @@ def _execute(self, job_path: os.PathLike[str], workflow_commons: WorkflowCommons
150151 try :
151152 upload_result_dict = returnValueOrRaise (
152153 _uploadLogToFailoverSE (
153- self .failover_transfer ,
154- zip_file_name ,
155- log_lfn_path ,
156- workflow_commons .site_name ,
154+ self .failover_transfer , zip_file_name , log_lfn_path , workflow_commons .site_name , path = job_path
157155 )
158156 )
159157
0 commit comments