@@ -12,7 +12,7 @@ def __init__(self):
12
12
DB .__init__ (self , "SandboxMetadataDB" , "WorkloadManagement/SandboxMetadataDB" )
13
13
result = self .__initializeDB ()
14
14
if not result ["OK" ]:
15
- raise RuntimeError (f"Can't create tables: { result ['Message' ]} " )
15
+ raise RuntimeError (f"Can't create tables: { result ['Message' ]} " )
16
16
self .__assignedSBGraceDays = 0
17
17
self .__unassignedSBGraceDays = 15
18
18
@@ -112,7 +112,7 @@ def registerAndGetSandbox(self, owner, ownerDN, ownerGroup, sbSE, sbPFN, size=0)
112
112
Register a new sandbox in the metadata catalog
113
113
Returns ( sbid, newSandbox )
114
114
"""
115
- result = self .__registerAndGetOwnerId (owner , ownerDN , ownerGroup )
115
+ result = self .__registerAndGetOwnerId (owner , ownerDN , ownerGroup )
116
116
if not result ["OK" ]:
117
117
return result
118
118
ownerId = result ["Value" ]
@@ -135,7 +135,7 @@ def registerAndGetSandbox(self, owner, ownerDN, ownerGroup, sbSE, sbPFN, size=0)
135
135
if not result ["OK" ]:
136
136
return result
137
137
if not result ["Value" ]:
138
- return S_ERROR ("Location %s already exists but doesn't belong to the user or setup" )
138
+ return S_ERROR ("SandBox already exists but doesn't belong to the user or setup" )
139
139
sbId = result ["Value" ][0 ][0 ]
140
140
self .accessedSandboxById (sbId )
141
141
return S_OK ((sbId , False ))
@@ -144,7 +144,7 @@ def registerAndGetSandbox(self, owner, ownerDN, ownerGroup, sbSE, sbPFN, size=0)
144
144
return S_OK ((result ["lastRowId" ], True ))
145
145
result = self ._query ("SELECT LAST_INSERT_ID()" )
146
146
if not result ["OK" ]:
147
- return S_ERROR ("Can't determine sandbox id after insertion" )
147
+ return S_ERROR ("Can't determine sandbox id after insertion" )
148
148
return S_OK ((result ["Value" ][0 ][0 ], True ))
149
149
150
150
def accessedSandboxById (self , sbId ):
@@ -174,12 +174,12 @@ def assignSandboxesToEntities(self, enDict, requesterName, requesterGroup, enSet
174
174
for entityId in enDict :
175
175
for sbTuple in enDict [entityId ]:
176
176
if not isinstance (sbTuple , (tuple , list )):
177
- return S_ERROR ("Entry for entity %s is not a itterable of tuples/lists" % entityId )
177
+ return S_ERROR (f "Entry for entity { entityId } is not an iterable of tuples/lists" )
178
178
if len (sbTuple ) != 2 :
179
- return S_ERROR ("SB definition is not ( SBLocation, Type )! It's '%s'" % str ( sbTuple ) )
179
+ return S_ERROR (f "SB definition is not ( SBLocation, Type )! It's { sbTuple } " )
180
180
SBLocation = sbTuple [0 ]
181
181
if SBLocation .find ("SB:" ) != 0 :
182
- return S_ERROR ("%s doesn't seem to be a sandbox" % SBLocation )
182
+ return S_ERROR (f" { SBLocation } doesn't seem to be a sandbox" )
183
183
SBLocation = SBLocation [3 :]
184
184
splitted = List .fromChar (SBLocation , "|" )
185
185
if len (splitted ) < 2 :
@@ -197,7 +197,8 @@ def assignSandboxesToEntities(self, enDict, requesterName, requesterGroup, enSet
197
197
insertValues = []
198
198
if not result ["OK" ]:
199
199
self .log .warn (
200
- "Cannot find id for %s:%s with requester %s@%s" % (SEName , SEPFN , requesterName , requesterGroup )
200
+ f"Cannot find id for { SEName } :" ,
201
+ f"{ SEPFN } with requester { requesterName } @{ requesterGroup } : { result ['Message' ]} " ,
201
202
)
202
203
else :
203
204
sbId = result ["Value" ]
@@ -273,7 +274,7 @@ def unassignEntities(self, entitiesDict, requesterName, requesterGroup):
273
274
escapedSetup = self ._escapeString (entitySetup )["Value" ]
274
275
result = self .__filterEntitiesByRequester (entitiesIds , escapedSetup , requesterName , requesterGroup )
275
276
if not result ["OK" ]:
276
- gLogger .error (f "Cannot filter entities: { result [' Message' ] } " )
277
+ gLogger .error ("Cannot filter entities" , result [" Message" ] )
277
278
continue
278
279
ids = result ["Value" ]
279
280
if not ids :
@@ -283,7 +284,7 @@ def unassignEntities(self, entitiesDict, requesterName, requesterGroup):
283
284
sqlCmd = "DELETE FROM `sb_EntityMapping` WHERE %s" % " AND " .join (sqlCond )
284
285
result = self ._update (sqlCmd )
285
286
if not result ["OK" ]:
286
- gLogger .error (f "Cannot unassign entities: { result [' Message' ] } " )
287
+ gLogger .error ("Cannot unassign entities" , result [" Message" ] )
287
288
else :
288
289
updated += 1
289
290
return S_OK (updated )
0 commit comments