@@ -125,16 +125,24 @@ ClassMethod GetRemoteClassInfo(
125
125
set importlib = ##class (%SYS.Python ).Import (" importlib" )
126
126
set builtins = ##class (%SYS.Python ).Import (" builtins" )
127
127
set sys = ##class (%SYS.Python ).Import (" sys" )
128
+ set os = ##class (%SYS.Python ).Import (" os" )
128
129
// Load the module form a specific path
129
- set spec = importlib .util ." spec_from_file_location" (pModule , onePath _pModule _" .py" )
130
- set module = importlib .util ." module_from_spec" (spec )
131
- do sys .modules ." __setitem__" (pModule , module )
132
- do spec .loader ." exec_module" (module )
130
+ // Guess the full path to the module
131
+ set path = ..GuessFullPath (pModule , onePath )
132
+ Try {
133
+ set spec = importlib .util ." spec_from_file_location" (pModule , path )
134
+ set module = importlib .util ." module_from_spec" (spec )
135
+ do sys .modules ." __setitem__" (pModule , module )
136
+ do spec .loader ." exec_module" (module )
137
+ }
138
+ Catch ex {
139
+ set module = importlib ." import_module" (pModule )
140
+ }
141
+
133
142
// Get the class
134
143
set class = builtins .getattr (module , pRemoteClassname )
135
144
set tClass = class ." __new__" (class )
136
145
137
-
138
146
If $IsObject (tClass ) {
139
147
#; List of information about the class as a whole - $lb(SuperClass, Description, InfoURL, IconURL, Adapter)
140
148
Set pClassDetails = tClass ." _get_info" ()
@@ -152,13 +160,21 @@ ClassMethod GetRemoteClassInfo(
152
160
Quit tSC
153
161
}
154
162
155
- /// Set tConnectionSettings("Classpaths") = pCLASSPATHS
156
- /// Set tConnectionSettings("Module") = pModule
157
- /// Set tConnectionSettings("Classname") = pRemoteClassname
158
- /// Set:(""=pProxyClassname) pProxyClassname = pRemoteClassname
159
- ///
160
- /// Set tSC = ..GenerateProxyClass(pProxyClassname,.tConnectionSettings,tClassDetails,tRemoteSettings,pOverwrite)
161
- /// "bo","Duplex","/irisdev/app/src/python/demo/duplex/",1,"Duplex.Duplex"
163
+ ClassMethod GuessFullPath (
164
+ module As %String ,
165
+ path As %String ) As %String
166
+ {
167
+ If $Find (module , " ." ) {
168
+ Set module = $Piece (module , " ." , *)
169
+ }
170
+ If $Find (path , module ) {
171
+ Set path = $Piece (path , module , 1 )
172
+ }
173
+ // append the module to the path
174
+ Set path = path _ module _ " .py"
175
+ Return path
176
+ }
177
+
162
178
ClassMethod GenerateProxyClass (
163
179
pClassname As %String ,
164
180
ByRef pConnectionSettings ,
0 commit comments