diff -u -r -N sugar-0.94.1.orig/src/jarabe/journal/misc.py sugar-0.94.1/src/jarabe/journal/misc.py
old
|
new
|
|
1 | 1 | # Copyright (C) 2007, One Laptop Per Child |
2 | 2 | # Copyright (C) 2010, Paraguay Educa <tecnologia@paraguayeduca.org> |
| 3 | # Copyright (C) 2012, Plan Ceibal <comunidad@plan.ceibal.edu.uy> |
3 | 4 | # |
4 | 5 | # This program is free software; you can redistribute it and/or modify |
5 | 6 | # it under the terms of the GNU General Public License as published by |
… |
… |
|
323 | 324 | return serial_number |
324 | 325 | |
325 | 326 | def get_xo_serial(): |
326 | | path = '/ofw/serial-number' |
| 327 | _ofw_serial = '/ofw/serial-number' |
| 328 | _proc_serial = '/proc/device-tree/serial-number' |
327 | 329 | |
328 | | if os.access(path, os.R_OK) == 0: |
| 330 | serial = None |
| 331 | if os.path.exists(_ofw_serial): |
| 332 | serial = read_file(_ofw_serial) |
| 333 | elif os.path.exists(_proc_serial): |
| 334 | serial = read_file(_proc_serial) |
| 335 | return serial |
| 336 | |
| 337 | def read_file(path): |
| 338 | if os.access(path, os.R_OK) == 0: |
329 | 339 | return None |
330 | 340 | |
331 | 341 | file_descriptor = open(path, 'r') |
332 | 342 | content = file_descriptor.read() |
333 | 343 | file_descriptor.close() |
334 | | |
335 | 344 | if content: |
336 | | return content.strip() |
337 | | else: |
| 345 | content = content.strip('\n') |
| 346 | return content |
| 347 | else: |
338 | 348 | logging.error('No serial number at %s', path) |
339 | 349 | return None |
340 | 350 | |
| 351 | |
341 | 352 | def get_nick(): |
342 | 353 | client = gconf.client_get_default() |
343 | 354 | return client.get_string("/desktop/sugar/user/nick") |