Return object form from `update_pps_conf()`
parent
cbcbb2b243
commit
7b2e8f1ba5
43
piker/pp.py
43
piker/pp.py
|
@ -333,40 +333,33 @@ def get_pps(
|
||||||
brokername: str,
|
brokername: str,
|
||||||
acctids: Optional[set[str]] = set(),
|
acctids: Optional[set[str]] = set(),
|
||||||
|
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, dict[str, Position]]:
|
||||||
'''
|
'''
|
||||||
Read out broker-specific position entries from
|
Read out broker-specific position entries from
|
||||||
incremental update file: ``pps.toml``.
|
incremental update file: ``pps.toml``.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
conf, path = config.load('pps')
|
conf, path = config.load('pps')
|
||||||
brokersection = conf.setdefault(brokername, {})
|
|
||||||
|
|
||||||
all_active = {}
|
all_active = {}
|
||||||
|
|
||||||
# try to load any ledgers if no section found
|
# try to load any ledgers if no section found
|
||||||
if not brokersection:
|
bconf, path = config.load('brokers')
|
||||||
bconf, path = config.load('brokers')
|
accounts = bconf[brokername]['accounts']
|
||||||
accounts = bconf[brokername]['accounts']
|
for account in accounts:
|
||||||
for account in accounts:
|
|
||||||
|
|
||||||
# TODO: instead of this filter we could
|
# TODO: instead of this filter we could
|
||||||
# always send all known pps but just not audit
|
# always send all known pps but just not audit
|
||||||
# them since an active client might not be up?
|
# them since an active client might not be up?
|
||||||
if (
|
if (
|
||||||
acctids and
|
acctids and
|
||||||
f'{brokername}.{account}' not in acctids
|
f'{brokername}.{account}' not in acctids
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
active = update_pps_conf(brokername, account)
|
active = update_pps_conf(brokername, account)
|
||||||
all_active.update(active)
|
all_active.setdefault(account, {}).update(active)
|
||||||
|
|
||||||
# reload pps after ledger updates
|
return all_active
|
||||||
conf, path = config.load('pps')
|
|
||||||
brokersection = conf.setdefault(brokername, {})
|
|
||||||
|
|
||||||
return brokersection
|
|
||||||
|
|
||||||
|
|
||||||
def update_pps_conf(
|
def update_pps_conf(
|
||||||
|
@ -432,6 +425,9 @@ def update_pps_conf(
|
||||||
brokerless_key = fqsn.rstrip(f'.{brokername}')
|
brokerless_key = fqsn.rstrip(f'.{brokername}')
|
||||||
pp_entries[brokerless_key] = pp_dict
|
pp_entries[brokerless_key] = pp_dict
|
||||||
|
|
||||||
|
for fqsn in closed:
|
||||||
|
pp_objs.pop(fqsn, None)
|
||||||
|
|
||||||
conf[brokername][acctid] = pp_entries
|
conf[brokername][acctid] = pp_entries
|
||||||
config.write(
|
config.write(
|
||||||
conf,
|
conf,
|
||||||
|
@ -441,7 +437,8 @@ def update_pps_conf(
|
||||||
# encoder=config.toml.Encoder(preserve=True),
|
# encoder=config.toml.Encoder(preserve=True),
|
||||||
)
|
)
|
||||||
|
|
||||||
return active
|
# deliver object form of all pps in table to caller
|
||||||
|
return pp_objs
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue