From f939baec056a458fcab040106e4a295e783a43b9 Mon Sep 17 00:00:00 2001
From: Aleksey Lim <alsroot@member.fsf.org>
Date: Wed, 16 Sep 2009 16:44:42 +0000
Subject: Error while initiating .sugar environment #1327
---
src/sugar/profile.py | 26 +++++++++++---------------
1 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/src/sugar/profile.py b/src/sugar/profile.py
index e5f5dc7..3ea1e67 100644
a
|
b
|
class Profile(object): |
53 | 53 | self._pubkey = None |
54 | 54 | self._privkey_hash = None |
55 | 55 | |
| 56 | self.pubkey = self._load_pubkey() |
| 57 | self.privkey_hash = self._hash_private_key() |
| 58 | |
56 | 59 | def is_valid(self): |
57 | 60 | client = gconf.client_get_default() |
58 | 61 | nick = client.get_string("/desktop/sugar/user/nick") |
… |
… |
class Profile(object): |
65 | 68 | |
66 | 69 | def _load_pubkey(self): |
67 | 70 | key_path = os.path.join(env.get_profile_path(), 'owner.key.pub') |
| 71 | |
| 72 | if not os.path.exists(key_path): |
| 73 | return None |
| 74 | |
68 | 75 | try: |
69 | 76 | f = open(key_path, "r") |
70 | 77 | lines = f.readlines() |
… |
… |
class Profile(object): |
83 | 90 | logging.error("Error parsing public key.") |
84 | 91 | return None |
85 | 92 | |
86 | | def _get_pubkey(self): |
87 | | # load on-demand. |
88 | | if not self._pubkey: |
89 | | self._pubkey = self._load_pubkey() |
90 | | return self._pubkey |
91 | | |
92 | 93 | def _hash_private_key(self): |
93 | 94 | key_path = os.path.join(env.get_profile_path(), 'owner.key') |
| 95 | |
| 96 | if not os.path.exists(key_path): |
| 97 | return None |
| 98 | |
94 | 99 | try: |
95 | 100 | f = open(key_path, "r") |
96 | 101 | lines = f.readlines() |
… |
… |
class Profile(object): |
115 | 120 | key_hash = util.sha_data(key) |
116 | 121 | return util.printable_hash(key_hash) |
117 | 122 | |
118 | | def _get_privkey_hash(self): |
119 | | # load on-demand. |
120 | | if not self._privkey_hash: |
121 | | self._privkey_hash = self._hash_private_key() |
122 | | return self._privkey_hash |
123 | | |
124 | | privkey_hash = property(_get_privkey_hash) |
125 | | pubkey = property(_get_pubkey) |
126 | | |
127 | 123 | def convert_profile(self): |
128 | 124 | cp = ConfigParser() |
129 | 125 | path = os.path.join(env.get_profile_path(), 'config') |