blob: d5da687309914098b2d69b2498cfb1b8c4dd399b [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:
13 print(sys.argv[1])
14
15 while True:
16 typed = sys.stdin.readline()
17 if typed.startswith("quit"):
18 print("Goodbye!")
19 sys.stdout.flush()
20 break
Bram Moolenaarc25558b2016-03-03 21:02:23 +010021 if typed.startswith("echo "):
Bram Moolenaar6463ca22016-02-13 17:04:46 +010022 print(typed[5:-1])
23 sys.stdout.flush()
Bram Moolenaare98d1212016-03-08 15:37:41 +010024 if typed.startswith("double "):
Bram Moolenaar9a6e33a2016-02-16 19:25:12 +010025 print(typed[7:-1] + "\nAND " + typed[7:-1])
26 sys.stdout.flush()
Bram Moolenaare98d1212016-03-08 15:37:41 +010027 if typed.startswith("echoerr "):
28 print(typed[8:-1], file=sys.stderr)
29 sys.stderr.flush()
30 if typed.startswith("doubleerr "):
31 print(typed[10:-1] + "\nAND " + typed[10:-1], file=sys.stderr)
32 sys.stderr.flush()
Bram Moolenaar6463ca22016-02-13 17:04:46 +010033