allow to select database (central or local) when starting
This commit is contained in:
28
feeder.py
28
feeder.py
@ -7,10 +7,22 @@ from seinflux import SEHistory
|
||||
from servicemanager import FrappyManager
|
||||
|
||||
|
||||
def main():
|
||||
USAGE = """
|
||||
Usage:
|
||||
start server
|
||||
|
||||
python feeder.py [<db instance>]
|
||||
|
||||
add a SECoP connection:
|
||||
|
||||
python feeder.py + uri [device] [instrument]
|
||||
"""
|
||||
|
||||
|
||||
def main(dbname=None):
|
||||
# egen = EventStream(ScanReply(), ScanStream(), n=NicosStream('localhost:14002'))
|
||||
egen = EventStream(ScanReply(), ScanStream())
|
||||
db = SEHistory(access='write')
|
||||
db = SEHistory(dbname, access='write')
|
||||
db.enable_write_access()
|
||||
|
||||
fm = FrappyManager()
|
||||
@ -23,8 +35,9 @@ def main():
|
||||
port = fm.info.get(ins, {}).get(service, {})
|
||||
if port:
|
||||
uri = f'{host}:{port}'
|
||||
print('CREATE', uri, cfginfo.get((ins, service)))
|
||||
print('CREATE', uri, ins, cfginfo.get((ins, service)))
|
||||
TrySecopConnect(uri)
|
||||
db.set_instrument(uri, ins)
|
||||
|
||||
event_map = {'value': db.add_float, 'error': db.add_error, 'stream': db.add_stream}
|
||||
|
||||
@ -39,7 +52,12 @@ def main():
|
||||
db.disconnect()
|
||||
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
send_fake_udp(*sys.argv[1:])
|
||||
if len(sys.argv) == 2:
|
||||
main(sys.argv[1])
|
||||
elif len(sys.argv) > 2:
|
||||
if sys.argv[1] == '+':
|
||||
send_fake_udp(*sys.argv[2:])
|
||||
else:
|
||||
print(USAGE)
|
||||
else:
|
||||
main()
|
||||
|
Reference in New Issue
Block a user