Пример #1
0
 def __delData(self,name=False):
   gLogger.info("__delData(%s) function" % name)
   if not name:
     return {"success":"false","error":"Name of the layout is absent"}
   upc = UserProfileClient( USER_PROFILE_NAME, getRPCClient )
   gLogger.info("upc.deleteVar(%s)" % name)
   result = upc.deleteVar(name)
   gLogger.debug(result)
   if not result["OK"]:
     return {"success":"false","error":result["Message"]}
   result = self.__delHistory(name)
   if not result["OK"]:
     gLogger.error(result["Message"])
   return self.__getData()    
Пример #2
0
 def __deleteLayout(self):
     gLogger.info("Running deleteLayout()")
     msg = "delLayout() for %s@%s" % (getUsername(), getSelectedGroup())
     result = self.__params2string(DELETE_LAYOUT_ARGS)
     if not result["OK"]:
         gLogger.error("Result %s: %s" % (msg, result["Message"]))
         return {"success": "false", "error": result["Message"]}
     args = result["Value"]
     name = args["name"]
     history = dict()
     for i in ["Save", "Load"]:
         result = self.__deleteHistory(name, i)
         if not result["OK"]:
             history[i] = result["Message"]
         else:
             history[i] = result["Value"]
     upc = UserProfileClient(USER_PROFILE_NAME, getRPCClient)
     result = upc.deleteVar(name)
     gLogger.debug(result)
     if not result["OK"]:
         gLogger.error("Result %s: %s" % (msg, result["Message"]))
         return {"success": "false", "error": result["Message"]}
     gLogger.info("Result %s: %s AND %s" % (msg, "true", history))
     return {"success": "true", "result": "true", "history": history}
Пример #3
0
 def __deleteLayout( self ):
   gLogger.info( "Running deleteLayout()" )
   msg = "delLayout() for %s@%s" % ( getUsername() , getSelectedGroup() )
   result = self.__params2string( DELETE_LAYOUT_ARGS )
   if not result[ "OK" ]:
     gLogger.error( "Result %s: %s" % ( msg , result[ "Message" ] ) )
     return { "success" : "false" , "error" : result[ "Message" ] }
   args = result[ "Value" ]
   name = args[ "name" ]
   history = dict()
   for i in [ "Save" , "Load" ]:
     result = self.__deleteHistory( name , i )
     if not result[ "OK" ]:
       history[ i ] = result[ "Message" ]
     else:
       history[ i ] = result[ "Value" ]
   upc = UserProfileClient( USER_PROFILE_NAME, getRPCClient )
   result = upc.deleteVar( name )
   gLogger.debug( result )
   if not result[ "OK" ]:
     gLogger.error( "Result %s: %s" % ( msg , result[ "Message" ] ) )
     return { "success" : "false" , "error" : result[ "Message" ] }
   gLogger.info( "Result %s: %s AND %s" % ( msg , "true" , history ) )
   return { "success" : "true" , "result" : "true" , "history" : history }
Пример #4
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)
Пример #5
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 )