summaryrefslogtreecommitdiff
path: root/shellutils.py
diff options
context:
space:
mode:
authorEmile Anclin <emile.anclin@logilab.fr>2010-09-21 15:25:09 +0200
committerEmile Anclin <emile.anclin@logilab.fr>2010-09-21 15:25:09 +0200
commit4ceefe71e176b38d333cc54597bc9427ea842f75 (patch)
tree960eceedad69ecd3e1df9f9c709acba42cb979ee /shellutils.py
parent4619682b0138bf6cff28530a8a0af29f2bcc8749 (diff)
downloadlogilab-common-4ceefe71e176b38d333cc54597bc9427ea842f75.tar.gz
[py3k] compat: add str_to_bytes and str_encode
In py3k, things are different: we will sometimes need to convert str to bytes if we want to write data into a file; and on other times we don't need to encode str to something
Diffstat (limited to 'shellutils.py')
-rw-r--r--shellutils.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/shellutils.py b/shellutils.py
index 2f6e85a..7d971e1 100644
--- a/shellutils.py
+++ b/shellutils.py
@@ -33,6 +33,7 @@ from os.path import exists, isdir, islink, basename, join
from logilab.common import STD_BLACKLIST, _handle_blacklist
from logilab.common.compat import raw_input
+from logilab.common.compat import str_to_bytes
try:
from logilab.common.proc import ProcInfo, NoSuchProcess
@@ -247,7 +248,7 @@ def acquire_lock(lock_file, max_try=10, delay=10, max_delay=3600):
while count:
try:
fd = os.open(lock_file, os.O_EXCL | os.O_RDWR | os.O_CREAT)
- os.write(fd, str(os.getpid()))
+ os.write(fd, str_to_bytes(str(os.getpid())) )
os.close(fd)
return True
except OSError, e: