mirror of
https://github.com/Rudd-O/ansible-qubes.git
synced 2025-03-01 14:22:33 +01:00
Ooooh, Python 3 is upon us.
This commit is contained in:
parent
39a133301b
commit
473d7cdea6
40
bin/qrun
40
bin/qrun
@ -1,6 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/python3 -u
|
||||||
|
|
||||||
import pipes
|
try:
|
||||||
|
from pipes import quote
|
||||||
|
except ImportError:
|
||||||
|
from shlex import quote
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@ -28,16 +31,29 @@ else:
|
|||||||
] + parms
|
] + parms
|
||||||
|
|
||||||
if remotehost:
|
if remotehost:
|
||||||
args = " ".join(pipes.quote(x) for x in parms)
|
args = " ".join(quote(x) for x in parms)
|
||||||
poop = file(path_to_bombshell, "rb").read().encode("hex_codec")
|
with open(path_to_bombshell, "r") as f:
|
||||||
therest_template = ("test -x ./.bombshell-client || "
|
poop = quote(f.read())
|
||||||
"python -c 'import os; file(\"./.bombshell-client\", \"wb\").write(\"%s\".decode(\"hex_codec\")); os.chmod(\"./.bombshell-client\", 0700)' || "
|
therest_template = ('''
|
||||||
"exit 127 ;"
|
set -e
|
||||||
"./.bombshell-client %s %s %s")
|
which bombshell-client >/dev/null 2>&1 && {
|
||||||
therest = therest_template % (poop,
|
exec bombshell-client %s %s %s
|
||||||
"-d" if os.getenv("BOMBSHELL_DEBUG") else "",
|
} || {
|
||||||
pipes.quote(host),
|
echo %s > .bombshell-client.tmp
|
||||||
args)
|
chmod +x .bombshell-client.tmp
|
||||||
|
mv -fT .bombshell-client.tmp .bombshell-client
|
||||||
|
exec ./.bombshell-client %s %s %s
|
||||||
|
}
|
||||||
|
''')
|
||||||
|
therest = therest_template % (
|
||||||
|
"-d" if os.getenv("BOMBSHELL_DEBUG") else "",
|
||||||
|
quote(host),
|
||||||
|
args,
|
||||||
|
poop,
|
||||||
|
"-d" if os.getenv("BOMBSHELL_DEBUG") else "",
|
||||||
|
quote(host),
|
||||||
|
args,
|
||||||
|
)
|
||||||
cmd = [
|
cmd = [
|
||||||
'ssh',
|
'ssh',
|
||||||
'-o', 'BatchMode yes',
|
'-o', 'BatchMode yes',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user