Exemplo n.º 1
0
 def __delBookmarks(self,name):
   if name == "columns" or name == "refresh" or name == "defaultLayout" or name == "layouts":
     return {"success":"false","error":"The name \"" + name + "\" is reserved, please choose another name. Operation failed"}
   upc = UserProfileClient( "Summary", getRPCClient )
   result = upc.retrieveVar( "Bookmarks" )
   if result["OK"]:
     data = result["Value"]
   else:
     data = {}
   gLogger.info("\033[0;31m data: \033[0m",data)
   if data.has_key("layouts"):
     if name in data["layouts"]:
       del data["layouts"][name]
     else:
       return {"success":"false","error":"Can't delete not existing layout: \"" + name + "\""}
   else:
     return {"success":"false","error":"Can't read existing layouts, operation failed"}
   if len(data["layouts"]) > 0:
     data["defaultLayout"] = data["layouts"].keys()[0]
   else:
     data["defaultLayout"] = ""
   gLogger.info("\033[0;31m data: \033[0m",data)
   result = upc.storeVar( "Bookmarks", data )
   gLogger.info("\033[0;31m result: \033[0m",result)
   if result["OK"]:
     return self.__getBookmarks()
   else:
     return {"success":"false","error":result["Message"]}
Exemplo n.º 2
0
 def __getBookmarks(self,name=""):
   if name == "columns" or name == "refresh" or name == "defaultLayout" or name == "layouts":
     return {"success":"false","error":"The name \"" + name + "\" is reserved, operation failed"}
   upc = UserProfileClient( "Summary", getRPCClient )
   result = upc.retrieveVar( "Bookmarks" )
   gLogger.info("\033[0;31m UserProfile getBookmarks response: \033[0m",result)
   if result["OK"]:
     result = result["Value"]
     if name != "":
       result["defaultLayout"] = name
       save = upc.storeVar( "Bookmarks", result )
       gLogger.info("\033[0;31m saving new default layout \033[0m",name)
       if not save["OK"]:
         return {"success":"false","error":save["Message"]}
     elif name == "" and not result.has_key("defaultLayout"):
       result["defaultLayout"] = ""
     if result.has_key("layouts"):
       layouts = ""
       for i in result["layouts"]:
         layouts = layouts + str(i) + ";"
       result["layoutNames"] = layouts
     c.result = {"success":"true","result":result}
   else:
     if result['Message'].find("No data for") != -1:
       c.result = {"success":"true","result":{}}
     else:
       c.result = {"success":"false","error":result["Message"]}
   return c.result
Exemplo n.º 3
0
 def __setBookmarks(self,name):
   if name == "columns" or name == "refresh" or name == "defaultLayout" or name == "layouts":
     return {"success":"false","error":"The name \"" + name + "\" is reserved, operation failed"}
   if not request.params.has_key("columns") and len(request.params["columns"]) <= 0:
     return {"success":"false","error":"Parameter 'Columns' is absent"}
   if not request.params.has_key("refresh") and len(request.params["refresh"]) <= 0:
     return {"success":"false","error":"Parameter 'Refresh' is absent"}
   upc = UserProfileClient( "Summary", getRPCClient )
   result = upc.retrieveVar( "Bookmarks" )
   if result["OK"]:
     data = result["Value"]
   else:
     data = {}
   data["defaultLayout"] = name
   if not data.has_key("layouts"):
     data["layouts"] =  {}
   data["layouts"][name] = {}
   if request.params.has_key("plots") and len(request.params["plots"]) > 0:
     data["layouts"][name]["url"] = str(request.params["plots"])
   else:
     data["layouts"][name]["url"] = ""
   data["layouts"][name]["columns"] = str(request.params["columns"])
   data["layouts"][name]["refresh"] = str(request.params["refresh"])
   gLogger.info("\033[0;31m Data to save: \033[0m",data)
   result = upc.storeVar( "Bookmarks", data )
   gLogger.info("\033[0;31m UserProfile response: \033[0m",result)
   if result["OK"]:
     return self.__getBookmarks()
   else:
     return {"success":"false","error":result["Message"]}
Exemplo n.º 4
0
 def __setHistory(self,name=False):
   gLogger.info("__setHistory(%s) function" % name)
   if not name:
     return S_ERROR( "Name of the layout to save in history is absent" )
   upc = UserProfileClient( "Default", getRPCClient )
   profile_name = USER_PROFILE_NAME + ".History"
   gLogger.info("upc.retrieveVar(%s)" % profile_name)
   result = upc.retrieveVar(profile_name)
   gLogger.debug(result)
   if not result["OK"]:
     result = dict()
     result["Value"] = dict()
   data = result["Value"]
   try:
     data = list(data)
   except:
     data = list()
   data.append(name)
   while len(data) > 50:
     data.popleft()
   gLogger.info("upc.storeVar(%s,%s)" % (profile_name,data))      
   result = upc.storeVar(profile_name,data)
   gLogger.debug(result)
   if not result["OK"]:
     return S_ERROR( result["Message"] )
   return S_OK( result["Value"] )
Exemplo n.º 5
0
 def __getBookmarks(self):
     """returns the bookkmarks"""
     self.getWidget().waitCursor()
     upc = UserProfileClient("Bookkeeping", RPCClient)
     bookmarks = upc.retrieveVar("Bookmarks")
     self.getWidget().arrowCursor()
     return bookmarks
Exemplo n.º 6
0
 def __getHistory( self , state ):
   """
   Just get the history based on state
   Return resulting list
   "state" can be either "Save" or "Load"
   """
   gLogger.info( "Running getHistory( %s )" % state )
   msg = "getHistory() for %s@%s" % ( getUsername() , getSelectedGroup() )
   opt = "/Website/" + USER_PROFILE_NAME + "/ShowHistory"
   history_length = gConfig.getOptions( opt , 5 )
   upc = UserProfileClient( "Default" , getRPCClient )
   group = str( getSelectedGroup() )
   profile_name = USER_PROFILE_NAME + ".History." + state + "." + group
   result = upc.retrieveVar( profile_name )
   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" ] )
     history = list()
   else:
     history = result[ "Value" ]
   if not isinstance( history , list ):
     err = "List expected at: %s" % profile_name
     gLogger.error( "Result %s: %s" % ( msg , err ) )
     return S_ERROR( err )
   if( len( history ) > history_length ):
     history = result[ history_length ]
   gLogger.info( "Result %s: %s" % ( msg , history ) )
   return S_OK( history )
Exemplo n.º 7
0
 def __getHistory(self, state):
     """
 Just get the history based on state
 Return resulting list
 "state" can be either "Save" or "Load"
 """
     gLogger.info("Running getHistory( %s )" % state)
     msg = "getHistory() for %s@%s" % (getUsername(), getSelectedGroup())
     opt = "/Website/" + USER_PROFILE_NAME + "/ShowHistory"
     history_length = gConfig.getOptions(opt, 5)
     upc = UserProfileClient("Default", getRPCClient)
     group = str(getSelectedGroup())
     profile_name = USER_PROFILE_NAME + ".History." + state + "." + group
     result = upc.retrieveVar(profile_name)
     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"])
         history = list()
     else:
         history = result["Value"]
     if not isinstance(history, list):
         err = "List expected at: %s" % profile_name
         gLogger.error("Result %s: %s" % (msg, err))
         return S_ERROR(err)
     if (len(history) > history_length):
         history = result[history_length]
     gLogger.info("Result %s: %s" % (msg, history))
     return S_OK(history)
Exemplo n.º 8
0
 def __getBookmarks(self, name=""):
     if name == "columns" or name == "refresh" or name == "defaultLayout" or name == "layouts":
         return {
             "success": "false",
             "error":
             "The name \"" + name + "\" is reserved, operation failed"
         }
     upc = UserProfileClient("Summary", getRPCClient)
     result = upc.retrieveVar("Bookmarks")
     gLogger.info("\033[0;31m UserProfile getBookmarks response: \033[0m",
                  result)
     if result["OK"]:
         result = result["Value"]
         if name != "":
             result["defaultLayout"] = name
             save = upc.storeVar("Bookmarks", result)
             gLogger.info("\033[0;31m saving new default layout \033[0m",
                          name)
             if not save["OK"]:
                 return {"success": "false", "error": save["Message"]}
         elif name == "" and not result.has_key("defaultLayout"):
             result["defaultLayout"] = ""
         if result.has_key("layouts"):
             layouts = ""
             for i in result["layouts"]:
                 layouts = layouts + str(i) + ";"
             result["layoutNames"] = layouts
         c.result = {"success": "true", "result": result}
     else:
         if result['Message'].find("No data for") != -1:
             c.result = {"success": "true", "result": {}}
         else:
             c.result = {"success": "false", "error": result["Message"]}
     return c.result
Exemplo n.º 9
0
 def __delHistory(self,name=False):
   gLogger.info("__delHistory(%s) function" % name)
   upc = UserProfileClient( "Default", getRPCClient )
   profile_name = USER_PROFILE_NAME + ".History"
   gLogger.info("upc.retrieveVar(%s)" % profile_name)
   result = upc.retrieveVar(profile_name)
   gLogger.debug(result)
   if not result["OK"]:
     return S_ERROR( result["Message"] )
   data = result["Value"]
   try:
     data = list(data)
   except:
     return S_ERROR( "Failed to convert '%s' to list" % data )
   if name:
     if data.count(name) > 0:
       while data.count(name) > 0:
         data.remove(name)
   else:
     data = list()
   while len(data) > 50:
     data.popleft()
   gLogger.info("upc.storeVar(%s,%s)" % (profile_name,data))
   result = upc.storeVar(profile_name,data)
   gLogger.debug(result)
   if not result["OK"]:
     return S_ERROR( result["Message"] )
   return S_OK( result["Value"] )
Exemplo n.º 10
0
    def isRequested(self, dn):
        """
    Checks if the email already saved as registration request key or not
    Return True or False
    """

        upc = UserProfileClient(REG_PROFILE_NAME, getRPCClient)
        return upc.retrieveVar(dn)
Exemplo n.º 11
0
  def isRequested( self , dn ):

    """
    Checks if the email already saved as registration request key or not
    Return True or False
    """
    
    upc = UserProfileClient( REG_PROFILE_NAME , getRPCClient )
    return upc.retrieveVar( dn )
Exemplo n.º 12
0
    def display(self):
        checkUserCredentials()
        dn = getUserDN()
        user = getUsername()
        group = getSelectedGroup()
        gLogger.always("User: %s, Group: %s, DN: %s" % (user, group, dn))
        templates = ["reg_%s.mako" % i for i in ["done", "form", "info"]]
        html = [
            "reg_%s.html" % i
            for i in ["footer", "header", "conditions", "form", "done"]
        ]
        files = templates + html
        basedir = os.path.join(rootPath, "Web", "dirac", "templates")
        for i in files:
            f = os.path.join(basedir, i)
            if not os.path.exists(f):
                gLogger.error("File does not exists: %s" % f)
                return render("web/External.mako")
        if dn and user == "anonymous":
            upc = UserProfileClient("Registration", getRPCClient)
            result = upc.retrieveVar(dn)
            if result["OK"]:
                c.sent = result["Value"]
                return render("/reg_done.mako")
            else:
                return render("/reg_form.mako")
        if not dn or dn == "":
            return render("/reg_info.mako")

        if "site" not in request.params:
            c.select = gConfig.getValue("/Website/DefaultExternalURL",
                                        "http://diracgrid.org")
            return render("web/External.mako")

        # No idea what this code should do...
        if request.params.has_key("site") and len(request.params["site"]) > 0:
            if str(request.params["site"]) != "All":
                c.select = str(request.params["site"])
                gLogger.debug("Request's body:")
                for key in request.params.keys():
                    if not key == "site" and len(request.params[key]) > 0:
                        c.select = c.select + "&" + key + "=" + request.params[
                            key]
                        try:
                            gLogger.debug("%s - %s" %
                                          (key, request.params[key]))
                        except Exception, x:
                            gLogger.error("Exception: %s" % str(x))
                            pass
Exemplo n.º 13
0
  def alreadyRequested( self , email = False ):

    """
    Checks if the email already saved as registration request key or not
    Return True or False
    """
    
    if not email:
      return True
    upc = UserProfileClient( REG_PROFILE_NAME , getRPCClient )
    result = upc.retrieveVar( email )
    gLogger.info( result )
    if result[ "OK" ]:
      return True
    return False
Exemplo n.º 14
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}
Exemplo n.º 15
0
 def __lastHistory(self):
   gLogger.info("__lastHistory() function")
   upc = UserProfileClient( "Default", getRPCClient )
   profile_name = USER_PROFILE_NAME + ".History"
   gLogger.info("upc.retrieveVar(%s)" % profile_name)
   result = upc.retrieveVar(profile_name)
   gLogger.debug(result)
   if not result["OK"]:
     return S_ERROR( result["Message"] )
   data = result["Value"]
   try:
     data = list(data)
   except:
     return S_ERROR( "Failed to convert %s to list" % data )
   last = ""
   if len(data) > 0:
     last = data.pop()
   return S_OK( last )
