File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ ClassMethod WrapperDemo() As %Status
55{
66
77 // Import the module
8- set tModule = ##class (IOP.Wrapper ).Import (" my_script" , " /irisdev/app/demo/python/non_production/ " , 54132 )
8+ set tModule = ##class (IOP.Wrapper ).Import (" my_script" , " /irisdev/app/demo/python/non_production" , 54132 )
99
1010 // Call the function
1111 set result = tModule .main ()
@@ -14,4 +14,21 @@ ClassMethod WrapperDemo() As %Status
1414 write result
1515}
1616
17+ ClassMethod WithoutWrapperDemo () As %Status
18+ {
19+
20+ // Set the Python path
21+ set sys = ##class (%SYS.Python ).Import (" sys" )
22+ do sys ." path" ." append" (" /irisdev/app/demo/python/non_production" )
23+
24+ // Import the module directly
25+ set tModule = ##class (%SYS.Python ).Import (" my_script" )
26+
27+ // Call the function
28+ set result = tModule .main ()
29+
30+ // Print the result
31+ write result
32+ }
33+
1734}
Original file line number Diff line number Diff line change 11import os
2+ import random
23
34def main ():
45 # Get the value of the environment variable
@@ -7,6 +8,12 @@ def main():
78 # Print the value of the environment variable
89 print (f'MY_ENV_VAR: { my_env_var } ' )
910
11+ if random .choice ([True , False ]):
12+ # Simulate a condition that raises an exception
13+ print ("An error occurred!" )
14+ # Raise an exception to demonstrate error handling
15+ raise Exception ("This is a demo exception to illustrate error handling." )
16+
1017 return "Script executed successfully!"
1118
1219
You can’t perform that action at this time.
0 commit comments