blob: 295f311521050f177978984818a383cb265fa92b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017, NORDUnet A/S.
# See LICENSE for licensing information.
import socket
import sys
import signal
def send_message(plopcontrolfile, message):
plopcontrolport = int(open(plopcontrolfile).read())
print >>sys.stderr, "plopcontrolport", plopcontrolport
s = socket.socket(socket.AF_INET)
print >>sys.stderr, "opened socket"
s.connect(("127.0.0.1", plopcontrolport))
print >>sys.stderr, "connected, sending message", message
s.sendall(message + "\n")
print >>sys.stderr, "sent message"
data = ""
while "\n" not in data:
data = data + s.recv(1024)
print >>sys.stderr, "received data"
data = data.rstrip("\n")
print >>sys.stderr, "received all data"
s.close()
return data
def main():
signal.alarm(5)
reply = send_message(sys.argv[1], sys.argv[2])
print reply
if __name__ == '__main__':
main()
|