コード例 #1
0
    def __register_control(self, ctrl):

        items = []

        # it's more secure to use a separate process here
        cmd = os.path.join(HOME, "ctrlinfo")
        fail, out = commands.getstatusoutput("%s %s" % (cmd, ctrl))

        if (fail):
            log("Warning: \"%s\" is an invalid control." % ctrl)
            return None

        else:
            log("Registering new control \"%s\"." % ctrl)

        # cut off initial crap; you never know what controls might do during
        # initialization...
        out = out[out.find("PATH:"):]

        for line in out.splitlines():
            if (":" in line):
                key, value = line.split(":")
                value = vfs.unescape_path(value)
            else:
                key = value = ""

            if (not value in self.__registry):
                self.__registry[value] = []

            items.append((key, value))

        return items
コード例 #2
0
    def __load(self):

        try:
            reg = open(self.__regfile).readlines()
        except:
            reg = []

        for line in reg:
            if not line.strip() or line.startswith("#"):
                continue

            parts = line[:-1].split(" ")
            path = vfs.unescape_path(parts[0])
            items = parts[1:]
            self.__registry[path] = []
            for i in items:
                k, v = i.split(":")
                self.__registry[path].append((k, vfs.unescape_path(v)))
            self.__loaded[path] = True
コード例 #3
0
ファイル: __init__.py プロジェクト: RaumZeit/gdesklets-core
    def __on_file_drop(self, widget, context, x, y, data, info, time):

        files = [uri for uri in data.data.split("\r\n") if uri != '']
        installer = self._get_plugin("Installer_Package")

        if (info == self.__NETSCAPE_URL):
            for f in files:
                f, name = f.splitlines()[0:2]
                installer.install_from(f)
            #end for

        elif (info == self.__TARGET_URL):
            for f in files:
                if (f.startswith("file://")): f = f[7:]
                # filenames are URL-quoted
                installer.install_from(vfs.unescape_path(f))
コード例 #4
0
        except IndexError, exc:
            log("The displaylist file has wrong format, ignoring it.")
            return

        self.__profiles[self.__current_profile] = []

        for line in data:
            if (not line): continue

            try:
                ident, path, profile = line.split()
            except ValueError, exc:
                log("The displaylist file has wrong format, ignoring it.")
                return

            path = vfs.unescape_path(path)
            profile = vfs.unescape_path(profile)
            if (not profile in self.__profiles):
                self.__profiles[profile] = []
            self.__profiles[profile].append(ident)

            self.__path_table[ident] = path
            self.__profiles_table[ident] = profile



    #
    # Saves the display list to file.
    #
    def __save_list(self):