xtd.core.application module¶
-
class
xtd.core.application.Application(p_name=None)[source]¶ Bases:
objectXTD main application object
Users must inherit this class :
- register program’s arguments in their
__init__method - and optionally override
initialize() - override
process()and code their program behavior - call
execute()at top level
p_nameparameter is used for various purpose such as:- default usage
- default –config-file value
- default disk-synced parameters output directory path
- default statistic disk output directory path
Parameters: p_name (str) – application’s name (optional). Defaults to sys.argv[0]-
m_name¶ str
application’s name
-
config()[source]¶ Get the
ConfigManagerinstanceReturns: ConfigManager instance Return type: config.manager.ConfigManager
-
stat()[source]¶ Get the
StatManagerinstanceReturns: StatManager instance Return type: stat.manager.StatManager
-
process()[source]¶ Main application body
The child class must override this method. Since default behavior is to log an error, you should not call parent’s method
Returns: program’s exit code and True if object should call stop method before joining Return type: int, bool
-
initialize()[source]¶ Initializes application
Specifically:
- application’s configuration facility, See
xtd.core.config - application’s logging facility, See
xtd.core.logger - application’s memory parameters, See
xtd.core.param - application’s statistics, See
xtd.core.stat
Any child class that overrides this method should call
super(Application, self).initialize()- application’s configuration facility, See
-
start()[source]¶ Start background modules
Any child class that overrides this method should call
super(Application, self).start()or startStatManagerby hand
-
stop()[source]¶ Stop background modules
Any child class that overrides this method should call
super(Application, self).stop()or stopStatManagerby hand
-
join()[source]¶ Join background modules
Any child class that overrides this method should call
super(Application, self).join()or joinStatManagerby hand
-
execute(p_argv=None)[source]¶ Main application entry point
Exits with code returned by
process().Note
During the initializing phase :
- Any
ConfigErrorleads to the display of the error, followed by the program usage and ends with asys.exit(1). - Any
XtdErrorleads to the display of the error and ends with asys.exit(1).
During the process phase :
- Any
XtdErrorleads to the log of the error and ends with asys.exit(1).
Parameters: p_argv (list) – program’s command-line argument. Defaults to None. If none, arguments are taken from sys.argv- Any
-
__dict__= mappingproxy({'stop': <function Application.stop at 0x7f20103b2ea0>, '_initialize_log': <function Application._initialize_log at 0x7f20103961e0>, '__dict__': <attribute '__dict__' of 'Application' objects>, 'start': <function Application.start at 0x7f20103b2e18>, '_initialize_stat': <function Application._initialize_stat at 0x7f2010396158>, '__init__': <function Application.__init__ at 0x7f20103b2158>, 'initialize': <function Application.initialize at 0x7f20103b2d90>, 'config': <function Application.config at 0x7f20103b2bf8>, 'execute': <function Application.execute at 0x7f2010396048>, 'stat': <function Application.stat at 0x7f20103b2c80>, 'join': <function Application.join at 0x7f20103b2f28>, '_initialize_config': <function Application._initialize_config at 0x7f20103960d0>, '__doc__': "XTD main application object\n\n Users must inherit this class :\n\n * register program's arguments in their ``__init__`` method\n * and optionally override :py:meth:`initialize`\n * override :py:meth:`process` and code their program behavior\n * call :py:meth:`execute` at top level\n\n\n ``p_name`` parameter is used for various purpose such as:\n\n * default usage\n * default --config-file value\n * default disk-synced parameters output directory path\n * default statistic disk output directory path\n\n\n Args:\n p_name (str): application's name (optional). Defaults to ``sys.argv[0]``\n\n Attributes:\n m_name (str): application's name\n\n ", 'process': <function Application.process at 0x7f20103b2d08>, '__module__': 'xtd.core.application', '_initialize_param': <function Application._initialize_param at 0x7f2010396268>, '__weakref__': <attribute '__weakref__' of 'Application' objects>})¶
-
__module__= 'xtd.core.application'¶
-
__weakref__¶ list of weak references to the object (if defined)
- register program’s arguments in their