Objectives

Sometimes you have some complex python code in some monitors and it's hard to maintain. when this code is used in various monitors it's horrible. The solution is to externalize the python code in a external module!

But:

  • modules are loaded once by process. If you don't use reload you have to restart the l2launcher
  • to use some functions or variable present in the ThinkServer you cannot use a simple import

This example how how to workaround these problems.

Installation

  • unzip the specific archive in the PythonLib/lib folder of the ThinkServer.
  • import the monitor in your ThinkServer. The pre-event script import and reload the module and init it with the init function.

It works!

You can change the code in TSTest.py and see how it is take into account once you restart the monitor. You can use any functions or variables present in the ThinkServer.

You can even add the additional parameters variables if you want the same way the other variables are obtained, modifying the init function in the module.


Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: October 18, 2018