def layoutAvailable(self): upProfileName = "Summary" upc = UserProfileClient( "Summary", getRPCClient ) result = upc.listAvailableVars() gLogger.info("\033[0;31m listAvailableVars: \033[0m",result) if result["OK"]: result = result["Value"] resultList = [] for i in result: resultList.append({'name':i[3],'owner':i[0]}) return {"success":"true","result":resultList,"total":"55"}
def layoutAvailable(self): upProfileName = "Summary" upc = UserProfileClient("Summary", getRPCClient) result = upc.listAvailableVars() gLogger.info("\033[0;31m listAvailableVars: \033[0m", result) if result["OK"]: result = result["Value"] resultList = [] for i in result: resultList.append({'name': i[3], 'owner': i[0]}) return {"success": "true", "result": resultList, "total": "55"}
def layoutUser(self): upProfileName = "Summary" upc = UserProfileClient( "Summary", getRPCClient ) result = upc.listAvailableVars() if result["OK"]: result = result["Value"] userList = [] for i in result: userList.append(i[0]) userList = uniqueElements(userList) resultList = [] for j in userList: resultList.append({'name':j}) total = len(resultList) resultList.sort() resultList.insert(0,{'name':'All'}) c.result = {"success":"true","result":resultList,"total":total} else: c.result = {"success":"false","error":result["Message"]} return c.result
def __getLayout(self): gLogger.info("Running getLayout()") msg = "getLayout() for %s@%s" % (getUsername(), getSelectedGroup()) upc = UserProfileClient(USER_PROFILE_NAME, getRPCClient) result = upc.listAvailableVars() gLogger.debug(result) if not result["OK"]: gLogger.error("Result %s: %s" % (msg, result["Message"])) return {"success": "false", "error": result["Message"]} result = result["Value"] gLogger.always("array2obj") availble = map(self.__array2obj, result) gLogger.always(availble) users = list() for i in result: if len(i) > 1: users.append({"user": i[0]}) users = uniqueElements(users) gLogger.info("Result %s: %s AND %s" % (msg, availble, users)) return {"success": "true", "result": availble, "users": users}
def __getLayout( self ) : gLogger.info( "Running getLayout()" ) msg = "getLayout() for %s@%s" % ( getUsername() , getSelectedGroup() ) upc = UserProfileClient( USER_PROFILE_NAME, getRPCClient ) result = upc.listAvailableVars() gLogger.debug( result ) if not result[ "OK" ]: gLogger.error( "Result %s: %s" % ( msg , result[ "Message" ] ) ) return { "success" : "false" , "error" : result[ "Message" ] } result = result[ "Value" ] gLogger.always( "array2obj" ) availble = map( self.__array2obj , result ) gLogger.always( availble ) users = list() for i in result : if len( i ) > 1 : users.append( { "user" : i[ 0 ] } ) users = uniqueElements( users ) gLogger.info( "Result %s: %s AND %s" % ( msg , availble , users ) ) return { "success" : "true" , "result" : availble , "users" : users }
def layoutUser(self): upProfileName = "Summary" upc = UserProfileClient("Summary", getRPCClient) result = upc.listAvailableVars() if result["OK"]: result = result["Value"] userList = [] for i in result: userList.append(i[0]) userList = uniqueElements(userList) resultList = [] for j in userList: resultList.append({'name': j}) total = len(resultList) resultList.sort() resultList.insert(0, {'name': 'All'}) c.result = { "success": "true", "result": resultList, "total": total } else: c.result = {"success": "false", "error": result["Message"]} return c.result
def web_listPublicStates( self ): session = self.getSessionData() user = session["user"]["username"] up = self.__getUP() retVal = yield self.threadTask( up.getUserProfileNames, {'PublishAccess':'ALL'} ) if not retVal[ 'OK' ]: raise WErr.fromSERROR( retVal ) data = retVal['Value'] if data == None: raise WErr(404, "There are no public states!" ) paramNames = ['user', 'group', 'vo', 'name'] mydesktops = {'name':'My Desktops', 'group':'', 'vo':'', 'user':'', 'iconCls' : 'my-desktop', 'children' :[] } shareddesktops = {'name':'Shared Desktops', 'group':'', 'vo':'', 'user':'', 'expanded': 'true', 'iconCls' : 'shared-desktop', 'children' :[] } myapplications = {'name':'My Applications', 'group':'', 'vo':'', 'user':'', 'children' :[] } sharedapplications = {'name':'Shared Applications', 'group':'', 'vo':'', 'user':'', 'expanded': 'true', 'iconCls' : 'shared-desktop', 'children' :[] } desktopsApplications = { 'text':'.', 'children': [{'name':'Desktops', 'group':'', 'vo':'', 'user':'', 'children' :[mydesktops, shareddesktops] }, {'name':'Applications', 'group':'', 'vo':'', 'user':'', 'children' :[myapplications, sharedapplications] } ] } type = '' for i in data: application = i.replace( 'Web/application/', '' ) up = UserProfileClient( i ) retVal = up.listAvailableVars() if not retVal['OK']: raise WErr.fromSERROR( retVal ) else: states = retVal['Value'] for state in states: record = dict( zip( paramNames, state ) ) record['app'] = application retVal = yield self.threadTask( up.getVarPermissions, record['name'] ) if not retVal['OK']: raise WErr.fromSERROR( retVal ) else: permissions = retVal['Value'] if permissions['PublishAccess'] == 'ALL': if application == 'desktop': record['type'] = 'desktop' record['leaf'] = 'true' record['iconCls'] = 'core-desktop-icon', if record['user'] == user: mydesktops['children'].append( record ) else: shareddesktops['children'].append( record ) else: record['type'] = 'application' record['leaf'] = 'true' record['iconCls'] = 'core-application-icon' if record['user'] == user: myapplications['children'].append( record ) else: sharedapplications['children'].append( record ) self.finish( desktopsApplications )
def web_listPublicStates(self): session = self.getSessionData() user = session["user"]["username"] up = self.__getUP() retVal = yield self.threadTask(up.getUserProfileNames, {'PublishAccess': 'ALL'}) if not retVal['OK']: raise WErr.fromSERROR(retVal) data = retVal['Value'] if data == None: raise WErr(404, "There are no public states!") paramNames = ['user', 'group', 'vo', 'name'] mydesktops = { 'name': 'My Desktops', 'group': '', 'vo': '', 'user': '', 'iconCls': 'my-desktop', 'children': [] } shareddesktops = { 'name': 'Shared Desktops', 'group': '', 'vo': '', 'user': '', 'expanded': 'true', 'iconCls': 'shared-desktop', 'children': [] } myapplications = { 'name': 'My Applications', 'group': '', 'vo': '', 'user': '', 'children': [] } sharedapplications = { 'name': 'Shared Applications', 'group': '', 'vo': '', 'user': '', 'expanded': 'true', 'iconCls': 'shared-desktop', 'children': [] } desktopsApplications = { 'text': '.', 'children': [{ 'name': 'Desktops', 'group': '', 'vo': '', 'user': '', 'children': [mydesktops, shareddesktops] }, { 'name': 'Applications', 'group': '', 'vo': '', 'user': '', 'children': [myapplications, sharedapplications] }] } type = '' for i in data: application = i.replace('Web/application/', '') up = UserProfileClient(i) retVal = up.listAvailableVars() if not retVal['OK']: raise WErr.fromSERROR(retVal) else: states = retVal['Value'] for state in states: record = dict(zip(paramNames, state)) record['app'] = application retVal = yield self.threadTask(up.getVarPermissions, record['name']) if not retVal['OK']: raise WErr.fromSERROR(retVal) else: permissions = retVal['Value'] if permissions['PublishAccess'] == 'ALL': if application == 'desktop': record['type'] = 'desktop' record['leaf'] = 'true' record['iconCls'] = 'core-desktop-icon', if record['user'] == user: mydesktops['children'].append(record) else: shareddesktops['children'].append(record) else: record['type'] = 'application' record['leaf'] = 'true' record['iconCls'] = 'core-application-icon' if record['user'] == user: myapplications['children'].append(record) else: sharedapplications['children'].append( record) self.finish(desktopsApplications)