Verified Commit 2e9f0a0e authored by Martin Petráček's avatar Martin Petráček
Browse files

connect to pakond

parent 5c359054
import socket
import sys
class pakond_reader():
def __init__(self):
self.buffer = ""
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
def connect(self, socket_path):
def read_line(self):
while '\n' not in self.buffer:
data = self.socket.recv(2048)
self.buffer += data.decode('utf-8','ignore')
(line, self.buffer) = self.buffer.split("\n", 1)
return line
def main():
r = pakond_reader()
except socket.error, msg:
print >>sys.stderr, "Can't connect to pakond. Is it running?"
print >>sys.stderr, msg
while True:
data = r.read_line()
print data
if __name__ == "__main__":
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment