Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-09-16 16:44:42 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-09-16 16:44:42 (GMT)
commitf939baec056a458fcab040106e4a295e783a43b9 (patch)
tree2b025676c1f1a7ca8c5236f1cfdb56e142058663
parentdf89c1bf0b1f0425cb6a6621dbe65770a7856bb1 (diff)
Error while initiating .sugar environment #1327
-rw-r--r--src/sugar/profile.py26
1 files changed, 11 insertions, 15 deletions
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')