Skip to content

Commit d391adc

Browse files
committed
fix: WMS DBs py3 only
1 parent d10f769 commit d391adc

File tree

10 files changed

+41
-112
lines changed

10 files changed

+41
-112
lines changed

src/DIRAC/WorkloadManagementSystem/Client/JobState/CachedJobState.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
IIUC this is a wrapper around the JobState object. It basically tries to cache
44
everything locally instead of going to the DB.
55
"""
6-
from __future__ import absolute_import
7-
from __future__ import division
8-
from __future__ import print_function
9-
10-
import six
116
import copy
127
import time
138

@@ -135,7 +130,7 @@ def deserialize(stub):
135130
if len(dataTuple) != 7:
136131
return S_ERROR("Invalid stub")
137132
# jid
138-
if not isinstance(dataTuple[0], six.integer_types):
133+
if not isinstance(dataTuple[0], int):
139134
return S_ERROR("Invalid stub 0")
140135
# cache
141136
if not isinstance(dataTuple[1], dict):
@@ -179,7 +174,7 @@ def __cacheAdd(self, key, value):
179174
self.__dirtyKeys.add(key)
180175

181176
def __cacheExists(self, keyList):
182-
if isinstance(keyList, six.string_types):
177+
if isinstance(keyList, str):
183178
keyList = [keyList]
184179
for key in keyList:
185180
if key not in self.__cache:
@@ -188,7 +183,7 @@ def __cacheExists(self, keyList):
188183

189184
def __cacheResult(self, cKey, functor, fArgs=None):
190185
# If it's a string
191-
if isinstance(cKey, six.string_types):
186+
if isinstance(cKey, str):
192187
if cKey not in self.__cache:
193188
if self.dOnlyCache:
194189
return S_ERROR("%s is not cached")
@@ -334,7 +329,7 @@ def getAppStatus(self):
334329
#
335330

336331
def setAttribute(self, name, value):
337-
if not isinstance(name, six.string_types):
332+
if not isinstance(name, str):
338333
return S_ERROR("Attribute name has to be a string")
339334
self.__cacheAdd("att.%s" % name, value)
340335
return S_OK()
@@ -357,7 +352,7 @@ def getAttributes(self, nameList=None):
357352
# Optimizer params
358353

359354
def setOptParameter(self, name, value):
360-
if not isinstance(name, six.string_types):
355+
if not isinstance(name, str):
361356
return S_ERROR("Optimizer parameter name has to be a string")
362357
self.__cacheAdd("optp.%s" % name, value)
363358
return S_OK()

src/DIRAC/WorkloadManagementSystem/Client/JobState/JobState.py

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
""" This object is a wrapper for setting and getting jobs states
22
"""
3-
4-
from __future__ import absolute_import
5-
from __future__ import division
6-
from __future__ import print_function
7-
8-
__RCSID__ = "$Id"
9-
10-
import six
113
import datetime
124

135
from DIRAC import gLogger, S_OK, S_ERROR
@@ -174,10 +166,10 @@ def __checkType(self, value, tList, canBeNone=False):
174166

175167
def setStatus(self, majorStatus, minorStatus=None, appStatus=None, source=None, updateTime=None):
176168
try:
177-
self.__checkType(majorStatus, six.string_types)
178-
self.__checkType(minorStatus, six.string_types, canBeNone=True)
179-
self.__checkType(appStatus, six.string_types, canBeNone=True)
180-
self.__checkType(source, six.string_types, canBeNone=True)
169+
self.__checkType(majorStatus, str)
170+
self.__checkType(minorStatus, str, canBeNone=True)
171+
self.__checkType(appStatus, str, canBeNone=True)
172+
self.__checkType(source, str, canBeNone=True)
181173
self.__checkType(updateTime, datetime.datetime, canBeNone=True)
182174
except TypeError as excp:
183175
return S_ERROR(str(excp))
@@ -206,8 +198,8 @@ def setStatus(self, majorStatus, minorStatus=None, appStatus=None, source=None,
206198

207199
def setMinorStatus(self, minorStatus, source=None, updateTime=None):
208200
try:
209-
self.__checkType(minorStatus, six.string_types)
210-
self.__checkType(source, six.string_types, canBeNone=True)
201+
self.__checkType(minorStatus, str)
202+
self.__checkType(source, str, canBeNone=True)
211203
except TypeError as excp:
212204
return S_ERROR(str(excp))
213205
result = JobState.__db.jobDB.setJobStatus(self.__jid, minorStatus=minorStatus)
@@ -230,8 +222,8 @@ def getStatus(self):
230222

231223
def setAppStatus(self, appStatus, source=None, updateTime=None):
232224
try:
233-
self.__checkType(appStatus, six.string_types)
234-
self.__checkType(source, six.string_types, canBeNone=True)
225+
self.__checkType(appStatus, str)
226+
self.__checkType(source, str, canBeNone=True)
235227
except TypeError as excp:
236228
return S_ERROR(str(excp))
237229
result = JobState.__db.jobDB.setJobStatus(self.__jid, applicationStatus=appStatus)
@@ -257,8 +249,8 @@ def getAppStatus(self):
257249

258250
def setAttribute(self, name, value):
259251
try:
260-
self.__checkType(name, six.string_types)
261-
self.__checkType(value, six.string_types)
252+
self.__checkType(name, str)
253+
self.__checkType(value, str)
262254
except TypeError as excp:
263255
return S_ERROR(str(excp))
264256
return JobState.__db.jobDB.setJobAttribute(self.__jid, name, value)
@@ -278,7 +270,7 @@ def setAttributes(self, attDict):
278270

279271
def getAttribute(self, name):
280272
try:
281-
self.__checkType(name, six.string_types)
273+
self.__checkType(name, str)
282274
except TypeError as excp:
283275
return S_ERROR(str(excp))
284276
return JobState.__db.jobDB.getJobAttribute(self.__jid, name)
@@ -298,8 +290,8 @@ def getAttributes(self, nameList=None):
298290

299291
def setOptParameter(self, name, value):
300292
try:
301-
self.__checkType(name, six.string_types)
302-
self.__checkType(value, six.string_types)
293+
self.__checkType(name, str)
294+
self.__checkType(value, str)
303295
except TypeError as excp:
304296
return S_ERROR(str(excp))
305297
return JobState.__db.jobDB.setJobOptParameter(self.__jid, name, value)
@@ -320,7 +312,7 @@ def setOptParameters(self, pDict):
320312
right_removeOptParameters = RIGHT_GET_INFO
321313

322314
def removeOptParameters(self, nameList):
323-
if isinstance(nameList, six.string_types):
315+
if isinstance(nameList, str):
324316
nameList = [nameList]
325317
try:
326318
self.__checkType(nameList, (list, tuple))
@@ -336,7 +328,7 @@ def removeOptParameters(self, nameList):
336328

337329
def getOptParameter(self, name):
338330
try:
339-
self.__checkType(name, six.string_types)
331+
self.__checkType(name, str)
340332
except TypeError as excp:
341333
return S_ERROR(str(excp))
342334
return JobState.__db.jobDB.getJobOptParameter(self.__jid, name)

src/DIRAC/WorkloadManagementSystem/DB/ElasticJobParametersDB.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@
2828
- setJobParameter()
2929
- deleteJobParameters()
3030
"""
31-
32-
from __future__ import absolute_import
33-
from __future__ import division
34-
from __future__ import print_function
35-
36-
import six
37-
38-
__RCSID__ = "$Id$"
39-
4031
from DIRAC import S_OK, gConfig
4132
from DIRAC.ConfigurationSystem.Client.PathFinder import getDatabaseSection
4233
from DIRAC.ConfigurationSystem.Client.Helpers import CSGlobals
@@ -86,7 +77,7 @@ def getJobParameters(self, jobID, paramList=None):
8677
"""
8778

8879
if paramList:
89-
if isinstance(paramList, six.string_types):
80+
if isinstance(paramList, str):
9081
paramList = paramList.replace(" ", "").split(",")
9182
else:
9283
paramList = []
@@ -193,7 +184,7 @@ def deleteJobParameters(self, jobID, paramList=None):
193184
# }
194185
# }
195186

196-
if isinstance(paramList, six.string_types):
187+
if isinstance(paramList, str):
197188
paramList = paramList.replace(" ", "").split(",")
198189

199190
for param in paramList:

src/DIRAC/WorkloadManagementSystem/DB/JobDB.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,11 @@
1111
* *CompressJDLs*: Enable compression of JDLs when they are stored in the database, default *False*.
1212
1313
"""
14-
15-
from __future__ import print_function
16-
from __future__ import absolute_import
17-
from __future__ import division
18-
19-
import six
2014
import base64
2115
import zlib
2216

