# HG changeset patch # User Erik Grinaker # Date 1090960246 0 # Node ID 5c5c063d3896d6ea8c7f7b8722e2ff2c79ad33cb # Parent 3794d9b384465462491f9ea3fa821f7572c9ba43 check and install configuration on startup diff -r 3794d9b384465462491f9ea3fa821f7572c9ba43 -r 5c5c063d3896d6ea8c7f7b8722e2ff2c79ad33cb ChangeLog --- a/ChangeLog Tue Jul 27 19:14:01 2004 +0000 +++ b/ChangeLog Tue Jul 27 20:30:46 2004 +0000 @@ -9,6 +9,10 @@ * cleaned up the widget code, and added docstrings to all classes, methods and functions + * the configuration is checked on startup, and if not found + the schema is automatically registered with the gconf + daemon + 2004-07-15 Erik Grinaker * when adding an entry the default type is Generic (not Folder) diff -r 3794d9b384465462491f9ea3fa821f7572c9ba43 -r 5c5c063d3896d6ea8c7f7b8722e2ff2c79ad33cb setup.py --- a/setup.py Tue Jul 27 19:14:01 2004 +0000 +++ b/setup.py Tue Jul 27 20:30:46 2004 +0000 @@ -10,7 +10,7 @@ description = 'Password manager for GNOME 2', author = 'Erik Grinaker', author_email = 'erikg@wired-networks.net', - url = 'http://oss.wired-networks.net/revelation/', + url = 'http://oss.codepoet.no/revelation/', packages = [ 'revelation', 'revelation.datahandler' ], package_dir = { 'revelation' : 'src/lib' }, diff -r 3794d9b384465462491f9ea3fa821f7572c9ba43 -r 5c5c063d3896d6ea8c7f7b8722e2ff2c79ad33cb src/lib/data.py --- a/src/lib/data.py Tue Jul 27 19:14:01 2004 +0000 +++ b/src/lib/data.py Tue Jul 27 20:30:46 2004 +0000 @@ -68,6 +68,11 @@ self.callbacks = {} self.client = gconf.client_get_default() + + # check if config is nice, otherwise install the schema + if self.check() == gtk.FALSE and self.install_schema() == gtk.FALSE: + raise ConfigError + self.client.add_dir(self.basedir, gconf.CLIENT_PRELOAD_NONE) @@ -160,6 +165,20 @@ widget.connect("unrealize", self.__cb_bind_unrealize, id) + def check(self): + "Checks if the configuration is available" + + try: + self.get("view/window-width") + self.get("file/autoload_file") + + except ConfigError: + return gtk.FALSE + + else: + return gtk.TRUE + + def get(self, key): "Looks up a config value" @@ -178,6 +197,17 @@ return value.get_bool() + def install_schema(self): + "Attempts to install the Revelation configuration schema" + + if not revelation.io.file_exists("/etc/gconf/schemas/revelation.schemas"): + return gtk.FALSE + + revelation.io.execute("gconftool-2 --install-schema-file=/etc/gconf/schemas/revelation.schemas") + + return self.check() + + def notify_add(self, key, callback, data = None): "Adds a callback for a key change" diff -r 3794d9b384465462491f9ea3fa821f7572c9ba43 -r 5c5c063d3896d6ea8c7f7b8722e2ff2c79ad33cb src/lib/io.py --- a/src/lib/io.py Tue Jul 27 19:14:01 2004 +0000 +++ b/src/lib/io.py Tue Jul 27 20:30:46 2004 +0000 @@ -123,6 +123,20 @@ raise IOError +def execute(command, input = None): + "Runs a command, returns its status code and output" + + p = os.popen(command) + + if input is not None: + p.write(input) + + output = p.read() + status = p.close() + + return output, status + + def file_exists(file): "Checks if a file exists" diff -r 3794d9b384465462491f9ea3fa821f7572c9ba43 -r 5c5c063d3896d6ea8c7f7b8722e2ff2c79ad33cb src/lib/widget.py --- a/src/lib/widget.py Tue Jul 27 19:14:01 2004 +0000 +++ b/src/lib/widget.py Tue Jul 27 20:30:46 2004 +0000 @@ -673,7 +673,7 @@ self.entry = Entry() self.pack_start(self.entry) - self.button = gtk.Button("Browse...", self.__cb_filesel) + self.button = Button("Browse...", self.__cb_filesel) self.pack_start(self.button, gtk.FALSE, gtk.FALSE) if filename is not None: diff -r 3794d9b384465462491f9ea3fa821f7572c9ba43 -r 5c5c063d3896d6ea8c7f7b8722e2ff2c79ad33cb src/revelation --- a/src/revelation Tue Jul 27 19:14:01 2004 +0000 +++ b/src/revelation Tue Jul 27 20:30:46 2004 +0000 @@ -46,6 +46,7 @@ os.umask(0077) self.__init_facilities() + self.__init_toolbar() self.__init_menu() self.__init_mainarea() @@ -66,7 +67,18 @@ def __init_facilities(self): "Sets up various application facilities" - self.config = revelation.data.Config() + try: + self.config = revelation.data.Config() + + except revelation.data.ConfigError: + revelation.dialog.Error( + None, "Configuration error", + "The Revelation configuration data could not be found in gconf. This indicates a fault in your installation, please re-install Revelation." + ).run() + + sys.exit(1) + + self.icons = revelation.stock.IconFactory(self) self.data = revelation.data.EntryStore() self.clipboard = revelation.data.EntryClipboard()