blob: fa1a40f1315982915eb800062f0f126f007efe39 [file] [log] [blame]
Bram Moolenaar6463ca22016-02-13 17:04:46 +01001#!/usr/bin/python
2#
3# Server that will communicate over stdin/stderr
4#
5# This requires Python 2.6 or later.
6
7from __future__ import print_function
8import sys
9
10if __name__ == "__main__":
11
12 if len(sys.argv) > 1:
Bram Moolenaarf65333c2016-03-08 18:27:21 +010013 if sys.argv[1].startswith("err"):
14 print(sys.argv[1], file=sys.stderr)
15 sys.stderr.flush()
16 else:
17 print(sys.argv[1])
18 sys.stdout.flush()
Bram Moolenaar6463ca22016-02-13 17:04:46 +010019
20 while True:
21 typed = sys.stdin.readline()
22 if typed.startswith("quit"):
23 print("Goodbye!")
24 sys.stdout.flush()
25 break
Bram Moolenaarc25558b2016-03-03 21:02:23 +010026 if typed.startswith("echo "):
Bram Moolenaar6463ca22016-02-13 17:04:46 +010027 print(typed[5:-1])
28 sys.stdout.flush()
Bram Moolenaare98d1212016-03-08 15:37:41 +010029 if typed.startswith("double "):
Bram Moolenaar9a6e33a2016-02-16 19:25:12 +010030 print(typed[7:-1] + "\nAND " + typed[7:-1])
31 sys.stdout.flush()
Bram Moolenaare98d1212016-03-08 15:37:41 +010032 if typed.startswith("echoerr "):
33 print(typed[8:-1], file=sys.stderr)
34 sys.stderr.flush()
35 if typed.startswith("doubleerr "):
36 print(typed[10:-1] + "\nAND " + typed[10:-1], file=sys.stderr)
37 sys.stderr.flush()
Bram Moolenaar6463ca22016-02-13 17:04:46 +010038