2317
import operator
2418

25-
__RCSID__ = "$Id$"
26-
2719
from DIRAC.ConfigurationSystem.Client.Config import gConfig
2820
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getVOForGroup
2921
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
@@ -165,7 +157,7 @@ def getJobParameters(self, jobID, paramList=None):
165157
If parameterList is empty - all the parameters are returned.
166158
"""
167159

168-
if isinstance(jobID, (six.string_types, six.integer_types)):
160+
if isinstance(jobID, (str, int)):
169161
jobID = [jobID]
170162

171163
jobIDList = []
@@ -179,7 +171,7 @@ def getJobParameters(self, jobID, paramList=None):
179171

180172
resultDict = {}
181173
if paramList:
182-
if isinstance(paramList, six.string_types):
174+
if isinstance(paramList, str):
183175
paramList = paramList.split(",")
184176
paramNameList = []
185177
for pn in paramList:
@@ -266,11 +258,11 @@ def getJobsAttributes(self, jobIDs, attrList=None):
266258
# If no list of attributes is given, return all attributes
267259
if not attrList:
268260
attrList = self.jobAttributeNames
269-
if isinstance(attrList, six.string_types):
261+
if isinstance(attrList, str):
270262
attrList = attrList.replace(" ", "").split(",")
271263
attrList.sort()
272264

273-
if isinstance(jobIDs, six.string_types):
265+
if isinstance(jobIDs, str):
274266
jobIDs = [int(jID) for jID in jobIDs.replace(" ", "").split(",")]
275267
if isinstance(jobIDs, int):
276268
jobIDs = [jobIDs]

src/DIRAC/WorkloadManagementSystem/DB/JobLoggingDB.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@
66
deleteJob()
77
getWMSTimeStamps()
88
"""
9-
from __future__ import absolute_import
10-
from __future__ import division
11-
from __future__ import print_function
12-
13-
__RCSID__ = "$Id$"
14-
159
import time
16-
import six
1710

1811
from DIRAC import S_OK, S_ERROR
1912
from DIRAC.Core.Utilities import Time
@@ -66,7 +59,7 @@ def addLoggingRecord(
6659
if not date:
6760
# Make the UTC datetime string and float
6861
_date = Time.dateTime()
69-
elif isinstance(date, six.string_types):
62+
elif isinstance(date, str):
7063
# The date is provided as a string in UTC
7164
_date = Time.fromString(date)
7265
elif isinstance(date, Time._dateTimeType):
@@ -126,9 +119,9 @@ def deleteJob(self, jobID):
126119
return S_OK()
127120

128121
# Make sure that we have a list of strings of jobIDs
129-
if isinstance(jobID, six.integer_types):
122+
if isinstance(jobID, int):
130123
jobList = [str(jobID)]
131-
elif isinstance(jobID, six.string_types):
124+
elif isinstance(jobID, str):
132125
jobList = jobID.replace(" ", "").split(",")
133126
else:
134127
jobList = list(str(j) for j in jobID)

src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
getGroupedPilotSummary()
1818
1919
"""
20-
from __future__ import absolute_import
21-
from __future__ import division
22-
from __future__ import print_function
23-
24-
__RCSID__ = "$Id$"
25-
26-
import six
2720
import threading
2821
import decimal
2922

@@ -242,7 +235,7 @@ def deletePilots(self, pilotIDs, conn=False):
242235
def deletePilot(self, pilotRef, conn=False):
243236
"""Delete Pilot with the given reference from the PilotAgentsDB"""
244237

245-
if isinstance(pilotRef, six.string_types):
238+
if isinstance(pilotRef, str):
246239
pilotID = self.__getPilotID(pilotRef)
247240
else:
248241
pilotID = pilotRef
@@ -432,7 +425,7 @@ def getPilotOutput(self, pilotRef):
432425
def __getPilotID(self, pilotRef):
433426
"""Get Pilot ID for the given pilot reference or a list of references"""
434427

435-
if isinstance(pilotRef, six.string_types):
428+
if isinstance(pilotRef, str):
436429
req = "SELECT PilotID from PilotAgents WHERE PilotJobReference='%s'" % pilotRef
437430
result = self._query(req)
438431
if not result["OK"]:
@@ -1154,7 +1147,7 @@ def getPilotMonitorWeb(self, selectDict, sortList, startItem, maxItems):
11541147
for pilot in pilotList:
11551148
parList = []
11561149
for parameter in paramNames:
1157-
if not isinstance(pilotDict[pilot][parameter], six.integer_types):
1150+
if not isinstance(pilotDict[pilot][parameter], int):
11581151
parList.append(str(pilotDict[pilot][parameter]))
11591152
else:
11601153
parList.append(pilotDict[pilot][parameter])

src/DIRAC/WorkloadManagementSystem/DB/PilotsLoggingDB.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010
deletePilotsLoggin()
1111
1212
"""
13-
from __future__ import absolute_import
14-
from __future__ import division
15-
from __future__ import print_function
16-
17-
__RCSID__ = "$Id$"
18-
19-
20-
import six
2113
from DIRAC import gLogger, gConfig, S_OK, S_ERROR
2214
from DIRAC.Core.Utilities import DErrno
2315
from DIRAC.ConfigurationSystem.Client.Utilities import getDBParameters
@@ -160,7 +152,7 @@ def getPilotsLogging(self, pilotUUID):
160152
def deletePilotsLogging(self, pilotUUID):
161153
"""Delete all logging entries for pilot"""
162154

163-
if isinstance(pilotUUID, six.string_types):
155+
if isinstance(pilotUUID, str):
164156
pilotUUID = [
165157
pilotUUID,
166158
]

src/DIRAC/WorkloadManagementSystem/DB/TaskQueueDB.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
""" TaskQueueDB class is a front-end to the task queues db
22
"""
3-
from __future__ import absolute_import
4-
from __future__ import division
5-
from __future__ import print_function
6-
7-
__RCSID__ = "$Id"
8-
9-
import six
103
import random
114
import string
125

@@ -182,10 +175,10 @@ def _checkTaskQueueDefinition(self, tqDefDict):
182175
if field not in tqDefDict:
183176
return S_ERROR("Missing mandatory field '%s' in task queue definition" % field)
184177
if field in ["CPUTime"]:
185-
if not isinstance(tqDefDict[field], six.integer_types):
178+
if not isinstance(tqDefDict[field], int):
186179
return S_ERROR("Mandatory field %s value type is not valid: %s" % (field, type(tqDefDict[field])))
187180
else:
188-
if not isinstance(tqDefDict[field], six.string_types):
181+
if not isinstance(tqDefDict[field], str):
189182
return S_ERROR("Mandatory field %s value type is not valid: %s" % (field, type(tqDefDict[field])))
190183
result = self._escapeString(tqDefDict[field])
191184
if not result["OK"]:
@@ -230,9 +223,9 @@ def travelAndCheckType(value, validTypes, escapeValues=True):
230223
continue
231224
fieldValue = tqMatchDict[field]
232225
if field in ["CPUTime"]:
233-
result = travelAndCheckType(fieldValue, six.integer_types, escapeValues=False)
226+
result = travelAndCheckType(fieldValue, int, escapeValues=False)
234227
else:
235-
result = travelAndCheckType(fieldValue, six.string_types)
228+
result = travelAndCheckType(fieldValue, str)
236229
if not result["OK"]:
237230
return S_ERROR("Match definition field %s failed : %s" % (field, result["Message"]))
238231
tqMatchDict[field] = result["Value"]
@@ -241,7 +234,7 @@ def travelAndCheckType(value, validTypes, escapeValues=True):
241234
for field in (multiField, "Banned%s" % multiField, "Required%s" % multiField):
242235
if field in tqMatchDict:
243236
fieldValue = tqMatchDict[field]
244-
result = travelAndCheckType(fieldValue, six.string_types)
237+
result = travelAndCheckType(fieldValue, str)
245238
if not result["OK"]:
246239
return S_ERROR("Match definition field %s failed : %s" % (field, result["Message"]))
247240
tqMatchDict[field] = result["Value"]

0 commit comments

Comments
 (0)