1 |
Author: zmedico |
2 |
Date: 2008-09-13 18:10:15 +0000 (Sat, 13 Sep 2008) |
3 |
New Revision: 11510 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/news.py |
7 |
Log: |
8 |
Bug #237526 - Use portage.util.grablines() for exception handling when |
9 |
reading the unread file. |
10 |
|
11 |
|
12 |
Modified: main/trunk/pym/portage/news.py |
13 |
=================================================================== |
14 |
--- main/trunk/pym/portage/news.py 2008-09-13 17:38:40 UTC (rev 11509) |
15 |
+++ main/trunk/pym/portage/news.py 2008-09-13 18:10:15 UTC (rev 11510) |
16 |
@@ -10,7 +10,8 @@ |
17 |
import errno |
18 |
import os |
19 |
import re |
20 |
-from portage.util import ensure_dirs, apply_permissions, normalize_path, grabfile, write_atomic |
21 |
+from portage.util import apply_permissions, ensure_dirs, grabfile, \ |
22 |
+ grablines, normalize_path, write_atomic |
23 |
from portage.data import portage_gid |
24 |
from portage.locks import lockfile, unlockfile |
25 |
from portage.exception import OperationNotPermitted |
26 |
@@ -141,19 +142,9 @@ |
27 |
if os.access(os.path.dirname(unreadfile), os.W_OK): |
28 |
# TODO: implement shared readonly locks |
29 |
unread_lock = lockfile(unreadfile) |
30 |
- try: |
31 |
- f = open(unreadfile) |
32 |
- try: |
33 |
- unread = f.readlines() |
34 |
- finally: |
35 |
- f.close() |
36 |
- except EnvironmentError, e: |
37 |
- if e.errno != errno.ENOENT: |
38 |
- raise |
39 |
- del e |
40 |
- return 0 |
41 |
- if len(unread): |
42 |
- return len(unread) |
43 |
+ |
44 |
+ return len(grablines(unreadfile)) |
45 |
+ |
46 |
finally: |
47 |
if unread_lock: |
48 |
unlockfile(unread_lock) |