1 |
Author: zmedico |
2 |
Date: 2009-09-05 22:01:43 +0000 (Sat, 05 Sep 2009) |
3 |
New Revision: 14201 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/_emerge/main.py |
7 |
main/trunk/pym/portage/__init__.py |
8 |
main/trunk/pym/portage/elog/mod_mail_summary.py |
9 |
main/trunk/pym/portage/elog/mod_save.py |
10 |
main/trunk/pym/portage/glsa.py |
11 |
Log: |
12 |
Use _unicode_decode() on the string returned from time.strftime(), in order |
13 |
to avoid a potential UnicodeDecodeError later. Thanks to Markus Duft |
14 |
<mduft@g.o> for reporting. |
15 |
|
16 |
|
17 |
Modified: main/trunk/pym/_emerge/main.py |
18 |
=================================================================== |
19 |
--- main/trunk/pym/_emerge/main.py 2009-09-05 13:36:07 UTC (rev 14200) |
20 |
+++ main/trunk/pym/_emerge/main.py 2009-09-05 22:01:43 UTC (rev 14201) |
21 |
@@ -9,6 +9,8 @@ |
22 |
import platform |
23 |
import portage |
24 |
from portage import os |
25 |
+from portage import _encodings |
26 |
+from portage import _unicode_decode |
27 |
import _emerge.help |
28 |
import portage.xpak, commands, errno, re, time |
29 |
from portage.output import colorize, xtermTitle, xtermTitleReset |
30 |
@@ -1297,7 +1299,9 @@ |
31 |
|
32 |
if not "--pretend" in myopts: |
33 |
emergelog(xterm_titles, "Started emerge on: "+\ |
34 |
- time.strftime("%b %d, %Y %H:%M:%S", time.localtime())) |
35 |
+ _unicode_decode( |
36 |
+ time.strftime("%b %d, %Y %H:%M:%S", time.localtime()), |
37 |
+ encoding=_encodings['content'], errors='replace')) |
38 |
myelogstr="" |
39 |
if myopts: |
40 |
myelogstr=" ".join(myopts) |
41 |
|
42 |
Modified: main/trunk/pym/portage/__init__.py |
43 |
=================================================================== |
44 |
--- main/trunk/pym/portage/__init__.py 2009-09-05 13:36:07 UTC (rev 14200) |
45 |
+++ main/trunk/pym/portage/__init__.py 2009-09-05 22:01:43 UTC (rev 14201) |
46 |
@@ -6267,8 +6267,9 @@ |
47 |
logid_path = os.path.join(mysettings["PORTAGE_BUILDDIR"], ".logid") |
48 |
if not os.path.exists(logid_path): |
49 |
open(_unicode_encode(logid_path), 'w') |
50 |
- logid_time = time.strftime("%Y%m%d-%H%M%S", |
51 |
- time.gmtime(os.stat(logid_path).st_mtime)) |
52 |
+ logid_time = _unicode_decode(time.strftime("%Y%m%d-%H%M%S", |
53 |
+ time.gmtime(os.stat(logid_path).st_mtime)), |
54 |
+ encoding=_encodings['content'], errors='replace') |
55 |
mysettings["PORTAGE_LOG_FILE"] = os.path.join( |
56 |
mysettings["PORT_LOGDIR"], "%s:%s:%s.log" % \ |
57 |
(mysettings["CATEGORY"], mysettings["PF"], logid_time)) |
58 |
|
59 |
Modified: main/trunk/pym/portage/elog/mod_mail_summary.py |
60 |
=================================================================== |
61 |
--- main/trunk/pym/portage/elog/mod_mail_summary.py 2009-09-05 13:36:07 UTC (rev 14200) |
62 |
+++ main/trunk/pym/portage/elog/mod_mail_summary.py 2009-09-05 22:01:43 UTC (rev 14201) |
63 |
@@ -8,6 +8,8 @@ |
64 |
from portage.localization import _ |
65 |
from portage.util import writemsg |
66 |
from portage import os |
67 |
+from portage import _encodings |
68 |
+from portage import _unicode_decode |
69 |
|
70 |
import socket |
71 |
import time |
72 |
@@ -15,8 +17,11 @@ |
73 |
_items = {} |
74 |
def process(mysettings, key, logentries, fulltext): |
75 |
global _items |
76 |
+ time_str = _unicode_decode( |
77 |
+ time.strftime("%Y%m%d-%H%M%S %Z", time.localtime(time.time())), |
78 |
+ encoding=_encodings['content'], errors='replace') |
79 |
header = _(">>> Messages generated for package %(pkg)s by process %(pid)d on %(time)s:\n\n") % \ |
80 |
- {"pkg": key, "pid": os.getpid(), "time": time.strftime("%Y%m%d-%H%M%S %Z", time.localtime(time.time()))} |
81 |
+ {"pkg": key, "pid": os.getpid(), "time": time_str} |
82 |
config_root = mysettings["PORTAGE_CONFIGROOT"] |
83 |
mysettings, items = _items.setdefault(config_root, (mysettings, {})) |
84 |
items[key] = header + fulltext |
85 |
|
86 |
Modified: main/trunk/pym/portage/elog/mod_save.py |
87 |
=================================================================== |
88 |
--- main/trunk/pym/portage/elog/mod_save.py 2009-09-05 13:36:07 UTC (rev 14200) |
89 |
+++ main/trunk/pym/portage/elog/mod_save.py 2009-09-05 22:01:43 UTC (rev 14201) |
90 |
@@ -7,6 +7,7 @@ |
91 |
import time |
92 |
from portage import os |
93 |
from portage import _encodings |
94 |
+from portage import _unicode_decode |
95 |
from portage import _unicode_encode |
96 |
from portage.data import portage_uid, portage_gid |
97 |
from portage.util import ensure_dirs |
98 |
@@ -20,7 +21,9 @@ |
99 |
elogdir = os.path.join(os.sep, "var", "log", "portage", "elog") |
100 |
ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=02770) |
101 |
|
102 |
- elogfilename = elogdir+"/"+path+":"+time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time()))+".log" |
103 |
+ elogfilename = os.path.join(elogdir, path + ":" + _unicode_decode( |
104 |
+ time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time())), |
105 |
+ encoding=_encodings['content'], errors='replace') + ".log") |
106 |
elogfile = codecs.open(_unicode_encode(elogfilename, |
107 |
encoding=_encodings['fs'], errors='strict'), |
108 |
mode='w', encoding=_encodings['content'], errors='backslashreplace') |
109 |
|
110 |
Modified: main/trunk/pym/portage/glsa.py |
111 |
=================================================================== |
112 |
--- main/trunk/pym/portage/glsa.py 2009-09-05 13:36:07 UTC (rev 14200) |
113 |
+++ main/trunk/pym/portage/glsa.py 2009-09-05 22:01:43 UTC (rev 14201) |
114 |
@@ -404,7 +404,8 @@ |
115 |
return datestr |
116 |
|
117 |
# TODO We could format to local date format '%x' here? |
118 |
- return d.strftime("%B %d, %Y") |
119 |
+ return _unicode_decode(d.strftime("%B %d, %Y"), |
120 |
+ encoding=_encodings['content'], errors='replace') |
121 |
|
122 |
# simple Exception classes to catch specific errors |
123 |
class GlsaTypeException(Exception): |