Exemplo n.º 16
0
 def __setBookmarks(self, name):
     if name == "columns" or name == "refresh" or name == "defaultLayout" or name == "layouts":
         return {
             "success": "false",
             "error":
             "The name \"" + name + "\" is reserved, operation failed"
         }
     if not request.params.has_key("columns") and len(
             request.params["columns"]) <= 0:
         return {
             "success": "false",
             "error": "Parameter 'Columns' is absent"
         }
     if not request.params.has_key("refresh") and len(
             request.params["refresh"]) <= 0:
         return {
             "success": "false",
             "error": "Parameter 'Refresh' is absent"
         }
     upc = UserProfileClient("Summary", getRPCClient)
     result = upc.retrieveVar("Bookmarks")
     if result["OK"]:
         data = result["Value"]
     else:
         data = {}
     data["defaultLayout"] = name
     if not data.has_key("layouts"):
         data["layouts"] = {}
     data["layouts"][name] = {}
     if request.params.has_key("plots") and len(
             request.params["plots"]) > 0:
         data["layouts"][name]["url"] = str(request.params["plots"])
     else:
         data["layouts"][name]["url"] = ""
     data["layouts"][name]["columns"] = str(request.params["columns"])
     data["layouts"][name]["refresh"] = str(request.params["refresh"])
     gLogger.info("\033[0;31m Data to save: \033[0m", data)
     result = upc.storeVar("Bookmarks", data)
     gLogger.info("\033[0;31m UserProfile response: \033[0m", result)
     if result["OK"]:
         return self.__getBookmarks()
     else:
         return {"success": "false", "error": result["Message"]}
Exemplo n.º 17
0
  def display(self):
    checkUserCredentials()
    dn = getUserDN()
    user = getUsername()
    group = getSelectedGroup()
    gLogger.always( "User: %s, Group: %s, DN: %s" % ( user , group , dn ) )
    templates = [ "reg_%s.mako" % i for i in [ "done" , "form" , "info" ] ]
    html = [ "reg_%s.html" % i for i in [ "footer" , "header" , "conditions" , "form" , "done" ] ]
    files = templates + html
    basedir = os.path.join( rootPath , "Web" , "dirac" , "templates" )
    for i in files:
      f = os.path.join( basedir , i )
      if not os.path.exists( f ):
        gLogger.error( "File does not exists: %s" % f )
        return render( "web/External.mako" )
    if dn and user == "anonymous":
      upc = UserProfileClient( "Registration" , getRPCClient )
      result =  upc.retrieveVar( dn )
      if result[ "OK" ]:
        c.sent = result[ "Value" ]
        return render( "/reg_done.mako" )
      else:
        return render("/reg_form.mako")
    if not dn or dn == "":
      return render("/reg_info.mako")

    if "site" not in request.params:
      c.select =  gConfig.getValue( "/Website/DefaultExternalURL", "http://diracgrid.org" )
      return render( "web/External.mako" )

    # No idea what this code should do...
    if request.params.has_key( "site" ) and len( request.params[ "site" ] ) > 0:
      if str( request.params[ "site" ] ) != "All":
        c.select = str( request.params[ "site" ] )
        gLogger.debug("Request's body:")
        for key in request.params.keys():
          if not key == "site" and len(request.params[key]) > 0:
            c.select = c.select + "&" + key + "=" + request.params[key]
            try:
              gLogger.debug("%s - %s" % (key,request.params[key]))
            except Exception,x:
              gLogger.error("Exception: %s" % str(x))
              pass
