@@ -23,27 +23,35 @@ solve those problems and hide verything away.
2323The module can oly be used inside Gatan Microscopy Suite®. The following example shows the
2424basic usage:
2525``` python
26- from execdmscript import exec_dmscript
27-
28- # some script to execute
29- script = " OKDialog(start_message)"
30- script_file = " path/to/script.s"
31-
32- # variables that will be defined for the scripts (and readable later on in python)
33- sv = {" start_message" : " Starting now!" }
34- # variables the dm-script defines and that should be readable in the python file
35- rv = {" selected_images" : list ,
36- " options" : " TagGroup" ,
37- " show_message" : " nUmBeR" }
38-
39- with exec_dmscript(script, script_file, readvars = rv, setvars = sv) as script:
40- print (script[" start_message" ])
41- print (script[" selected_images" ])
42- print (script[" options" ])
43- print (script[" show_message" ])
44-
45- # all variables can be accessed via indexing `script` or by using
46- # `script.synchronized_vars`, note that `script` is also iterable like a dict
26+ import traceback
27+
28+ try :
29+ from execdmscript import exec_dmscript
30+
31+ # some script to execute
32+ script = " OKDialog(start_message)"
33+ script_file = " path/to/script.s"
34+
35+ # variables that will be defined for the scripts (and readable later on in python)
36+ sv = {" start_message" : " Starting now!" }
37+ # variables the dm-script defines and that should be readable in the python file
38+ rv = {" selected_images" : list ,
39+ " options" : " TagGroup" ,
40+ " show_message" : " nUmBeR" }
41+
42+ with exec_dmscript(script, script_file, readvars = rv, setvars = sv) as script:
43+ print (script[" start_message" ])
44+ print (script[" selected_images" ])
45+ print (script[" options" ])
46+ print (script[" show_message" ])
47+
48+ # all variables can be accessed via indexing `script` or by using
49+ # `script.synchronized_vars`, note that `script` is also iterable like a dict
50+ except Exception as e:
51+ # dm-script error messages are very bad, use this for getting the error text and the
52+ # correct traceback
53+ print (" Exception: " , e)
54+ traceback.print_exc()
4755```
4856
4957Note that the upper script only runs when ` execdmscript ` is installed in one of the
0 commit comments