Commit 47dbb015 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Fixed asyncio reader. Added -n to ssh command.

parent 7adc50e8
...@@ -75,10 +75,22 @@ class LOG: ...@@ -75,10 +75,22 @@ class LOG:
self.decode = decode self.decode = decode
def __call__(self, flush=False): def __call__(self):
with self.mutex: with self.mutex:
buf = os.read(self.fd, 4096)
self.buf.extend(buf)
while True: while True:
buf = os.read(self.fd, 10) i = self.buf.find(b'\n')
if i < 0: break
self.log.MESSAGE(self.decode(self.buf[0:i]),
level=level)
self.buf = self.buf[i+1:]
def flush(self):
with self.mutex:
while True:
buf = os.read(self.fd, 4096)
if len(buf) == 0: break if len(buf) == 0: break
self.buf.extend(buf) self.buf.extend(buf)
while True: while True:
...@@ -87,8 +99,8 @@ class LOG: ...@@ -87,8 +99,8 @@ class LOG:
self.log.MESSAGE(self.decode(self.buf[0:i]), self.log.MESSAGE(self.decode(self.buf[0:i]),
level=level) level=level)
self.buf = self.buf[i+1:] self.buf = self.buf[i+1:]
if len(self.buf) > 0 and flush: if len(self.buf) > 0:
self.log.MESSAGE(self.decode(self.buf), level=level) self.log.MESSAGE(self.decode(self.buf), level=level)
class MakeFile: class MakeFile:
def __init__(self, log): def __init__(self, log):
...@@ -102,5 +114,6 @@ class LOG: ...@@ -102,5 +114,6 @@ class LOG:
def __del__(self): def __del__(self):
loop.remove_reader(self.rpipe) loop.remove_reader(self.rpipe)
os.close(self.wpipe) os.close(self.wpipe)
self.reader(flush=True) self.reader.flush()
return MakeFile(self) return MakeFile(self)
...@@ -156,7 +156,7 @@ class Client: ...@@ -156,7 +156,7 @@ class Client:
log=self.server_log) log=self.server_log)
socket_path = '/tmp/%s_client' % (self.uuid) socket_path = '/tmp/%s_client' % (self.uuid)
cmd = ( cmd = (
[ 'ssh', self.entry.mount.host ] + [ 'ssh', '-n', self.entry.mount.host ] +
( self.options.user and ( self.options.user and
[ '-l', self.options.user ] or []) + [ '-l', self.options.user ] or []) +
( self.options.identity and ( self.options.identity and
......
Markdown is supported
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