Exemplo n.º 18
0
 def __deleteHistory( self , name , state ):
   """
   Deleting item from Load and Save history list
   Return resulting list
   "name" is a string
   "state" can be either "Save" or "Load"
   """
   gLogger.info( "Running deleteHistory( %s )" % name )
   msg = "deleteHistory() for %s@%s" % ( getUsername() , getSelectedGroup() )
   opt = "/Website/" + USER_PROFILE_NAME + "/ShowHistory"
   history_length = gConfig.getOptions( opt , 5 )
   upc = UserProfileClient( "Default" , getRPCClient )
   group = str( getSelectedGroup() )
   profile_name = USER_PROFILE_NAME + ".History." + state + "." + group
   result = upc.retrieveVar( profile_name )
   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" ] )
     gLogger.info( "Result %s: %s" % ( msg , result[ "Message" ] ) )
     return S_OK( list() ) # Nothing to delete, return an empty list
   else:
     result = result[ "Value" ]
   if not isinstance( result , list ):
     err = "List expected at: %s" % profile_name
     gLogger.error( "Result %s: %s" % ( msg , err ) )
     return S_ERROR( err )
   history = list()
   for i in result:
     if i.has_key( "name" ) and not i["name"] == name:
       history.append( i )
   if( len( history ) > history_length ):
     history = result[ history_length ]
   gLogger.error( "History: %s" % history )
   result = upc.storeVar( profile_name , history )
   gLogger.info( result )
   if not result[ "OK" ]:
     gLogger.error( "Result %s: %s" % ( msg , result[ "Message" ] ) )
     return S_ERROR( result[ "Message" ] )
   gLogger.info( "Result %s: %s" % ( msg , history ) )
   return S_OK( history )
Exemplo n.º 19
0
 def __deleteHistory(self, name, state):
     """
 Deleting item from Load and Save history list
 Return resulting list
 "name" is a string
 "state" can be either "Save" or "Load"
 """
     gLogger.info("Running deleteHistory( %s )" % name)
     msg = "deleteHistory() for %s@%s" % (getUsername(), getSelectedGroup())
     opt = "/Website/" + USER_PROFILE_NAME + "/ShowHistory"
     history_length = gConfig.getOptions(opt, 5)
     upc = UserProfileClient("Default", getRPCClient)
     group = str(getSelectedGroup())
     profile_name = USER_PROFILE_NAME + ".History." + state + "." + group
     result = upc.retrieveVar(profile_name)
     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"])
         gLogger.info("Result %s: %s" % (msg, result["Message"]))
         return S_OK(list())  # Nothing to delete, return an empty list
     else:
         result = result["Value"]
     if not isinstance(result, list):
         err = "List expected at: %s" % profile_name
         gLogger.error("Result %s: %s" % (msg, err))
         return S_ERROR(err)
     history = list()
     for i in result:
         if i.has_key("name") and not i["name"] == name:
             history.append(i)
     if (len(history) > history_length):
         history = result[history_length]
     gLogger.error("History: %s" % history)
     result = upc.storeVar(profile_name, history)
     gLogger.info(result)
     if not result["OK"]:
         gLogger.error("Result %s: %s" % (msg, result["Message"]))
         return S_ERROR(result["Message"])
     gLogger.info("Result %s: %s" % (msg, history))
     return S_OK(history)
Exemplo n.º 20
0
 def __delBookmarks(self, name):
     if name == "columns" or name == "refresh" or name == "defaultLayout" or name == "layouts":
         return {
             "success":
             "false",
             "error":
             "The name \"" + name +
             "\" is reserved, please choose another name. Operation failed"
         }
     upc = UserProfileClient("Summary", getRPCClient)
     result = upc.retrieveVar("Bookmarks")
     if result["OK"]:
         data = result["Value"]
     else:
         data = {}
     gLogger.info("\033[0;31m data: \033[0m", data)
     if data.has_key("layouts"):
         if name in data["layouts"]:
             del data["layouts"][name]
         else:
             return {
                 "success": "false",
                 "error":
                 "Can't delete not existing layout: \"" + name + "\""
             }
     else:
         return {
             "success": "false",
             "error": "Can't read existing layouts, operation failed"
         }
     if len(data["layouts"]) > 0:
         data["defaultLayout"] = data["layouts"].keys()[0]
     else:
         data["defaultLayout"] = ""
     gLogger.info("\033[0;31m data: \033[0m", data)
     result = upc.storeVar("Bookmarks", data)
     gLogger.info("\033[0;31m result: \033[0m", result)
     if result["OK"]:
         return self.__getBookmarks()
     else:
         return {"success": "false", "error": result["Message"]}
