mdavidsaver / pvxs

PVA protocol client/server library and utilities.
https://mdavidsaver.github.io/pvxs/
Other
19 stars 25 forks source link

Feature request: `python -m pvxslibs.ioc` #49

Open coretl opened 1 year ago

coretl commented 1 year ago

I have monkeypatched this like so:

import ctypes
import os

import pvxslibs.path
from epicscorelibs import ioc
from setuptools_dso.runtime import find_dso

pvxsIoc = ctypes.CDLL(find_dso("pvxslibs.lib.pvxsIoc"), ctypes.RTLD_GLOBAL)
os.environ.setdefault("PVXS_QSRV_ENABLE", "YES")

orig_dbld = ioc.dbLoadDatabase

def dbLoadDatabase(dbd, dbdpath, substitutions):
    if dbd == b"qsrv.dbd":
        orig_dbld(b"pvxsIoc.dbd", pvxslibs.path.dbd_path.encode(), None)
    elif dbd == b"PVAServerRegister.dbd":
        pass
    else:
        orig_dbld(dbd, dbdpath, substitutions)

ioc.dbLoadDatabase = dbLoadDatabase

if __name__ == "__main__":
    ioc.main()

But obviously this is a hack.

Maybe the best way to support this is to pass in a list of tuples of (dbd, dbdpath) to epicscorelibs.ioc.main, defaulting to the existing qsrv.dbd and PVAServerRegister.dbd, and then call it with a different set in pvxslibs.ioc?

Shall I make a PR for this? Or is there a better way?

coretl commented 3 months ago

I find myself needing this again, would a PR with the above be helpful?

mdavidsaver commented 3 months ago

Yes, a PR would be helpful.