Revision eb93b673 lib/utils/io.py
b/lib/utils/io.py | ||
---|---|---|
39 | 39 |
_RANDOM_UUID_FILE = "/proc/sys/kernel/random/uuid" |
40 | 40 |
|
41 | 41 |
|
42 |
def ErrnoOrStr(err): |
|
43 |
"""Format an EnvironmentError exception. |
|
44 |
|
|
45 |
If the L{err} argument has an errno attribute, it will be looked up |
|
46 |
and converted into a textual C{E...} description. Otherwise the |
|
47 |
string representation of the error will be returned. |
|
48 |
|
|
49 |
@type err: L{EnvironmentError} |
|
50 |
@param err: the exception to format |
|
51 |
|
|
52 |
""" |
|
53 |
if hasattr(err, "errno"): |
|
54 |
detail = errno.errorcode[err.errno] |
|
55 |
else: |
|
56 |
detail = str(err) |
|
57 |
return detail |
|
58 |
|
|
59 |
|
|
42 | 60 |
def ReadFile(file_name, size=-1, preread=None): |
43 | 61 |
"""Reads a file. |
44 | 62 |
|
Also available in: Unified diff