Ejemplo n.º 1
0
 def setUpClass(cls):
     """
     setup loader & runner with 2 addons instances
     """
     cls.run_mgr = runner(['start', 'execute'], ['stop'])
     cls.load_mgr = loader(verbose=False, recursive=True)
     cls.load_mgr.set_addon_dirs(['./data'])
     cls.load_mgr.load_addons()
     cls.cli_inst = cls.load_mgr.get_instance('CommandLineAddon')
     cls.fileio_inst = cls.load_mgr.get_instance('FileIOAddon')
Ejemplo n.º 2
0
print(loader_mgr.get_loaded_addons(list_all=True))

# ********** USE RUNNER (Transaction) **********

# 3.2: Optional. Use runner order specified at time of initialization
#      Every addon must specify certain tasks (functions), make use of that and run execution as transaction
#      there by consumer dont have to write try..except..finally block
#    - There are 3 variations of this call...

# 3.2.1: Specify <Execute> <Stop> order at the time of initialization
#        So whoever uses this run_mgr will first call addon.start(), addon.execute() and in case these raises
#        exception or runs successfully addon.stop() will be called.
# [ See example below ]

# ********** RUNNER: SEQUENCE AT INITIALIZATION **********
run_mgr = runner(['start', 'execute'], ['stop'])

# get instance of required addon

# 3.2.2: Pass the instance of addon in order to execute with order specified while initializing run_mgr
#        So, cli.start(), cli.execute() and while exiting cli.stop() will be called.
run_mgr.by_default(cli)

# ********** RUNNER: SEQUENCE AT CALLING **********

# 3.3.1: Or you can specify different <Execution> and <Stop> sequence

fileio = loader_mgr.get_instance('FileIOAddon')
fileio.print_addon_info()

# 3.3.2: Execute fileio.execute() & fileio.start() while starting up and fileio.stop() while exiting.
Ejemplo n.º 3
0
print(loader_mgr.get_loaded_addons(list_all=True))

# ********** USE RUNNER (Transaction) **********

# 3.2: Optional. Use runner order specified at time of initialization
#      Every addon must specify certain tasks (functions), make use of that and run execution as transaction
#      there by consumer dont have to write try..except..finally block
#    - There are 3 variations of this call...

# 3.2.1: Specify <Execute> <Stop> order at the time of initialization
#        So whoever uses this run_mgr will first call addon.start(), addon.execute() and in case these raises
#        exception or runs successfully addon.stop() will be called.
# [ See example below ]

# ********** RUNNER: SEQUENCE AT INITIALIZATION **********
run_mgr = runner(['start', 'execute'], ['stop'])

# get instance of required addon

# 3.2.2: Pass the instance of addon in order to execute with order specified while initializing run_mgr
#        So, cli.start(), cli.execute() and while exiting cli.stop() will be called.
run_mgr.by_default(cli)

# ********** RUNNER: SEQUENCE AT CALLING **********

# 3.3.1: Or you can specify different <Execution> and <Stop> sequence

fileio = loader_mgr.get_instance('FileIOAddon')
fileio.print_addon_info()

# 3.3.2: Execute fileio.execute() & fileio.start() while starting up and fileio.stop() while exiting.