ShellBanner
System:Linux MiraNet 3.0.0-14-generic-pae #23-Ubuntu SMP Mon Nov 21 22:07:10 UTC 2011 i686
Software:Apache. PHP/5.3.6-13ubuntu3.10
ID:uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
Safe Mode:OFF
Open_Basedir:OFF
Freespace:27.45 GB of 70.42 GB (38.98%)
MySQL: ON MSSQL: OFF Oracle: OFF PostgreSQL: OFF Curl: OFF Sockets: ON Fetch: OFF Wget: ON Perl: ON
Disabled Functions: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,

/ usr/ lib/ python2.7/ dist-packages/ LanguageSelector/ - drwxr-xr-x

Directory:
Viewing file:     ImSwitch.py (5.1 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# ImSwitch.py (c) 2006 Canonical, released under the GPL
#
# This file implements a interface to im-switch
#

from LocaleInfo import LocaleInfo
import os
import sys
import subprocess

class ImSwitch(object):
    
    # some global data
    global_confdir = "/etc/X11/xinit/xinput.d/"
    local_confdir = os.path.expanduser("~/.xinput.d/")
    bin = "/usr/bin/im-switch"
    default_method = "ibus"
    blacklist_file = "/usr/share/language-selector/data/im-switch.blacklist"

    def __init__(self):
        pass

    def available(self):
        " return True if im-switch is available at all "
        return os.path.exists(self.bin)

    def removeDanglingSymlinks(self):
        for dir in (self.local_confdir, self.global_confdir):
            if os.path.exists(dir):
                for dentry in os.listdir(dir):
                    if not os.path.exists("%s/%s" % (dir, dentry)):
                        os.unlink("%s/%s" % (dir, dentry))
    
    def enabledForLocale(self, locale):
        " check if we have a config for this specifc locale (e.g. ja_JP) "
        for dir in (self.local_confdir, self.global_confdir):
            for name in (locale, "all_ALL"):
                target = os.path.join(dir,name)
                #print "checking im-switch config: ", target, os.path.basename(os.path.realpath(target))
                if os.path.exists(target):
                    im_name = os.path.basename(os.path.realpath(target))
                    if im_name in ("none", "default"):
                        #print "points to none or default"
                        return False
                    #print "points to real config"
                    return True
        return False

    def enable(self, locale):
        " enable input methods for locale"
        # try auto first
        subprocess.call(["im-switch","-z",locale,"-a"])
        # if no config is set, force the default
        if not self.enabledForLocale(locale):
            subprocess.call(["im-switch","-z",locale,
                             "-s", self.default_method])

    def disable(self, locale):
        " disable input method for locale "
        # remove local config first
        if os.path.exists(os.path.join(self.local_confdir, locale)):
            os.unlink(os.path.join(self.local_confdir, locale))
        # see if we still have a input method and if so, force "none"
        if self.enabledForLocale(locale):
            subprocess.call(["im-switch","-z",locale,"-s","none"])

    def getInputMethodForLocale(self, locale):
        for dir in (self.local_confdir, self.global_confdir):
            if os.path.exists(dir):
                for name in (locale, "all_ALL"):
                    target = os.path.join(dir,name)
                    if os.path.exists(target):
                        return os.path.basename(os.path.realpath(target))
        return None
        
    def setInputMethodForLocale(self, im, locale):
        if not os.path.exists(self.local_confdir):
            os.mkdir(self.local_confdir)
        subprocess.call(["im-switch","-z",locale,"-s",im])
    
    def getAvailableInputMethods(self):
        """ return the input methods available via im-switch """
        # load blacklist
        blacklist = []
        for l in open(self.blacklist_file):
            l = l.strip()
            if l and not l.startswith('#'):
                blacklist.append(l)
        # now get available methods 
        inputMethods = []
        for dentry in os.listdir(self.global_confdir):
            if (not os.path.islink(self.global_confdir+dentry) and 
                not dentry in blacklist):
                inputMethods.append(dentry)
        return ['none']+sorted(inputMethods)

    def setDefaultInputMethod(self, method, locale="all_ALL"):
        """ sets the default input method for the given locale
            (in ll_CC form)
        """
        l = self.confdir+locale
        if os.path.islink(l):
            os.unlink(l)
        os.symlink(self.confdir+method, l)
        return True

    def resetDefaultInputMethod(self, locale="all_ALL"):
        """ reset the default input method to auto (controlled by
            im-switch
        """
        d = "/etc/alternatives/xinput-%s" % locale
        l = self.confdir+locale
        if os.path.islink(l):
            os.unlink(l)
        os.symlink(d, self.confdir+locale)
        return True
        
    def getCurrentInputMethod(self, locale="all_ALL"):
        """ get the current default input method for the selected
            locale (in ll_CC form)
        """
        return os.path.basename(os.path.realpath(self.local_confdir+locale))
        
if __name__ == "__main__":
    im = ImSwitch()
#    print im.getInputMethodForLocale("ja_JP")
#    print im.enabledForLocale("all_ALL")
    print "available input methods: "
    print im.getAvailableInputMethods()
    print "current method: ",
    print im.getCurrentInputMethod()
    sys.exit(1)
    print "switching to 'th-xim': ",
    print im.setDefaultInputMethod("th-xim")
    print "current method: ",
    print im.getCurrentInputMethod()
    print "reset default: ",
    print im.resetDefaultInputMethod()
    print "current method: ",
    print im.getCurrentInputMethod()
Command:
Quick Commands:
Upload:
[Read-Only] Max size: 100MB
PHP Filesystem: <@ Ú
Search File:
regexp
Create File:
Overwrite [Read-Only]
View File:
Mass Defacement:
[+] Main Directory: [+] Defacement Url:
LmfaoX Shell - Private Build [BETA] - v0.1 -; Generated: 0.4092 seconds