Debian Codegraph @

tests/data/pk-client-helper-test.py

raw
1 #!/usr/bin/env python3
2 # Licensed under the GNU General Public License Version 2
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 #
18 # Copyright (C) 2010 Richard Hughes <[email protected]>
19
20 import sys
21
22 def main():
23 while True:
24 try:
25 line = sys.stdin.readline().strip('\n')
26 except IOError as e:
27 print("could not read from stdin: %s", str(e))
28 break
29 except KeyboardInterrupt as e:
30 print("process was killed by ctrl-c", str(e))
31 break
32 if not line or line == 'exit':
33 break
34 if line == 'ping':
35 sys.stdout.write('pong\n')
36 sys.stdout.flush()
37 else:
38 sys.stdout.write("you said to me: %s\n" % line)
39 sys.stdout.flush()
40
41 if __name__ == "__main__":
42 main()