66
77from DIRAC import gConfig , gLogger
88from DIRAC .Core .Utilities import TimeUtilities
9- from DIRAC .TransformationSystem .Client .TransformationClient import TransformationClient
9+ from DIRAC .MonitoringSystem .Client .WebAppClient import WebAppClient
1010
1111from WebAppDIRAC .Lib .WebHandler import WebHandler , WErr
1212
@@ -18,8 +18,8 @@ def web_getSelectionData(self):
1818 if self .getUserName ().lower () == "anonymous" :
1919 return {"prod" : [["Insufficient rights" ]]}
2020
21- tsClient = TransformationClient ()
22- if (result := tsClient .getDistinctAttributeValues ("Plugin" , {}))["OK" ]:
21+ waClient = WebAppClient ()
22+ if (result := waClient .getDistinctAttributeValues ("Plugin" , {}))["OK" ]:
2323 plugin = []
2424 if len (result ["Value" ]) > 0 :
2525 for i in result ["Value" ]:
@@ -30,7 +30,7 @@ def web_getSelectionData(self):
3030 plugin = "Error during RPC call"
3131 callback = {"plugin" : plugin }
3232
33- if (result := tsClient .getDistinctAttributeValues ("Status" , {}))["OK" ]:
33+ if (result := waClient .getDistinctAttributeValues ("Status" , {}))["OK" ]:
3434 status = []
3535 if len (result ["Value" ]) > 0 :
3636 for i in result ["Value" ]:
@@ -41,7 +41,7 @@ def web_getSelectionData(self):
4141 status = "Error during RPC call"
4242 callback ["prodStatus" ] = status
4343
44- if (result := tsClient .getDistinctAttributeValues ("TransformationGroup" , {}))["OK" ]:
44+ if (result := waClient .getDistinctAttributeValues ("TransformationGroup" , {}))["OK" ]:
4545 group = []
4646 if len (result ["Value" ]) > 0 :
4747 for i in result ["Value" ]:
@@ -52,7 +52,7 @@ def web_getSelectionData(self):
5252 group = "Error during RPC call"
5353 callback ["transformationGroup" ] = group
5454
55- if (result := tsClient .getDistinctAttributeValues ("AgentType" , {}))["OK" ]:
55+ if (result := waClient .getDistinctAttributeValues ("AgentType" , {}))["OK" ]:
5656 atype = []
5757 if len (result ["Value" ]) > 0 :
5858 for i in result ["Value" ]:
@@ -63,7 +63,7 @@ def web_getSelectionData(self):
6363 atype = "Error during RPC call"
6464 callback ["agentType" ] = atype
6565
66- if (result := tsClient .getDistinctAttributeValues ("Type" , {}))["OK" ]:
66+ if (result := waClient .getDistinctAttributeValues ("Type" , {}))["OK" ]:
6767 transType = []
6868 if result ["Value" ]:
6969 for i in result ["Value" ]:
@@ -116,8 +116,8 @@ def web_getTransformationData(
116116 TransformationFamily ,
117117 )
118118
119- tsClient = TransformationClient (timeout = 3600 )
120- if not (result := tsClient .getTransformationSummaryWeb (params , self .globalSort , start , limit ))["OK" ]:
119+ waClient = WebAppClient (timeout = 3600 )
120+ if not (result := waClient .getTransformationSummaryWeb (params , self .globalSort , start , limit ))["OK" ]:
121121 return {"success" : "false" , "error" : result ["Message" ]}
122122
123123 data = result ["Value" ]
@@ -175,7 +175,7 @@ def web_action(self, data_kind, id: int, tasks: int = None):
175175 return {"success" : "false" , "error" : "Action is unknown!!!" }
176176
177177 def web_executeOperation (self , action , ids ):
178- tsClient = TransformationClient ()
178+ waClient = WebAppClient ()
179179
180180 agentType = "Manual"
181181 if action == "clean" :
@@ -197,10 +197,10 @@ def web_executeOperation(self, action, ids):
197197
198198 for i in ids .split ("," ):
199199 try :
200- result = tsClient .setTransformationParameter (transid := int (i ), "Status" , status )
200+ result = waClient .setTransformationParameter (transid := int (i ), "Status" , status )
201201 if result ["OK" ]:
202202 resString = f"ProdID: { transid } set to { action } successfully"
203- result = tsClient .setTransformationParameter (transid , "AgentType" , agentType )
203+ result = waClient .setTransformationParameter (transid , "AgentType" , agentType )
204204 if not result ["OK" ]:
205205 resString = f"ProdID: { transid } failed to set to { action } : { result ['Message' ]} "
206206 else :
@@ -212,16 +212,16 @@ def web_executeOperation(self, action, ids):
212212 return {"success" : "true" , "showResult" : callback }
213213
214214 def __fileRetry (self , prodid , mode ):
215- tsClient = TransformationClient ()
215+ waClient = WebAppClient ()
216216 result = None
217217 if mode == "proc" :
218- result = tsClient .getTransformationFilesCount (prodid , "ErrorCount" , {"Status" : "Processed" })
218+ result = waClient .getTransformationFilesCount (prodid , "ErrorCount" , {"Status" : "Processed" })
219219 elif mode == "not" :
220- result = tsClient .getTransformationFilesCount (
220+ result = waClient .getTransformationFilesCount (
221221 prodid , "ErrorCount" , {"Status" : ["Unused" , "Assigned" , "Failed" ]}
222222 )
223223 elif mode == "all" :
224- result = tsClient .getTransformationFilesCount (prodid , "ErrorCount" )
224+ result = waClient .getTransformationFilesCount (prodid , "ErrorCount" )
225225
226226 if not result ["OK" ]:
227227 return {"success" : "false" , "error" : result ["Message" ]}
@@ -238,12 +238,12 @@ def __fileRetry(self, prodid, mode):
238238 return {"success" : "true" , "result" : resList }
239239
240240 def __dataQuery (self , prodid ):
241- tsClient = TransformationClient ()
241+ waClient = WebAppClient ()
242242
243243 # FIXME: getTransformationInputDataQuery has been replaced by getTransformationMetaQuery in DIRAC v7r0
244- result = tsClient .getTransformationMetaQuery (prodid , "Input" )
244+ result = waClient .getTransformationMetaQuery (prodid , "Input" )
245245 if not result ["OK" ] and "Unknown method" in result ["Message" ]:
246- result = tsClient .getTransformationInputDataQuery (prodid )
246+ result = waClient .getTransformationInputDataQuery (prodid )
247247
248248 gLogger .debug ("-= #######" , result )
249249 if not result ["OK" ]:
@@ -253,20 +253,20 @@ def __dataQuery(self, prodid):
253253 return {"success" : "true" , "result" : back }
254254
255255 def __additionalParams (self , prodid ):
256- if not (result := TransformationClient ().getAdditionalParameters (prodid ))["OK" ]:
256+ if not (result := WebAppClient ().getAdditionalParameters (prodid ))["OK" ]:
257257 return {"success" : "false" , "error" : result ["Message" ]}
258258 data = result ["Value" ]
259259 back = [[i , data [i ]] for i in sorted (data )]
260260 return {"success" : "true" , "result" : back }
261261
262262 def __workflowxml (self , transid ):
263- tsClient = TransformationClient ()
264- if not (result := tsClient .getTransformations ({"TransformationID" : transid }))["OK" ]:
263+ waClient = WebAppClient ()
264+ if not (result := waClient .getTransformations ({"TransformationID" : transid }))["OK" ]:
265265 raise WErr .fromSERROR (result )
266266 return {"success" : "true" , "result" : result ["Value" ][0 ]["Body" ]}
267267
268268 def __getLoggingInfo (self , transid ):
269- if (result := TransformationClient ().getTransformationLogging (transid ))["OK" ]:
269+ if (result := WebAppClient ().getTransformationLogging (transid ))["OK" ]:
270270 if len (data := result ["Value" ]) > 0 :
271271 userdb = {}
272272 callback = []
@@ -282,8 +282,8 @@ def __getLoggingInfo(self, transid):
282282 return {"success" : "false" , "error" : result ["Message" ]}
283283
284284 def __transformationFileStatus (self , transid ):
285- tsClient = TransformationClient ()
286- if not (result := tsClient .getTransformationFilesCount (transid , "Status" ))["OK" ]:
285+ waClient = WebAppClient ()
286+ if not (result := waClient .getTransformationFilesCount (transid , "Status" ))["OK" ]:
287287 return {"success" : "false" , "error" : result ["Message" ]}
288288 resList = []
289289 if (total := result ["Value" ].pop ("Total" )) == 0 :
@@ -297,8 +297,8 @@ def __transformationFileStatus(self, transid):
297297 return {"success" : "true" , "result" : resList }
298298
299299 def __transformationDetail (self , prodid ):
300- tsClient = TransformationClient ()
301- if not (result := tsClient .getTransformationParameters (prodid , ["DetailedInfo" ]))["OK" ]:
300+ waClient = WebAppClient ()
301+ if not (result := waClient .getTransformationParameters (prodid , ["DetailedInfo" ]))["OK" ]:
302302 return {"success" : "false" , "error" : result ["Message" ]}
303303 if callback := result ["Value" ]:
304304 return {"success" : "true" , "result" : callback }
@@ -307,15 +307,15 @@ def __transformationDetail(self, prodid):
307307
308308 def __extendTransformation (self , transid , tasks ):
309309 gLogger .info (f"Extend transformation ({ transid } , { tasks } )" )
310- if (result := TransformationClient ().extendTransformation (transid , tasks ))["OK" ]:
310+ if (result := WebAppClient ().extendTransformation (transid , tasks ))["OK" ]:
311311 resString = f"{ transid } extended by { tasks } successfully"
312312 else :
313313 resString = f"{ transid } failed to extend: { result ['Message' ]} "
314314 gLogger .debug ("#######" , result )
315315 return {"success" : "true" , "showResult" : [resString ], "result" : resString }
316316
317317 def web_showFileStatus (self , start : int , limit : int , transformationId , status ):
318- result = TransformationClient ().getTransformationFilesSummaryWeb (
318+ result = WebAppClient ().getTransformationFilesSummaryWeb (
319319 {"TransformationID" : transformationId , "Status" : status },
320320 [["FileID" , "ASC" ]],
321321 start ,
@@ -357,7 +357,7 @@ def web_getTier1Sites(self):
357357
358358 def web_setSite (self , TransformationId : int , RunNumber : int , Site ):
359359 gLogger .info (f"\033 [0;31m setTransformationRunsSite({ TransformationId } , { RunNumber } , { Site } ) \033 [0m" )
360- result = TransformationClient ().setTransformationRunsSite (TransformationId , RunNumber , Site )
360+ result = WebAppClient ().setTransformationRunsSite (TransformationId , RunNumber , Site )
361361 if result ["OK" ]:
362362 return {"success" : "true" , "result" : "true" }
363363 return {"success" : "false" , "error" : result ["Message" ]}
@@ -379,7 +379,7 @@ def _prepareSearchParameters(
379379 transformationGroup ,
380380 TransformationFamily ,
381381 ):
382- """Prepare a query dictionary which can be used with TransformationClient .getTransformationSummaryWeb
382+ """Prepare a query dictionary which can be used with WebAppClient .getTransformationSummaryWeb
383383
384384 Note: This method can be overridden by extensions
385385 """
0 commit comments