add seaman.sea_recorder
+ do_start argument logger=False disables info messages
This commit is contained in:
14
base.py
14
base.py
@ -310,16 +310,22 @@ class ServiceManager:
|
||||
ins_list = self.wildcard(ins)
|
||||
if ins_list is not None:
|
||||
return ins_list
|
||||
if logger is None:
|
||||
class logger:
|
||||
@staticmethod
|
||||
if not logger:
|
||||
if logger is False:
|
||||
def info(fmt, *args):
|
||||
pass
|
||||
else:
|
||||
def info(fmt, *args):
|
||||
print(fmt % args)
|
||||
|
||||
@staticmethod
|
||||
def error(fmt, *args):
|
||||
print(('ERROR: ' + fmt) % args)
|
||||
|
||||
logger = type('Logger', (), {})
|
||||
|
||||
logger.info = info
|
||||
logger.error = error
|
||||
|
||||
if ins is None:
|
||||
logger.info('nothing to start')
|
||||
return
|
||||
|
20
seaman.py
20
seaman.py
@ -26,7 +26,8 @@ import subprocess
|
||||
import psutil
|
||||
import os
|
||||
import re
|
||||
from os.path import join, exists
|
||||
import socket
|
||||
from os.path import join, exists, expanduser
|
||||
from servicemanager.base import ServiceManager, ServiceDown, UsageError
|
||||
|
||||
CFGLINE = re.compile(r'(?:device makeitem (name|stick_name|confirmed) "(.*)" ""'
|
||||
@ -255,3 +256,20 @@ class SeaManager(ServiceManager):
|
||||
if service:
|
||||
result.append(service)
|
||||
return result + extra
|
||||
|
||||
def sea_recorder(self, ins, uris):
|
||||
self.do_start(ins, None, logger=False)
|
||||
port = self.info[ins]['sea']
|
||||
try:
|
||||
conn = socket.create_connection(('localhost', port))
|
||||
uris = ' '.join(uris)
|
||||
conn.send(f'seauser seaser\nconfig listen 1\nsea_recorder {uris}\n'.encode())
|
||||
conn.settimeout(2)
|
||||
prev = b''
|
||||
while True:
|
||||
lines = (prev + conn.recv(999)).split(b'\n')
|
||||
prev = lines.pop()
|
||||
if b'ACTIVE' in lines:
|
||||
break
|
||||
finally:
|
||||
conn.close()
|
||||
|
Reference in New Issue
Block a user