Skip to content

Commit dda883a

Browse files
committed
fix: py2 -> py3 fixes for FrameworkSystem DB modules
1 parent 6f0219a commit dda883a

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

src/DIRAC/FrameworkSystem/DB/ComponentMonitoringDB.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
""" ComponentMonitoring class is a front-end to the Component monitoring Database
22
"""
3-
import six
43
from urllib import parse
54

65
from DIRAC import gConfig, S_OK, S_ERROR
@@ -95,7 +94,7 @@ def __datetime2str(self, dt):
9594
"""
9695
This method converts the datetime type to a string type.
9796
"""
98-
if isinstance(dt, six.string_types):
97+
if isinstance(dt, str):
9998
return dt
10099
return "%s-%s-%s %s:%s:%s" % (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
101100

@@ -249,9 +248,9 @@ def __getComponents(self, condDict):
249248
sqlWhere = []
250249
for field in condDict:
251250
val = condDict[field]
252-
if isinstance(val, six.string_types):
251+
if isinstance(val, str):
253252
sqlWhere.append("%s='%s'" % (field, val))
254-
elif isinstance(val, six.integer_types + (float,)):
253+
elif isinstance(val, (int, float)):
255254
sqlWhere.append("%s='%s'" % (field, val))
256255
else:
257256
sqlWhere.append("( %s )" % " OR ".join(["%s='%s'" % (field, v) for v in val]))

src/DIRAC/FrameworkSystem/DB/InstalledComponentsDB.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
Classes and functions for easier management of the InstalledComponents database
33
"""
4-
import six
54
import re
65
import datetime
76
from sqlalchemy import MetaData, Column, Integer, String, DateTime, create_engine, text
@@ -416,7 +415,7 @@ def __filterFields(self, session, table, matchFields=None):
416415
toAppend = element
417416
if isinstance(toAppend, datetime.datetime):
418417
toAppend = toAppend.strftime("%Y-%m-%d %H:%M:%S")
419-
if isinstance(toAppend, six.string_types):
418+
if isinstance(toAppend, str):
420419
toAppend = "'%s'" % (toAppend)
421420
if i == 0:
422421
sql = "%s%s" % (sql, toAppend)
@@ -425,7 +424,7 @@ def __filterFields(self, session, table, matchFields=None):
425424
sql = "%s )" % (sql)
426425
else:
427426
continue
428-
elif isinstance(matchFields[key], six.string_types):
427+
elif isinstance(matchFields[key], str):
429428
sql = "`%s` %s '%s'" % (actualKey, comparison, matchFields[key])
430429
elif isinstance(matchFields[key], datetime.datetime):
431430
sql = "%s %s '%s'" % (actualKey, comparison, matchFields[key].strftime("%Y-%m-%d %H:%M:%S"))

src/DIRAC/FrameworkSystem/DB/UserProfileDB.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
""" UserProfileDB class is a front-end to the User Profile Database
22
"""
33

4-
import six
5-
64
import cachetools
75

86
from DIRAC import S_OK, S_ERROR
@@ -498,7 +496,7 @@ def deleteVar(self, userName, userGroup, profileName, varName):
498496
return self.deleteVarByUserId(userIds, profileName, varName)
499497

500498
def __profilesCondGenerator(self, value, varType, initialValue=False):
501-
if isinstance(value, six.string_types):
499+
if isinstance(value, str):
502500
value = [value]
503501
ids = []
504502
if initialValue:

src/DIRAC/ProductionSystem/DB/ProductionDB.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
in order to automate the task of transformation preparation for high level productions.
55
"""
66
# # imports
7-
import six
87
import json
98
import threading
109

@@ -149,7 +148,7 @@ def getProductions(
149148
# TODO: remove, as Description should have been converted to a text type
150149
row = [item.decode() if isinstance(item, bytes) else item for item in row]
151150
# Prepare the structure for the web
152-
rList = [str(item) if not isinstance(item, six.integer_types) else item for item in row]
151+
rList = [str(item) if not isinstance(item, int) else item for item in row]
153152
prodDict = dict(zip(self.PRODPARAMS, row))
154153
webList.append(rList)
155154
resultList.append(prodDict)
@@ -181,7 +180,7 @@ def getProductionParameters(self, prodName, parameters, connection=False):
181180
:param str prodName: the Production name or ID
182181
:param str parameters: any valid production parameter in self.PRODPARAMS
183182
"""
184-
if isinstance(parameters, six.string_types):
183+
if isinstance(parameters, str):
185184
parameters = [parameters]
186185
res = self.getProduction(prodName, connection=connection)
187186
if not res["OK"]:
@@ -319,7 +318,7 @@ def getProductionTransformations(
319318
resultList = []
320319
for row in res["Value"]:
321320
# Prepare the structure for the web
322-
rList = [str(item) if not isinstance(item, six.integer_types) else item for item in row]
321+
rList = [str(item) if not isinstance(item, int) else item for item in row]
323322
transDict = dict(zip(self.TRANSPARAMS, row))
324323
webList.append(rList)
325324
resultList.append(transDict)
@@ -619,7 +618,7 @@ def _getProductionID(self, prodName, connection=False):
619618
prodName = int(prodName)
620619
cmd = "SELECT ProductionID from Productions WHERE ProductionID=%d;" % prodName
621620
except Exception:
622-
if not isinstance(prodName, six.string_types):
621+
if not isinstance(prodName, str):
623622
return S_ERROR("Production should be ID or name")
624623
cmd = "SELECT ProductionID from Productions WHERE ProductionName='%s';" % prodName
625624
res = self._query(cmd, connection)

0 commit comments

Comments
 (0)