Start work on python bootstrap script
This commit is contained in:
parent
30e635a934
commit
f3407959a6
@ -13,7 +13,7 @@ import tarfile
|
|||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from base64 import standard_b64decode
|
from base64 import standard_b64decode, standard_b64encode
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from getpass import getuser
|
from getpass import getuser
|
||||||
from typing import (
|
from typing import (
|
||||||
@ -323,10 +323,14 @@ def parse_ssh_args(args: List[str]) -> Tuple[List[str], List[str], bool]:
|
|||||||
|
|
||||||
def get_remote_command(remote_args: List[str], hostname: str = 'localhost', interpreter: str = 'sh') -> List[str]:
|
def get_remote_command(remote_args: List[str], hostname: str = 'localhost', interpreter: str = 'sh') -> List[str]:
|
||||||
command_to_execute = ''
|
command_to_execute = ''
|
||||||
|
is_python = 'python' in interpreter.lower()
|
||||||
if remote_args:
|
if remote_args:
|
||||||
# ssh simply concatenates multiple commands using a space see
|
# ssh simply concatenates multiple commands using a space see
|
||||||
# line 1129 of ssh.c and on the remote side sshd.c runs the
|
# line 1129 of ssh.c and on the remote side sshd.c runs the
|
||||||
# concatenated command as shell -c cmd
|
# concatenated command as shell -c cmd
|
||||||
|
if is_python:
|
||||||
|
command_to_execute = standard_b64encode(' '.join(remote_args).encode('utf-8')).decode('ascii')
|
||||||
|
else:
|
||||||
args = [c.replace("'", """'"'"'""") for c in remote_args]
|
args = [c.replace("'", """'"'"'""") for c in remote_args]
|
||||||
command_to_execute = "exec \"$login_shell\" -c '{}'".format(' '.join(args))
|
command_to_execute = "exec \"$login_shell\" -c '{}'".format(' '.join(args))
|
||||||
sh_script = load_script(exec_cmd=command_to_execute)
|
sh_script = load_script(exec_cmd=command_to_execute)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user