示例#1
0
    def logout(self):
        # IF IS KDE
        if (("KDE_FULL_SESSION" in env) and (env["KDE_FULL_SESSION"] == "true")):
            # KDE4
            if (("KDE_SESSION_VERSION" in env) and (env['KDE_SESSION_VERSION'] == '4')):
                executable = is_in_path("qdbus")
                if not executable:
                    return False

                cmd = [executable, "org.kde.ksmserver", "/KSMServer",
                       "logout", "0", "0", "0"]

                execute_command(cmd)
                return True

            # KDE3
            executable = is_in_path('dcop')
            if not executable:
                return False

            cmd = [executable, "ksmserver", "ksmserver",
                   "logout", "0", "0", "0"]
            execute_command(cmd)
            return True

        elif "GNOME_DESKTOP_SESSION_ID" in env:
            p = is_in_path("gnome-session-save")

            if not p:
                return False

            cmd = [p, "--logout"]
            execute_command(cmd)

        # FIND XFCE4
        if "xfce4" in get_output_of_command("xprop -root _DT_SAVE_MODE"):
            p = is_in_path("xfce4-session-logout")

            if not p:
                return False

            cmd = [p, "--logout"]
            execute_command(cmd)
            
            return True
            
        # BlackBox and fluxbox
        out = get_output_of_command ("xprop -root _BLACKBOX_PID")
        if out:
            print out
            m = re.search(r'\d+', out)

            if m:
                pid = int(m.group())
                oskill(pid)
                return True
            
        #TODO: find session and send logout signal
        pass
示例#2
0
    def reboot(self):
        executable = is_in_path("reboot")
        if not executable:
            return False

        a = execute_command(executable)
        print a
示例#3
0
 def reboot(self):
     executable = is_in_path("reboot")
     if not executable:
         return False
     
     a = execute_command(executable)
     print a
示例#4
0
    def shutdown(self):
        executable = is_in_path("shutdown")
        if not executable:
            return False

        cmd = [executable, "-h", "now"]
        a = execute_command(cmd)
        print a
示例#5
0
 def shutdown(self):
     executable = is_in_path("shutdown")
     if not executable:
         return False
     
     cmd = [executable, "-h", "now"]
     a = execute_command(cmd)
     print a
示例#6
0
from OpenlhClient import utils
from OpenlhClient.ui import icons
from OpenlhClient.globals import *
from OpenlhCore.utils import threaded, is_in_path, execute_command
from OpenlhClient.ui.utils import get_gtk_builder

_ = gettext.gettext

from os import name as osname
from os import path as ospath
from os import getenv as os_getenv
from os import environ as osenviron

BUTTONS = (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)

GNOME_OPEN_PATH = is_in_path("gnome-open")

(URL_TYPE_SITE, URL_TYPE_EMAIL) = range(2)


@threaded
def open_link(obj, link, url_type):
    if url_type == URL_TYPE_SITE:
        command = [GNOME_OPEN_PATH, link]
    elif url_type == URL_TYPE_EMAIL:
        command = [GNOME_OPEN_PATH, "mailto:" + link]

    execute_command(command)


if GNOME_OPEN_PATH:
示例#7
0
    def logout(self):
        assert "GDMSESSION" in env, "Session must be specified by environ Variable GDMSESSION"
        session = env["GDMSESSION"]

        # Openbox
        if "openbox" in session.lower():
            p = is_in_path("openbox")

            if not p:
                return False

            cmd = [p, "--exit"]
            execute_command(cmd)

        # Send logout signal to GNOME
        elif "gnome" in session.lower():
            p = is_in_path("gnome-session-save")

            if not p:
                return False

            cmd = [p, "--logout"]
            a = execute_command(cmd)

        if "xfce" in session.lower():
            p = is_in_path("xfce4-session-logout")

            if not p:
                return False

            cmd = [p, "--logout"]
            execute_command(cmd)

            return True

        elif (("fluxbox" in session.lower())
              or ("blackbox" in session.lower())):
            out = get_output_of_command("xprop -root _BLACKBOX_PID")

            if not out:
                return False

            m = re.search(r'\d+', out)

            if not m:
                return False

            pid = int(m.group())
            oskill(pid)

        elif ("kde" in session.lower()):
            # KDE4
            if (("KDE_SESSION_VERSION" in env)
                    and (env['KDE_SESSION_VERSION'] == '4')):
                executable = is_in_path("qdbus")
                if not executable:
                    return False

                cmd = [
                    executable, "org.kde.ksmserver", "/KSMServer", "logout",
                    "0", "0", "0"
                ]

                execute_command(cmd)
                return True

            # KDE3
            executable = is_in_path('dcop')
            if not executable:
                return False

            cmd = [
                executable, "ksmserver", "ksmserver", "logout", "0", "0", "0"
            ]
            execute_command(cmd)
            return True

        #TODO: write for kde, xfce4, and LXDE
        return True
示例#8
0
    def logout(self):
        # IF IS KDE
        if (("KDE_FULL_SESSION" in env)
                and (env["KDE_FULL_SESSION"] == "true")):
            # KDE4
            if (("KDE_SESSION_VERSION" in env)
                    and (env['KDE_SESSION_VERSION'] == '4')):
                executable = is_in_path("qdbus")
                if not executable:
                    return False

                cmd = [
                    executable, "org.kde.ksmserver", "/KSMServer", "logout",
                    "0", "0", "0"
                ]

                execute_command(cmd)
                return True

            # KDE3
            executable = is_in_path('dcop')
            if not executable:
                return False

            cmd = [
                executable, "ksmserver", "ksmserver", "logout", "0", "0", "0"
            ]
            execute_command(cmd)
            return True

        elif "GNOME_DESKTOP_SESSION_ID" in env:
            p = is_in_path("gnome-session-save")

            if not p:
                return False

            cmd = [p, "--logout"]
            execute_command(cmd)

        # FIND XFCE4
        if "xfce4" in get_output_of_command("xprop -root _DT_SAVE_MODE"):
            p = is_in_path("xfce4-session-logout")

            if not p:
                return False

            cmd = [p, "--logout"]
            execute_command(cmd)

            return True

        # BlackBox and fluxbox
        out = get_output_of_command("xprop -root _BLACKBOX_PID")
        if out:
            print out
            m = re.search(r'\d+', out)

            if m:
                pid = int(m.group())
                oskill(pid)
                return True

        #TODO: find session and send logout signal
        pass
示例#9
0
from OpenlhClient import utils
from OpenlhClient.ui import icons
from OpenlhClient.globals import *
from OpenlhCore.utils import threaded, is_in_path, execute_command
from OpenlhClient.ui.utils import get_gtk_builder
_ = gettext.gettext

from os import name as osname
from os import path as ospath
from os import getenv as os_getenv
from os import environ as osenviron

BUTTONS = (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK,
           gtk.RESPONSE_ACCEPT)

GNOME_OPEN_PATH = is_in_path('gnome-open')

(URL_TYPE_SITE, URL_TYPE_EMAIL) = range(2)


@threaded
def open_link(obj, link, url_type):
    if url_type == URL_TYPE_SITE:
        command = [GNOME_OPEN_PATH, link]
    elif url_type == URL_TYPE_EMAIL:
        command = [GNOME_OPEN_PATH, "mailto:" + link]

    execute_command(command)


if GNOME_OPEN_PATH:
示例#10
0
    def logout(self):
        assert "GDMSESSION" in env, "Session must be specified by environ Variable GDMSESSION"
        session = env["GDMSESSION"]
        
        # Openbox
        if "openbox" in session.lower():
            p = is_in_path("openbox")
            
            if not p:
                return False
            
            cmd = [p, "--exit"]
            execute_command(cmd)
            
        # Send logout signal to GNOME
        elif "gnome" in session.lower():
            p = is_in_path("gnome-session-save")
            
            if not p:
                return False
            
            cmd = [p, "--logout"]
            a = execute_command(cmd)

        if "xfce" in session.lower():
            p = is_in_path("xfce4-session-logout")

            if not p:
                return False

            cmd = [p, "--logout"]
            execute_command(cmd)
            
            return True
            
        elif (("fluxbox" in session.lower()) or 
              ("blackbox" in session.lower())):
            out = get_output_of_command ("xprop -root _BLACKBOX_PID")

            if not out:
                return False

            m = re.search(r'\d+', out)
            
            if not m:
                return False
            
            pid = int(m.group())
            oskill(pid)
            
        elif ("kde" in session.lower()):
            # KDE4
            if (("KDE_SESSION_VERSION" in env) and (env['KDE_SESSION_VERSION'] == '4')):
                executable = is_in_path("qdbus")
                if not executable:
                    return False

                cmd = [executable, "org.kde.ksmserver", "/KSMServer",
                       "logout", "0", "0", "0"]

                execute_command(cmd)
                return True

            # KDE3
            executable = is_in_path('dcop')
            if not executable:
                return False

            cmd = [executable, "ksmserver", "ksmserver",
                   "logout", "0", "0", "0"]
            execute_command(cmd)
            return True


        #TODO: write for kde, xfce4, and LXDE
        return True