1
1
""" UserProfileDB class is a front-end to the User Profile Database
2
2
"""
3
3
4
- import six
5
-
6
4
import cachetools
7
5
8
6
from DIRAC import S_OK , S_ERROR
@@ -51,7 +49,7 @@ class UserProfileDB(DB):
51
49
"VOId" : "INTEGER" ,
52
50
"Profile" : "VARCHAR(255) NOT NULL" ,
53
51
"VarName" : "VARCHAR(255) NOT NULL" ,
54
- "Data" : "BLOB " ,
52
+ "Data" : "TEXT " ,
55
53
"ReadAccess" : 'VARCHAR(10) DEFAULT "USER"' ,
56
54
"PublishAccess" : 'VARCHAR(10) DEFAULT "USER"' ,
57
55
},
@@ -260,7 +258,8 @@ def retrieveVarById(self, userIds, ownerIds, profileName, varName):
260
258
return result
261
259
data = result ["Value" ]
262
260
if len (data ) > 0 :
263
- return S_OK (data [0 ][0 ].decode ())
261
+ # TODO: The decode is only needed in DIRAC v8.0.x while moving from BLOB -> TEXT
262
+ return S_OK (data [0 ][0 ].decode () if isinstance (data [0 ][0 ], bytes ) else data [0 ][0 ])
264
263
return S_ERROR ("No data for userIds %s profileName %s varName %s" % (userIds , profileName , varName ))
265
264
266
265
def retrieveAllUserVarsById (self , userIds , profileName ):
@@ -278,7 +277,12 @@ def retrieveAllUserVarsById(self, userIds, profileName):
278
277
if not result ["OK" ]:
279
278
return result
280
279
data = result ["Value" ]
281
- return S_OK ({k : v .decode () for k , v in data })
280
+ try :
281
+ # TODO: This is only needed in DIRAC v8.0.x while moving from BLOB -> TEXT
282
+ allUserDataDict = {k : v .decode () for k , v in data }
283
+ except AttributeError :
284
+ allUserDataDict = {k : v for k , v in data }
285
+ return S_OK (allUserDataDict )
282
286
283
287
def retrieveUserProfilesById (self , userIds ):
284
288
"""
@@ -289,12 +293,15 @@ def retrieveUserProfilesById(self, userIds):
289
293
result = self ._query (selectSQL )
290
294
if not result ["OK" ]:
291
295
return result
292
- data = result ["Value" ]
293
296
dataDict = {}
294
- for profile , varName , data in data :
297
+ for profile , varName , data in result [ "Value" ] :
295
298
if profile not in dataDict :
296
299
dataDict [profile ] = {}
297
- dataDict [profile ][varName ] = data .decode ()
300
+ try :
301
+ # TODO: This is only needed in DIRAC v8.0.x while moving from BLOB -> TEXT
302
+ dataDict [profile ][varName ] = data .decode ()
303
+ except AttributeError :
304
+ dataDict [profile ][varName ] = data
298
305
return S_OK (dataDict )
299
306
300
307
def retrieveVarPermsById (self , userIds , ownerIds , profileName , varName ):
@@ -489,7 +496,7 @@ def deleteVar(self, userName, userGroup, profileName, varName):
489
496
return self .deleteVarByUserId (userIds , profileName , varName )
490
497
491
498
def __profilesCondGenerator (self , value , varType , initialValue = False ):
492
- if isinstance (value , six . string_types ):
499
+ if isinstance (value , str ):
493
500
value = [value ]
494
501
ids = []
495
502
if initialValue :
0 commit comments