Пример #1
0
    def waitLogout(self,urLogin,waitTime,postWaitTime=5):
        """
        Ожидать завершения пользовательского сеанса

        Args:
        urLogin: логин пользователя
        waitTime: время ожидания завершения сеанса
        """
        if filter(lambda x: "xdm/xdm\x00--logout" in x,
                 getRunCommands()):
            for i in range(0,waitTime):
                if not filter(lambda x: "xdm/xdm\x00--logout" in x,
                    getRunCommands()):
                    return True
                time.sleep(1)
            else:
                raise DesktopError(_("Unable to wait for completion "
                                     "of the user logout"))
        for wait in range(0,5):
            self.clVars.Invalidate('cl_desktop_online_data')
            if not urLogin in self.clVars.Get('cl_desktop_online_user'):
                return True
            time.sleep(1)
        else:
            return False
Пример #2
0
 def userLogout(self, datavars=None):
     """
     Raise user logout throught dbus
     """
     self.initVars(datavars)
     if not self.clVars.Get('ur_login') in \
         self.clVars.Get('cl_desktop_online_user'):
         raise DesktopError(_("X session users not found"))
     urLogin = self.clVars.Get('ur_login')
     display = self.clVars.Select('cl_desktop_online_display',
                 where='cl_desktop_online_user',eq=urLogin,limit=1)
     session = self.clVars.Get('cl_desktop_xsession')
     if session == 'xfce':
         logoutCommand = "/usr/bin/qdbus org.xfce.SessionManager " \
             "/org/xfce/SessionManager Logout False False"
     elif session == 'kde':
         logoutCommand = "/usr/bin/kquitapp ksmserver"
     elif session == 'gnome':
         logoutCommand = "/usr/bin/qdbus org.gnome.SessionManager " \
             "/org/gnome/SessionManager Logout 1"
     else:
         raise DesktopError(_("Unable to detect the X session"))
     if process("su",urLogin,"-c",
         ("DISPLAY=:%s "%display)+logoutCommand).failed():
         raise DesktopError(_("Unable to send the logout command"))
     for i in range(0,20):
         if filter(lambda x: "xdm/xdm\x00--logout" in x,
                 getRunCommands()):
             break
         time.sleep(0.5)
     if filter(lambda x: "xdm/xdm\x00--logout" in x,
              getRunCommands()):
         self.startTask(_("Waiting for completion of the user logout"))
         for i in range(0,300):
             if not filter(lambda x: "xdm/xdm\x00--logout" in x,
                 getRunCommands()):
                 return True
             time.sleep(1)
             self.endTask()
         else:
             raise DesktopError(_("Unable to wait for completion "
                                  "of the user logout"))
     if self.clVars.Get('ur_login') in \
         self.clVars.Get('cl_desktop_online_user'):
         raise DesktopError(_("Wrong logout"))
     return True