2017-03-24 4 views
1

내가 사용할 수 파이썬에서 CORBA 개발을위한 튜토리얼 다음 : 나는 주어진 IDL 파일에서 파이썬 파일을 생성 한 후 omniORBpy User’s GuideCORBA 파이썬 파일

을, 나는 것으로 나타났습니다 Example 패키지의 init.py 및 Example__POA가 한 수준 아래에 배치 된 echo_example_idl.py 파일을 가져 오려고합니다. 예 모듈에서 init.py의

---Example (module) 
| 
|------ init.py 
| 
---Example__POA (module) 
| 
|------ init.py  
| 
---echo_example_idl.py 
---echo_example.idl 
---example_execution.py 

내용 : example_execution.py의

# DO NOT EDIT THIS FILE! 
# 
# Python module Example generated by omniidl 

import omniORB 
omniORB.updateModule("Example") 

# ** 1. Stub files contributing to this module 
import echo_example_idl 

# ** 2. Sub-modules 

# ** 3. End 

내용 :

#!/usr/bin/env python 
import sys 
from omniORB import CORBA, PortableServer 
import Example, Example__POA 

class Echo_i (Example__POA.Echo): 
    def echoString(self, mesg): 
     print "echoString() called with message:", mesg 
     return mesg 

orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) 
poa = orb.resolve_initial_references("RootPOA") 

ei = Echo_i() 
eo = ei._this() 

poaManager = poa._get_the_POAManager() 
poaManager.activate() 

message = "Hello" 
result = eo.echoString(message) 
print "I said '%s'. The object said '%s'." % (message,result) 

내가 성공 프로그램을 실행할 수를 다음과 같이 디렉토리 트리 보인다.

  1. 두 모듈에 대한 init.py 내부의 import 문은 어떻게 작동합니까? 그것은 omniidl을 통해 생성 된 소스 파일과 동일한 디렉토리에서 example_execution.py를 실행하기 때문입니까?

  2. I (나는 모든 CORBA 소스를 가지고 다른에 내가 example_execution.py 파일을 유지하려는 하려는 하나의 디렉토리에 예를 들어) 소스 파일이있는 디렉토리 외부 실행 파일을 갖고 싶어 내가 진행하는 방법을
  3. . 내가 이렇게하면 나는이 문제를 해결할 수 있었다 echo_example_idl.py

답변

1

에 대한 ImportError를 을 얻을 것이다. 해결책은 파이썬 모듈 안에 CORBA 스텁과 클라이언트/서버 모듈을 생성하는 것입니다. 이는 omniidl 프로그램에 적절한 플래그를 전달하여 수행 할 수 있습니다. 내 경우에는 그것은이었다

omniidl -bpython -Wbpackage=example example_echo.idl 

덕분에 내 디렉토리 트리가 다음과 같이 (실행 및 IDL 파일 자체에 대한 파일 포함) 보이는 것과 : 나는 CORBA 기능을 사용하려면

---example (Python module) 
| 
|------Example (CORBA client module) 
|------Example__POA (CORBA server module) 
|------echo_example.idl.py 
| 
---echo_example.idl 
---example_execution.py 

나는 단지 파일 상단에 import example을 추가해야합니다.