dummyssh
35 lines
| 916 B
| text/plain
|
TextLexer
/ tests / dummyssh
|
r46434 | #!/usr/bin/env python3 | ||
|
r14186 | |||
|
r29159 | from __future__ import absolute_import | ||
import os | ||||
r48441 | import shlex | |||
r48440 | import subprocess | |||
|
r14186 | import sys | ||
os.chdir(os.getenv('TESTTMP')) | ||||
if sys.argv[1] != "user@dummy": | ||||
sys.exit(-1) | ||||
|
r31007 | os.environ["SSH_CLIENT"] = "%s 1 2" % os.environ.get('LOCALIP', '127.0.0.1') | ||
|
r14186 | |||
log = open("dummylog", "ab") | ||||
|
r35588 | log.write(b"Got arguments") | ||
|
r14186 | for i, arg in enumerate(sys.argv[1:]): | ||
|
r36138 | log.write(b" %d:%s" % (i + 1, arg.encode('latin1'))) | ||
log.write(b"\n") | ||||
|
r14186 | log.close() | ||
|
r15768 | hgcmd = sys.argv[2] | ||
if os.name == 'nt': | ||||
# hack to make simple unix single quote quoting work on windows | ||||
hgcmd = hgcmd.replace("'", '"') | ||||
r48441 | cmds = shlex.split(hgcmd) | |||
if cmds[0].endswith('.py'): | ||||
python_exe = os.environ['PYTHON'] | ||||
cmds.insert(0, python_exe) | ||||
hgcmd = shlex.join(cmds) | ||||
# shlex generate windows incompatible string... | ||||
hgcmd = hgcmd.replace("'", '"') | ||||
r48440 | r = subprocess.call(hgcmd, shell=True) | |||
|
r14186 | sys.exit(bool(r)) | ||