diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/modules/subprocess/test/xpcshell/data_test_script.py | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/modules/subprocess/test/xpcshell/data_test_script.py')
-rw-r--r-- | toolkit/modules/subprocess/test/xpcshell/data_test_script.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/toolkit/modules/subprocess/test/xpcshell/data_test_script.py b/toolkit/modules/subprocess/test/xpcshell/data_test_script.py new file mode 100644 index 000000000..035d8ac56 --- /dev/null +++ b/toolkit/modules/subprocess/test/xpcshell/data_test_script.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python2 +from __future__ import print_function + +import os +import signal +import struct +import sys + + +def output(line): + sys.stdout.write(struct.pack('@I', len(line))) + sys.stdout.write(line) + sys.stdout.flush() + + +def echo_loop(): + while True: + line = sys.stdin.readline() + if not line: + break + + output(line) + + +if sys.platform == "win32": + import msvcrt + msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) + + +cmd = sys.argv[1] +if cmd == 'echo': + echo_loop() +elif cmd == 'exit': + sys.exit(int(sys.argv[2])) +elif cmd == 'env': + for var in sys.argv[2:]: + output(os.environ.get(var, '')) +elif cmd == 'pwd': + output(os.path.abspath(os.curdir)) +elif cmd == 'print_args': + for arg in sys.argv[2:]: + output(arg) +elif cmd == 'ignore_sigterm': + signal.signal(signal.SIGTERM, signal.SIG_IGN) + + output('Ready') + while True: + try: + signal.pause() + except AttributeError: + import time + time.sleep(3600) +elif cmd == 'print': + sys.stdout.write(sys.argv[2]) + sys.stderr.write(sys.argv[3]) |