Initializing help system before first use

xpressinsight.create_app

xpressinsight.create_app


Purpose
Prepare the environment for the test mode and return a new Insight app instance.
Synopsis
create_app(app_type: Type[~AppBaseChild], base_dir: str = None, companion_file: str = None, app_work_dir: str = None, insight_work_dir: str = None) -> ~AppBaseChild
Arguments
app_type 
A subclass of xpressinsight.AppBase.
base_dir 
Path to application base directory (absolute or relative to current working directory). By default, it will be set to the parent directory of the source file that defines the app_type class.
companion_file 
Path to application companion XML file (absolute or relative to base_dir). By default, it will be set to the unique XML file that is located in the application base directory.
app_work_dir 
Absolute path to temporary application working directory. By default, it will be set to the subfolder "work_dir/app" in the application base directory.
insight_work_dir 
Absolute path to temporary Insight working directory. By default, it will be set to the subfolder "work_dir/insight" in the application base directory.
Return value
An instance of the Insight app, i.e., an instance of app_type.
Example
A typical use case for this function is the __main__ section of the application source file. At first we initialize the test mode environment for the app, then we call the load and run modes.
>>> import xpressinsight as xi
...
... @xi.AppConfig(name="Insight Python App")
... class MyApp(xi.AppBase):
...     @xi.ExecModeLoad()
...     def load(self):
...         print(self.insight.exec_mode, "mode ...")
...
...     @xi.ExecModeRun()
...     def run(self):
...         print(self.insight.exec_mode, "mode ...")
...
... if __name__ == "__main__":
...     app = xi.create_app(MyApp)
...     sys.exit(app.call_exec_modes(["LOAD", "RUN"]))		
Further information
1. WARNING: The function first deletes the temporary application working directory app_work_dir, if it exists, and then initializes a new one, by copying the model resources to the new directory. Then it deletes the temporary Insight working directory insight_work_dir, if it exists, and initializes a new one, by copying the attachments to the newly created folder structure.
2. The function also sets the working directory of the Python process to app_work_dir.
3. Throws an exception on failure: OSError or shutil.SameFileError if a file operation fails; ValueError or TypeError if input values are invalid.