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 | |
| | 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): |
| 328 | 338 | if os.access(path, os.R_OK) == 0: |
| 329 | 339 | return None |
| 330 | 340 | |
| 331 | | file_descriptor = open(path, 'r') |
| 332 | | content = file_descriptor.read() |
| 333 | | file_descriptor.close() |
| 334 | | |
| 335 | | if content: |
| 336 | | return content.strip() |
| | 341 | fd = open(path, 'r') |
| | 342 | value = fd.read() |
| | 343 | fd.close() |
| | 344 | if value: |
| | 345 | value = value.strip('\n') |
| | 346 | return value |
| 337 | 347 | else: |
| 338 | | logging.error('No serial number at %s', path) |
| 339 | 348 | return None |
| 340 | 349 | |
| | 350 | |
| 341 | 351 | def get_nick(): |
| 342 | 352 | client = gconf.client_get_default() |
| 343 | 353 | return client.get_string("/desktop/sugar/user/nick") |