Exemplo n.º 21
0
 def __setHistory( self , item , state ):
   """
   Insert item to  Load or Save history list in first position and checking for
   duplications.
   Return resulting list
   "item" is a dict
   "state" should be either "Save" or "Load" but can be any other value
   """
   gLogger.info( "Running setHistory( %s , %s )" % ( item , state ) )
   msg = "setHistory() for %s@%s" % ( getUsername() , getSelectedGroup() )
   opt = "/Website/" + USER_PROFILE_NAME + "/ShowHistory"
   history_length = gConfig.getOptions( opt , 5 )
   upc = UserProfileClient( "Default" , getRPCClient )
   group = str( getSelectedGroup() )
   profile_name = USER_PROFILE_NAME + ".History." + state + "." + group
   result = upc.retrieveVar( profile_name )
   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" ] )
     history = list()
   else:
     history = result[ "Value" ]
   if not isinstance( history , list ):
     err = "List expected at: %s" % profile_name
     gLogger.error( "Result %s: %s" % ( msg , err ) )
     return S_ERROR( err )
   if( len( history ) > history_length ):
     history = result[ history_length ]
   history.insert( 0 , item )
   history = uniqueElements( history )
   gLogger.error( "History: %s" % history )
   result = upc.storeVar( profile_name , history )
   gLogger.info( result )
   if not result[ "OK" ]:
     gLogger.error( "Result %s: %s" % ( msg , result[ "Message" ] ) )
     return S_ERROR( result[ "Message" ] )
   gLogger.info( "Result %s: %s" % ( msg , history ) )
   return S_OK( history )
Exemplo n.º 22
0
 def __setHistory(self, item, state):
     """
 Insert item to  Load or Save history list in first position and checking for
 duplications.
 Return resulting list
 "item" is a dict
 "state" should be either "Save" or "Load" but can be any other value
 """
     gLogger.info("Running setHistory( %s , %s )" % (item, state))
     msg = "setHistory() for %s@%s" % (getUsername(), getSelectedGroup())
     opt = "/Website/" + USER_PROFILE_NAME + "/ShowHistory"
     history_length = gConfig.getOptions(opt, 5)
     upc = UserProfileClient("Default", getRPCClient)
     group = str(getSelectedGroup())
     profile_name = USER_PROFILE_NAME + ".History." + state + "." + group
     result = upc.retrieveVar(profile_name)
     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"])
         history = list()
     else:
         history = result["Value"]
     if not isinstance(history, list):
         err = "List expected at: %s" % profile_name
         gLogger.error("Result %s: %s" % (msg, err))
         return S_ERROR(err)
     if (len(history) > history_length):
         history = result[history_length]
     history.insert(0, item)
     history = uniqueElements(history)
     gLogger.error("History: %s" % history)
     result = upc.storeVar(profile_name, history)
     gLogger.info(result)
     if not result["OK"]:
         gLogger.error("Result %s: %s" % (msg, result["Message"]))
         return S_ERROR(result["Message"])
     gLogger.info("Result %s: %s" % (msg, history))
     return S_OK(history)
Exemplo n.º 23
0
 def __addBookmark(self, path, title):
     """adds a bookmark"""
     self.getWidget().waitCursor()
     upc = UserProfileClient("Bookkeeping", RPCClient)
     result = upc.retrieveVar("Bookmarks")
     if result["OK"]:
         data = result["Value"]
     else:
         data = {}
     if title in data:
         QMessageBox.critical(
             self.getWidget(), "Error", "The bookmark with the title \"" +
             title + "\" is already exists", QMessageBox.Ok)
         return S_ERROR("The bookmark with the title \"" + title +
                        "\" is already exists")
     else:
         data[title] = path
     result = upc.storeVar("Bookmarks", data)
     self.getWidget().arrowCursor()
     if result["OK"]:
         return self.__getBookmarks()
     else:
         return S_ERROR(result["Message"])
Exemplo n.º 24
0
 def __delBookmark(self, title):
     """deletes a bookmark"""
     self.getWidget().waitCursor()
     upc = UserProfileClient("Bookkeeping", RPCClient)
     result = upc.retrieveVar("Bookmarks")
     if result["OK"]:
         data = result["Value"]
     else:
         data = {}
     if title in data:
         del data[title]
     else:
         QMessageBox.critical(
             self.getWidget(), "Error",
             "Can't delete not existing bookmark: \"" + title + "\"",
             QMessageBox.Ok)
         return S_ERROR("Can't delete not existing bookmark: \"" + title +
                        "\"")
     result = upc.storeVar("Bookmarks", data)
     self.getWidget().arrowCursor()
     if result["OK"]:
         return self.__getBookmarks()
     else:
         return S_ERROR(result["Message"])