Esempio n. 1
0
    def setExename(self):
        try:
            cmd = self.entry["command"]
        except KeyError:
            raise Prophet.NotSet("no command entry found")
        self.testGoodness(cmd)
        scmd = cmd.split(" ", 1)
        if len(scmd) >= 2:
            cmd = scmd[0].strip()
            args = scmd[1].strip()
            for x in args.split():
                if fnmatch.fnmatch(x, "*/*/*") and not os.path.exists(x):
                    # An argument specified in the command line looks like a path. If it
                    # doesn't exist, the entire command is likely to be
                    # worthless, so throw it off
                    raise Prophet.NotSet(
                        "nonexistent path %s as command argument")

            self.exeargs = args
        if not runDebian:
            # If we're not running Debian specified command may be located
            # elsewhere therefore we have to scan PATH for it
            cmd = os.path.basename(cmd)
            # List of globs of unwanted commands
            if cmd in ("sh", "bash", "csh", "tcsh", "zsh", "ls", "killall",
                       "echo", "nice", "xmessage", "xlock"):
                # Debian seems to have lots of shell commands. While it would be nice
                # to try to analyze them, this isn't a priority since they're often
                # too Debian-specific.
                raise Prophet.NotSet("%s blacklisted" % cmd)

        self.exename = cmd
Esempio n. 2
0
    def setTerminal(self):
        try:
            needs = Kw(self.entry["needs"])
            if needs == Kw("X11"):
                self.terminal = False
            elif needs == Kw("text"):
                self.terminal = True
            else:
                raise Prophet.NotSet("unsupported needs entry (%s)" % needs)

        except KeyError:
            super(App, self).setTerminal()
Esempio n. 3
0
 def setKeywords(self):
     try:
         sect = self.entry["section"]
     except KeyError:
         sect = ""
     try:
         hint = self.entry["hints"]
     except KeyError:
         hint = ""
     kws = _deb2kws(sect, hint)
     if not len(kws):
         raise Prophet.NotSet("no keywords guessed")
     self.keywords = kws
Esempio n. 4
0
    def setKeywords(self):
        try:
            cats = self.desktop["Categories"]
            if type(cats) == tuple:
                self.keywords = KwS(*cats)
            else:
                self.keywords = KwS(cats)
        except KeyError:
            if _kws:
                self.keywords = _kws
            else:
                raise Prophet.NotSet("Categories not found")

        if fnmatch.fnmatch(self.exename, "*kcmshell"):
            self.keywords |= KwS(KDE, Kw("X-KDE-settings"))
Esempio n. 5
0
def _deb2kws(sec, hint):
    """Convert Debian style section/hints entries to an equivalent keyword set"""
    kws = []
    for x in sec.split("/"):
        x = Kw(x)
        if x in _rejs:
            raise Prophet.NotSet("section %s rejected" % x)
        try:
            kws += _secs[x]
        except KeyError:
            pass

    for x in hint.split(","):
        x = Kw(x)
        try:
            kws += _hints[x]
        except KeyError:
            pass

    return KwS(*kws)