forked from third-party-mirrors/zfs_autobackup
python 2 compat
This commit is contained in:
parent
c682665888
commit
0ce3bf1297
zfs_autobackup
@ -3,6 +3,11 @@ import os
|
||||
import select
|
||||
import shlex
|
||||
|
||||
try:
|
||||
from shlex import quote as cmd_quote
|
||||
except ImportError:
|
||||
from pipes import quote as cmd_quote
|
||||
|
||||
class CmdPipe:
|
||||
"""a pipe of one or more commands. also takes care of utf-8 encoding/decoding and line based parsing"""
|
||||
|
||||
@ -43,7 +48,7 @@ class CmdPipe:
|
||||
ret = ret + "(" + " ".join(item['cmd']) + ")"
|
||||
else:
|
||||
#make it copy-pastable, will make a mess of quotes sometimes, but is correct
|
||||
ret = ret + "(" + " ".join(map(shlex.quote,item['cmd'])) + ")"
|
||||
ret = ret + "(" + " ".join(map(cmd_quote,item['cmd'])) + ")"
|
||||
|
||||
return ret
|
||||
|
||||
|
@ -1,10 +1,15 @@
|
||||
import os
|
||||
import select
|
||||
import subprocess
|
||||
import shlex
|
||||
from zfs_autobackup.CmdPipe import CmdPipe
|
||||
from zfs_autobackup.LogStub import LogStub
|
||||
|
||||
try:
|
||||
from shlex import quote as cmd_quote
|
||||
except ImportError:
|
||||
from pipes import quote as cmd_quote
|
||||
|
||||
|
||||
class ExecuteError(Exception):
|
||||
pass
|
||||
|
||||
@ -62,7 +67,7 @@ class ExecuteNode(LogStub):
|
||||
|
||||
ret.append(self.ssh_to)
|
||||
|
||||
ret.append(" ".join(map(shlex.quote, cmd)))
|
||||
ret.append(" ".join(map(cmd_quote, cmd)))
|
||||
|
||||
return ret
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user