Exemple #1
0
 def __getData(self,name=False):
   gLogger.info("__getData(%s) function" % name)
   upc = UserProfileClient( USER_PROFILE_NAME, getRPCClient )
   gLogger.info("upc.retrieveAllVars()")
   result = upc.retrieveAllVars()
   gLogger.debug(result)
   if not result["OK"]:
     if result['Message'].find("No data for") != -1:
       return {"success":"true","result":{}}
     return {"success":"false","error":result["Message"]}
   callback = dict()
   callback["layouts"] = result["Value"]
   keys = result["Value"].keys()
   callback["layoutNames"] = ";".join(keys)
   if not name:
     last = self.__lastHistory()
     if not last["OK"]:
       last = ""
     else:
       last = last["Value"]
   else:
     last = name
   callback["defaultLayout"] = last
   if name:
     result = self.__setHistory(name)
     if not result["OK"]:
       gLogger.error(result["Message"])
   return {"success":"true","result":callback}
 def all(self):
     result = list()
     for i in [USER_PROFILE_NAME, "Default"]:
         upc = UserProfileClient(i, getRPCClient)
         allvar = upc.retrieveAllVars()
         result.append(allvar)
     return result
 def __getUserLayout(self):
     gLogger.info("Running getUserLayout()")
     msg = "getUserLayout() for %s@%s" % (getUsername(), getSelectedGroup())
     upc = UserProfileClient(USER_PROFILE_NAME, getRPCClient)
     result = upc.retrieveAllVars()
     gLogger.debug(result)
     if not result["OK"]:
         gLogger.error("Result %s: %s" % (msg, result["Message"]))
         return {"success": "false", "error": result["Message"]}
     layouts = result["Value"]
     data = list()
     for name, value in layouts.items():
         result = self.__getPermissions(name)
         if not result["OK"]:
             perm = result["Message"]
         else:
             perm = result["Value"]
             if perm.has_key("ReadAccess"):
                 perm = perm["ReadAccess"]
             else:
                 perm = "Undefined"
         if value.has_key("group"):
             group = value["group"]
         else:
             group = "Undefined"
         perm = perm.capitalize()
         data.append({"name": name, "permission": perm, "group": group})
     gLogger.info("Result %s: %s" % (msg, data))
     return {"success": "true", "result": data}
Exemple #4
0
 def all(self):
   result = list()
   for i in [ USER_PROFILE_NAME , "Default" ]:
     upc = UserProfileClient( i , getRPCClient )
     allvar = upc.retrieveAllVars() 
     result.append( allvar )
   return result
Exemple #5
0
 def __getUserLayout( self ) :
   gLogger.info( "Running getUserLayout()" )
   msg = "getUserLayout() for %s@%s" % ( getUsername() , getSelectedGroup() )
   upc = UserProfileClient( USER_PROFILE_NAME, getRPCClient )
   result = upc.retrieveAllVars()
   gLogger.debug( result )
   if not result[ "OK" ]:
     gLogger.error( "Result %s: %s" % ( msg , result[ "Message" ] ) )
     return { "success" : "false" , "error" : result[ "Message" ] }
   layouts = result[ "Value" ]
   data = list()
   for name , value in layouts.items():
     result = self.__getPermissions( name )
     if not result[ "OK" ]:
       perm = result[ "Message" ]
     else:
       perm = result[ "Value" ]
       if perm.has_key( "ReadAccess" ):
         perm = perm[ "ReadAccess" ]
       else:
         perm = "Undefined"
     if value.has_key( "group" ):
       group = value[ "group" ]
     else:
       group = "Undefined"
     data.append( { "name" : name , "permission" : perm , "group" : group } )
   gLogger.info( "Result %s: %s" % ( msg , data ) )
   return { "success" : "true" , "result" : data }
 def kaboom(self):
     uList = [str(getUsername())]
     result = list()
     for i in [USER_PROFILE_NAME, "Default"]:
         upc = UserProfileClient(i, getRPCClient)
         tmp = upc.deleteProfiles(uList)
         allvar = upc.retrieveAllVars()
         result.append(allvar)
     return result
Exemple #7
0
 def kaboom(self):
   uList = [ str( getUsername() ) ]
   result = list()
   for i in [ USER_PROFILE_NAME , "Default" ]:
     upc = UserProfileClient( i , getRPCClient )
     tmp = upc.deleteProfiles( uList )
     allvar = upc.retrieveAllVars() 
     result.append( allvar )
   return result
Exemple #8
0
 def __getAtomicData(self,name=False):
   gLogger.info("__getAtomicData(%s) function" % name)
   upc = UserProfileClient( USER_PROFILE_NAME, getRPCClient )
   if not name:
     gLogger.info("upc.retrieveAllVars()")
     result = upc.retrieveAllVars()
   else:
     gLogger.info("upc.retrieveVar(%s)" % name)
     result = upc.retrieveVar(name)
   gLogger.debug(result)
   if not result["OK"]:
     if result['Message'].find("No data for") != -1:
       return {"success":"true","result":{}}
     return {"success":"false","error":result["Message"]}
   result = result["Value"]
   return {"success":"true","result":result}
 def __convert(self):
     gLogger.info("Running convert()")
     msg = "convert() for %s@%s" % (getUsername(), getSelectedGroup())
     upc = UserProfileClient("Summary", getRPCClient)
     result = upc.retrieveAllVars()
     gLogger.info(result)
     if not result["OK"]:
         if result["Message"].find("No data") < 0:
             gLogger.error("Result %s: %s" % (msg, result["Message"]))
             return S_ERROR(result["Message"])
         result = "No data found, nothing to convert"
         gLogger.info("Result %s: %s" % (msg, result))
         return S_OK(result)
     result = result["Value"]
     if not result.has_key("Bookmarks"):
         result = "No old Bookmarks found"
         gLogger.info("Result %s: %s" % (msg, result))
         return S_OK(result)
     data = result["Bookmarks"]
     try:
         layouts = dict(data)
     except:
         result = "Layouts '%s' is not dictionary, can't convert" % layouts
         gLogger.info("Result %s: %s" % (msg, result))
         return S_OK(result)
     err = list()
     done = list()
     gLogger.info("Saving old data to new place")
     upcnew = UserProfileClient(USER_PROFILE_NAME, getRPCClient)
     permissions = "USER"
     user = str(getUsername())
     group = str(getSelectedGroup())
     for i in layouts:
         data = dict()
         data["url"] = layouts[i]["url"]
         data["columns"] = layouts[i]["columns"]
         data["refresh"] = layouts[i]["refresh"]
         result = upcnew.storeVar(i, data, permissions)
         gLogger.debug(result)
         if not result["OK"]:
             err.append(result["Message"])
             continue
         done.append(result["Value"])
         result = upc.deleteVar(i)
         if not result["OK"]:
             gLogger.error("Result %s: %s" % (msg, result["Message"]))
             err.append(result["Message"])
         continue
     gLogger.info("Is something left?")
     result = upc.retrieveAllVars()
     gLogger.info(result)
     if result["OK"] and len(result["Value"]) > 0:
         text = "Some data has left at old place. Please remove them manually"
         gLogger.info("Result %s: %s" % (msg, text))
     if not result["OK"]:
         if result["Message"].find("No data") < 0:
             gLogger.error("Result %s: %s" % (msg, result["Message"]))
             return S_ERROR(result["Message"])
     gLogger.info("Looks like old data are erased")
     if len(err) == 0 and len(done) == 0:
         good = "Some magic has happens. Neither errors nor succesfull results"
         good = good + " Perhaps there is no old profile to convert"
         gLogger.info("Result %s: %s" % (msg, good))
         return S_OK(good)
     if len(err) > 0 and len(done) == 0:
         error = "No succesfull results, only errors:\n"
         tmp = "\n".join(err)
         error = error + tmp
         gLogger.error("Result %s: %s" % (msg, error))
         return S_ERROR(error)
     if len(err) > 0 and len(done) > 0:
         good = "Conversion has finished partially sucessfull"
         if len(err) > 0:
             good = good + ". There are some errors though\n"
         else:
             good = good + ". There is an error though\n"
         error = "\n".join(err)
         good = good + error
         gLogger.info("Result %s: %s" % (msg, good))
         return S_OK(good)
     if len(err) == 0 and len(done) > 0:
         good = "Conversion has finished sucessfully"
         gLogger.info("Result %s: %s" % (msg, good))
         return S_OK(good)
Exemple #10
0
 def __convert(self):
   gLogger.info("Running convert()")
   msg = "convert() for %s@%s" % ( getUsername() , getSelectedGroup() )
   upc = UserProfileClient( "Summary", getRPCClient )
   result = upc.retrieveAllVars()
   gLogger.info( result )
   if not result["OK"]:
     if result[ "Message" ].find( "No data" ) < 0 :
       gLogger.error( "Result %s: %s" % ( msg , result[ "Message" ] ) )
       return S_ERROR( result[ "Message" ] )
     result = "No data found, nothing to convert"
     gLogger.info( "Result %s: %s" % ( msg , result ) )
     return S_OK( result )
   result = result[ "Value" ]
   if not result.has_key( "Bookmarks" ):
     result = "No old Bookmarks found"
     gLogger.info( "Result %s: %s" % ( msg , result ) )
     return S_OK( result )
   data = result[ "Bookmarks" ]
   try:
     layouts = dict( data )
   except:
     result = "Layouts '%s' is not dictionary, can't convert" % layouts
     gLogger.info( "Result %s: %s" % ( msg , result ) )
     return S_OK( result )
   err = list()
   done = list()
   gLogger.info( "Saving old data to new place" )
   upcnew = UserProfileClient( USER_PROFILE_NAME, getRPCClient )
   permissions = "USER"
   user = str( getUsername() )
   group = str( getSelectedGroup() )
   for i in layouts:
     data = dict()
     data[ "url" ] = layouts[ i ][ "url" ]
     data[ "columns" ] = layouts[ i ][ "columns" ]
     data[ "refresh" ] = layouts[ i ][ "refresh" ]
     result = upcnew.storeVar( i , data , permissions )
     gLogger.debug( result )
     if not result[ "OK" ]:
       err.append( result[ "Message" ] )
       continue
     done.append( result[ "Value" ] )
     result = upc.deleteVar( i )
     if not result["OK"]:
       gLogger.error( "Result %s: %s" % ( msg , result[ "Message" ] ) )
       err.append( result["Message"] )
     continue
   gLogger.info( "Is something left?" )
   result = upc.retrieveAllVars()
   gLogger.info( result )
   if result[ "OK" ] and len( result[ "Value" ] ) > 0:
     text = "Some data has left at old place. Please remove them manually"
     gLogger.info( "Result %s: %s" % ( msg , text ) )
   if not result["OK"]:
     if result[ "Message" ].find( "No data" ) < 0 :
       gLogger.error( "Result %s: %s" % ( msg , result[ "Message" ] ) )
       return S_ERROR( result[ "Message" ] )
   gLogger.info( "Looks like old data are erased" )
   if len( err ) == 0 and len( done ) == 0:
     good = "Some magic has happens. Neither errors nor succesfull results"
     good = good + " Perhaps there is no old profile to convert"
     gLogger.info( "Result %s: %s" % ( msg , good ) )
     return S_OK( good )
   if len( err ) > 0 and len( done ) == 0:
     error = "No succesfull results, only errors:\n"
     tmp = "\n".join( err )
     error = error + tmp
     gLogger.error( "Result %s: %s" % ( msg , error ) )
     return S_ERROR( error )
   if len( err ) > 0 and len( done ) > 0:
     good = "Conversion has finished partially sucessfull"
     if len( err ) > 0:
       good = good + ". There are some errors though\n"
     else:
       good = good + ". There is an error though\n"
     error = "\n".join( err )
     good = good + error
     gLogger.info( "Result %s: %s" % ( msg , good ) )
     return S_OK( good )
   if len( err ) == 0 and len( done ) > 0:
     good = "Conversion has finished sucessfully"
     gLogger.info( "Result %s: %s" % ( msg , good ) )
     return S_OK( good )