This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17849 ) Change subject: powersupply: Import sublcass module only if used ...................................................................... powersupply: Import sublcass module only if used This way we avoid unconditionally importing all subclass dependencies, and make them optional based on whether the setup has devices of that type or not. Change-Id: I0d2f8b26364b45f0d837cc51078784d1d0fa7ea1 --- M src/osmo_gsm_tester/obj/powersupply.py 1 file changed, 8 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/49/17849/1 diff --git a/src/osmo_gsm_tester/obj/powersupply.py b/src/osmo_gsm_tester/obj/powersupply.py index 90e84ef..d0d315c 100644 --- a/src/osmo_gsm_tester/obj/powersupply.py +++ b/src/osmo_gsm_tester/obj/powersupply.py @@ -50,23 +50,17 @@ MainLoop.sleep(self, sleep) self.power_set(True) - -from . import powersupply_sispm, powersupply_intellinet - -KNOWN_PWSUPPLY_TYPES = { - 'sispm' : powersupply_sispm.PowerSupplySispm, - 'intellinet' : powersupply_intellinet.PowerSupplyIntellinet, -} - -def register_type(name, clazz): - """Register a new PoerSupply child class at runtime.""" - KNOWN_PWSUPPLY_TYPES[name] = clazz - def get_instance_by_type(pwsupply_type, pwsupply_opt): """Allocate a PowerSupply child class based on type. Opts are passed to the newly created object.""" - obj = KNOWN_PWSUPPLY_TYPES.get(pwsupply_type, None) - if not obj: + if pwsupply_type == 'sispm': + from powersupply_sispm import PowerSupplySispm + obj = PowerSupplySispm + elif pwsupply_type == 'intellinet': + from powersupply_intellinet import PowerSupplyIntellinet + obj = PowerSupplyIntellinet + else: raise log.Error('PowerSupply type not supported:', pwsupply_type) + return obj(pwsupply_opt) -- To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17849 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-gsm-tester Gerrit-Branch: master Gerrit-Change-Id: I0d2f8b26364b45f0d837cc51078784d1d0fa7ea1 Gerrit-Change-Number: 17849 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200417/93731c05/attachment.htm>