From f939baec056a458fcab040106e4a295e783a43b9 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Wed, 16 Sep 2009 16:44:42 +0000 Subject: Error while initiating .sugar environment #1327 --- diff --git a/src/sugar/profile.py b/src/sugar/profile.py index e5f5dc7..3ea1e67 100644 --- a/src/sugar/profile.py +++ b/src/sugar/profile.py @@ -53,6 +53,9 @@ class Profile(object): self._pubkey = None self._privkey_hash = None + self.pubkey = self._load_pubkey() + self.privkey_hash = self._hash_private_key() + def is_valid(self): client = gconf.client_get_default() nick = client.get_string("/desktop/sugar/user/nick") @@ -65,6 +68,10 @@ class Profile(object): def _load_pubkey(self): key_path = os.path.join(env.get_profile_path(), 'owner.key.pub') + + if not os.path.exists(key_path): + return None + try: f = open(key_path, "r") lines = f.readlines() @@ -83,14 +90,12 @@ class Profile(object): logging.error("Error parsing public key.") return None - def _get_pubkey(self): - # load on-demand. - if not self._pubkey: - self._pubkey = self._load_pubkey() - return self._pubkey - def _hash_private_key(self): key_path = os.path.join(env.get_profile_path(), 'owner.key') + + if not os.path.exists(key_path): + return None + try: f = open(key_path, "r") lines = f.readlines() @@ -115,15 +120,6 @@ class Profile(object): key_hash = util.sha_data(key) return util.printable_hash(key_hash) - def _get_privkey_hash(self): - # load on-demand. - if not self._privkey_hash: - self._privkey_hash = self._hash_private_key() - return self._privkey_hash - - privkey_hash = property(_get_privkey_hash) - pubkey = property(_get_pubkey) - def convert_profile(self): cp = ConfigParser() path = os.path.join(env.get_profile_path(), 'config') -- cgit v0.9.1