Ticket #1327: sugar-1327.3.patch

File sugar-1327.3.patch, 2.2 KB (added by alsroot, 15 years ago)
  • src/sugar/profile.py

    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): 
    5353        self._pubkey = None
    5454        self._privkey_hash = None
    5555
     56        self.pubkey = self._load_pubkey()
     57        self.privkey_hash = self._hash_private_key()
     58
    5659    def is_valid(self):
    5760        client = gconf.client_get_default()
    5861        nick = client.get_string("/desktop/sugar/user/nick")
    class Profile(object): 
    6568
    6669    def _load_pubkey(self):
    6770        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
    6875        try:
    6976            f = open(key_path, "r")
    7077            lines = f.readlines()
    class Profile(object): 
    8390            logging.error("Error parsing public key.")
    8491            return None
    8592
    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 
    9293    def _hash_private_key(self):
    9394        key_path = os.path.join(env.get_profile_path(), 'owner.key')
     95
     96        if not os.path.exists(key_path):
     97            return None
     98
    9499        try:
    95100            f = open(key_path, "r")
    96101            lines = f.readlines()
    class Profile(object): 
    115120        key_hash = util.sha_data(key)
    116121        return util.printable_hash(key_hash)
    117122
    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 
    127123    def convert_profile(self):
    128124        cp = ConfigParser()
    129125        path = os.path.join(env.get_profile_path(), 'config')