xtd.core.application module¶
-
class
xtd.core.application.
Application
(p_name=None)[source]¶ Bases:
object
XTD 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_name
parameter 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
ConfigManager
instanceReturns: ConfigManager instance Return type: config.manager.ConfigManager
-
stat
()[source]¶ Get the
StatManager
instanceReturns: 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 startStatManager
by hand
-
stop
()[source]¶ Stop background modules
Any child class that overrides this method should call
super(Application, self).stop()
or stopStatManager
by hand
-
join
()[source]¶ Join background modules
Any child class that overrides this method should call
super(Application, self).join()
or joinStatManager
by hand
-
execute
(p_argv=None)[source]¶ Main application entry point
Exits with code returned by
process()
.Note
During the initializing phase :
- Any
ConfigError
leads to the display of the error, followed by the program usage and ends with asys.exit(1)
. - Any
XtdError
leads to the display of the error and ends with asys.exit(1)
.
During the process phase :
- Any
XtdError
leads 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({'__init__': <function Application.__init__ at 0x7f0b92320158>, '_initialize_config': <function Application._initialize_config at 0x7f0b9234f0d0>, '_initialize_stat': <function Application._initialize_stat at 0x7f0b9234f158>, 'start': <function Application.start at 0x7f0b92320e18>, '__module__': 'xtd.core.application', '__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 ", 'stop': <function Application.stop at 0x7f0b92320ea0>, 'stat': <function Application.stat at 0x7f0b92320c80>, 'process': <function Application.process at 0x7f0b92320d08>, '__weakref__': <attribute '__weakref__' of 'Application' objects>, '_initialize_log': <function Application._initialize_log at 0x7f0b9234f1e0>, 'config': <function Application.config at 0x7f0b92320bf8>, 'initialize': <function Application.initialize at 0x7f0b92320d90>, 'execute': <function Application.execute at 0x7f0b9234f048>, '_initialize_param': <function Application._initialize_param at 0x7f0b9234f268>, '__dict__': <attribute '__dict__' of 'Application' objects>, 'join': <function Application.join at 0x7f0b92320f28>})¶
-
__module__
= 'xtd.core.application'¶
-
__weakref__
¶ list of weak references to the object (if defined)
- register program’s arguments in their