示例#1
0
    def __save_list(self):

        data = [self.__current_profile + "\n"]
        for profile, idents in self.__profiles.items():
            for ident in idents:
                path = self.__path_table[ident]
                path = vfs.escape_path(path)
                profile = vfs.escape_path(profile)
                data.append("%s %s %s\n" % (ident, path, profile))

        try:
            open(self.__display_list, "w").writelines(data)
        except IOError, exc:
            log("Could not open file \"%s\" for writing data!\n%s\n"
                % (self.__display_list, exc))
示例#2
0
    def __save(self):

        fd = open(self.__regfile, "w")
        fd.write(
            "# This autogenerated file acts as a cache. Removing this file "
            "will result in a\n"
            "# longer startup time.\n\n"
        )

        for path, items in self.__registry.items():
            if not os.path.exists(path):
                continue
            data = map(lambda item: "%s:%s" % (item[0], vfs.escape_path(item[1])), items)
            fd.write("%s %s\n" % (vfs.escape_path(path), " ".join(data)))

        fd.close()
示例#3
0
import sys
import utils
import gtk
from utils import vfs


# gDesklets home paths
HOME = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
USERHOME = os.path.join(os.path.expanduser("~"), ".gdesklets")
OLDHOME = os.path.join(HOME, os.pardir, os.pardir, "share", "gdesklets")

# we need the DISPLAY variable
try:
    # Use gtk's get_name() to return a string containing the screen number (in
    # case the DISPLAY variable doesn't contain the screen number)
    DISPLAY = vfs.escape_path(gtk.gdk.Display(os.environ["DISPLAY"]).get_name()).replace("/", "_")
except:
    try:
        print >> sys.stderr, "Error: could not open display", os.environ["DISPLAY"]
    except:
        print >> sys.stderr, "(could not get DISPLAY environment variable)"
    DISPLAY = "0"


# the name of the purge key
PURGE_KEY = "_paths_to_purge_"

# for unset coordinates
UNSET_COORD = -1000

# paths where the display files are located