def SessionGetId(username): doc = None try: doc = _ManagementProcessRequest( _SessionFormatRequest("session", "status", None, username)) except Exception, e: return None
def UserSetUserPref(username, key, value): doc = _ManagementProcessRequest(_UserFormatRequest(username, "user_conf", "set", key, value )) if doc is None: return False pref = doc.getElementsByTagName("response") if len(pref) == 0: return False return True
def UserSetUserPref(username, key, value): doc = _ManagementProcessRequest( _UserFormatRequest(username, "user_conf", "set", key, value)) if doc is None: return False pref = doc.getElementsByTagName("response") if len(pref) == 0: return False return True
def SessionGetStatus(session_id): doc = _ManagementProcessRequest(_SessionFormatRequest("session", "status", session_id)) if doc is None: return SESSION_STATUS_UNKNOWN sessions = doc.getElementsByTagName("session") if len(sessions) == 0: return SESSION_STATUS_UNKNOWN sessionNode = sessions[0] status = sessionNode.getAttribute("status") return status
def UserGetUserPref(username, key): doc = _ManagementProcessRequest(_UserFormatRequest(username, "user_conf", "get", key )) if doc is None: return USER_PREF_UNKNOW pref = doc.getElementsByTagName("user_conf") if len(pref) == 0: return USER_PREF_UNKNOW prefNode = pref[0] value = prefNode.getAttribute("value") return value
def SessionGetStatus(session_id): doc = _ManagementProcessRequest( _SessionFormatRequest("session", "status", session_id)) if doc is None: return SESSION_STATUS_UNKNOWN sessions = doc.getElementsByTagName("session") if len(sessions) == 0: return SESSION_STATUS_UNKNOWN sessionNode = sessions[0] status = sessionNode.getAttribute("status") return status
def UserGetUserPref(username, key): doc = _ManagementProcessRequest( _UserFormatRequest(username, "user_conf", "get", key)) if doc is None: return USER_PREF_UNKNOW pref = doc.getElementsByTagName("user_conf") if len(pref) == 0: return USER_PREF_UNKNOW prefNode = pref[0] value = prefNode.getAttribute("value") return value
def SessionLogoff(session_id): doc = _ManagementProcessRequest(_SessionFormatRequest("session", "logoff", session_id)) if doc is None: return False sessions = doc.getElementsByTagName("session") if len(sessions) == 0: return False sessionNode = sessions[0] status = sessionNode.getAttribute("status") if status != SESSION_STATUS_CLOSED: return False return True
def SessionDisconnect(session_id): doc = _ManagementProcessRequest(_SessionFormatRequest("session", "disconnect", session_id)) if doc is None: return False sessions = doc.getElementsByTagName("session") if len(sessions) == 0: return False sessionNode = sessions[0] status = sessionNode.getAttribute("status") if status != SESSION_STATUS_DISCONNECTED: return False return True
def SessionLogoff(session_id): doc = _ManagementProcessRequest( _SessionFormatRequest("session", "logoff", session_id)) if doc is None: return False sessions = doc.getElementsByTagName("session") if len(sessions) == 0: return False sessionNode = sessions[0] status = sessionNode.getAttribute("status") if status != SESSION_STATUS_CLOSED: return False return True
def SessionDisconnect(session_id): doc = _ManagementProcessRequest( _SessionFormatRequest("session", "disconnect", session_id)) if doc is None: return False sessions = doc.getElementsByTagName("session") if len(sessions) == 0: return False sessionNode = sessions[0] status = sessionNode.getAttribute("status") if status != SESSION_STATUS_DISCONNECTED: return False return True
def SessionGetList(): l = {} doc = _ManagementProcessRequest(_SessionFormatRequest("sessions", "list")) if doc is None: return l sessionNodes = doc.getElementsByTagName("session") for node in sessionNodes: session = {} for key in ["id", "username", "status"]: session[key] = node.getAttribute(key) l[session["id"]] = session return l
def SessionGetId(username): doc = None try: doc = _ManagementProcessRequest(_SessionFormatRequest("session", "status", None, username)) except Exception, e: return None