import time
from portage import os
from portage import _encodings
+from portage import _unicode_decode
from portage import _unicode_encode
from portage.data import portage_uid, portage_gid
from portage.localization import _
encoding=_encodings['fs'], errors='strict'),
mode='a', encoding=_encodings['content'], errors='backslashreplace')
apply_permissions(elogfilename, mode=060, mask=0)
+ time_str = time.strftime("%Y-%m-%d %H:%M:%S %Z",
+ time.localtime(time.time()))
+ # Avoid potential UnicodeDecodeError later.
+ time_str = _unicode_decode(time_str,
+ encoding=_encodings['content'], errors='replace')
elogfile.write(_(">>> Messages generated by process %(pid)d on %(time)s for package %(pkg)s:\n\n") %
- {"pid": os.getpid(), "time": time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime(time.time())), "pkg": key})
+ {"pid": os.getpid(), "time": time_str, "pkg": key})
elogfile.write(fulltext)
elogfile.write("\n")
elogfile.close()