Ticket #1976: SL1976.patch

File SL1976.patch, 2.3 KB (added by martin.langhoff, 10 years ago)
  • src/jarabe/desktop/schoolserver.py

    diff --git a/src/jarabe/desktop/schoolserver.py b/src/jarabe/desktop/schoolserver.py
    index f79711e..4181d84 100644
    a b def generate_serial_number(): 
    4848
    4949    return serial
    5050
    51 def store_identifiers(serial_number, uuid, backup_url):
     51def store_identifiers(serial_number, uuid, backup_url=None):
    5252    """  Stores the serial number, uuid and backup_url
    5353    in the identifier folder inside the profile directory
    5454    so that these identifiers can be used for backup. """
    def store_identifiers(serial_number, uuid, backup_url): 
    6969    uuid_file.write(uuid)
    7070    uuid_file.close()
    7171
    72     if os.path.exists(os.path.join(identifier_path, 'backup_url')):
    73         os.remove(os.path.join(identifier_path, 'backup_url'))
    74     backup_url_file = open(os.path.join(identifier_path, 'backup_url'), 'w')
    75     backup_url_file.write(backup_url)
    76     backup_url_file.close()
     72    if backup_url:
     73        if os.path.exists(os.path.join(identifier_path, 'backup_url')):
     74            os.remove(os.path.join(identifier_path, 'backup_url'))
     75        backup_url_file = open(os.path.join(identifier_path, 'backup_url'), 'w')
     76        backup_url_file.write(backup_url)
     77        backup_url_file.close()
    7778
    7879class RegisterError(Exception):
    7980    pass
    def register_laptop(url=REGISTER_URL): 
    108109        sn = sn or 'SHF00000000'
    109110        uuid_ = uuid_ or '00000000-0000-0000-0000-000000000000'
    110111    else:
    111         sn = generate_serial_number()
    112         uuid_ = str(uuid.uuid1())
    113 
    114     setting_name = '/desktop/sugar/collaboration/jabber_server'
    115     jabber_server = client.get_string(setting_name)
    116     store_identifiers(sn, uuid_, jabber_server)
    117 
    118     if jabber_server:
    119         url = 'http://' + jabber_server + ':8080/'
     112        identifier_path = os.path.join(env.get_profile_path(), 'identifiers')
     113        newids = False
     114        try:
     115            sn = open(os.path.join(identifier_path, 'sn')).read()
     116        except:
     117            sn = generate_serial_number()
     118            newids = True
     119        try:
     120            uuid_ = open(os.path.join(identifier_path, 'sn')).read()
     121        except:
     122            uuid_ = str(uuid.uuid1())
     123            newids = True
     124        if newids:
     125            store_identifiers(sn, uuid_)
    120126
    121127    nick = client.get_string('/desktop/sugar/user/nick')
    122128