@@ -82,22 +82,24 @@ def get_request_id(self) -> bool:
8282 print (f"Request ID: { self .request_id } " )
8383 return True
8484
85- def download_log (self , log_name_url : str , log_name : str = None ) -> bool :
85+ def download_log (
86+ self , log_name_url : str , log_name : str = None , is_failed : bool = False
87+ ) -> bool :
8688 """
8789 Download a log from the Testing Farm.
8890 """
89- for _ in range (5 ):
90- print (f"Downloading log: { log_name_url } " )
91+ for _ in range (2 ):
92+ logfile_dir = self .log_dir / "results" if is_failed else self .log_dir
93+ print (f"Downloading log '{ log_name_url } ' to '{ logfile_dir } '" )
9194 response = requests .get (log_name_url , verify = False )
9295 if response .status_code == 200 :
93- with (self . log_dir / log_name ).open ("wb" ) as f :
96+ with (logfile_dir / log_name ).open ("wb" ) as f :
9497 f .write (response .content )
9598 return True
9699 else :
97- print (f"Failed to download log: { response .status_code } " )
98- time .sleep (3 ) # Wait before retrying
100+ time .sleep (2 ) # Wait before retrying
99101 else :
100- print ("Failed to download log after multiple attempts." )
102+ print (f "Failed to download log { log_name_url } after multiple attempts." )
101103 return False
102104
103105 def download_tmt_logs (self ):
@@ -131,15 +133,15 @@ def get_list_of_containers_logs(self, html_content: str):
131133 print (f"Failed to get list of failed containers: { e } " )
132134 return False
133135
134- def download_container_logs (self , failed : bool = False ) -> bool :
136+ def download_container_logs (self , is_failed : bool = False ) -> bool :
135137 """
136138 Download the failed container logs from the Testing Farm.
137139 """
138140 if not self .data_dir_url_link :
139141 print ("Data directory URL link not found." )
140142 return False
141143 url_link = self .data_dir_url_link
142- if failed :
144+ if is_failed :
143145 url_link += "/results"
144146
145147 print (f"Data directory URL link: { url_link } " )
@@ -150,7 +152,9 @@ def download_container_logs(self, failed: bool = False) -> bool:
150152 print (f"Failed to download data/results directory: { response .status_code } " )
151153 return False
152154 for cont in CONTAINERS :
153- self .download_log (f"{ url_link } /{ cont } .log" , f"{ cont } .log" )
155+ self .download_log (
156+ f"{ url_link } /{ cont } .log" , f"{ cont } .log" , is_failed = is_failed
157+ )
154158 return True
155159
156160 def get_xml_report (self ) -> bool :
@@ -162,14 +166,13 @@ def get_xml_report(self) -> bool:
162166 else :
163167 xml_report_url = f"{ REPORTS_PRIVATE_URL } /{ self .request_id } /results.xml"
164168 print (f"XML Report URL: { xml_report_url } " )
165- for _ in range (5 ):
169+ for _ in range (2 ):
166170 response = requests .get (xml_report_url , verify = False )
167171 if response .status_code == 200 :
168172 self .xml_dict = xmltodict .parse (response .content )
169173 break
170174 else :
171- print (f"Failed to download XML report: { response .status_code } " )
172- time .sleep (3 ) # Wait before retrying
175+ time .sleep (2 ) # Wait before retrying
173176 else :
174177 print ("Failed to download XML report after multiple attempts." )
175178 return False
@@ -194,4 +197,4 @@ def get_xml_report(self) -> bool:
194197 sys .exit (1 )
195198 downloader .download_tmt_logs ()
196199 downloader .download_container_logs ()
197- downloader .download_container_logs (failed = True )
200+ downloader .download_container_logs (is_failed = True )
0 commit comments