idlcompile.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # @brief IDL Compile for OpenRTM-aist-Python
4 #
5 # Target Python version 2.4, 2.5, 2.6
6 #
7 
8 import os, glob, sys, _winreg
9 
10 ##--------------------------------------------------------------------
11 ## commandline argument
12 ## argvs[1]: Python version (2.4, 2.5, 2.6)
13 ## argvs[2]: OpenRTM examples Path
14 ##--------------------------------------------------------------------
15 argvs = sys.argv
16 argc = len(argvs)
17 inst_ver = "all"
18 examples_path = ""
19 
20 if argc > 1:
21  inst_ver = str(argvs[1])
22  examples_path = str(argvs[2])
23 
24 
25 ##--------------------------------------------------------------------
26 ## Install check and IDL Compile
27 ##--------------------------------------------------------------------
28 def idl_compile(chk_ver, reg_key, exa_path):
29  reg_root = _winreg.HKEY_LOCAL_MACHINE
30 
31  try:
32  InstallPath = None
33  index = 0
34 
35  ## Get InstallPath
36  reg_hdl = _winreg.OpenKey(reg_root, reg_key)
37  reg_data = _winreg.EnumValue(reg_hdl, index)
38  InstallPath = reg_data[1]
39  _winreg.CloseKey(reg_hdl)
40 
41  if InstallPath.rfind("\\") != (len(InstallPath) -1):
42  InstallPath += "\\"
43 
44  ## RTM_IDL Directory
45  curr_dir = InstallPath + "Lib\site-packages\OpenRTM_aist\RTM_IDL"
46  os.chdir(curr_dir)
47 
48  ## make idl list
49  idl_cmd = InstallPath + "omniidl.exe -bpython"
50  idl_list = glob.glob("*.idl")
51  idl_cnt = len(idl_list)
52  for i in range(idl_cnt):
53  idl_cmd += " " + idl_list[i]
54 
55  ## idl compile
56  os.system(idl_cmd)
57 
58  ## device_interfaces Directory
59  ## make idl list
60  idl_cmd = InstallPath + "omniidl.exe -bpython"
61  idl_list = glob.glob("device_interfaces\*.idl")
62  idl_cnt = len(idl_list)
63  for i in range(idl_cnt):
64  idl_cmd += " " + idl_list[i]
65 
66  ## idl compile
67  os.system(idl_cmd)
68 
69  ## SimpleService Directory
70  ExamplesPath = exa_path
71  if ExamplesPath.rfind("\\") != (len(ExamplesPath) -1):
72  ExamplesPath += "\\"
73 
74  curr_dir = ExamplesPath + "SimpleService"
75  os.chdir(curr_dir)
76 
77  ## idl compile
78  idl_cmd = InstallPath + "omniidl.exe -bpython MyService.idl"
79  os.system(idl_cmd)
80 
81  return True
82 
83  except EnvironmentError:
84  return False
85 
86  return False
87 
88 
89 ##--------------------------------------------------------------------
90 ## Python 2.4
91 ##--------------------------------------------------------------------
92 if (inst_ver == "all") or (inst_ver == "2.4"):
93  py_ver = "2.4"
94  py_key = "SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath"
95  ret = idl_compile(py_ver, py_key, examples_path)
96  if ret == False:
97  print "Python %s Not Installed." % py_ver
98 
99 
100 ##--------------------------------------------------------------------
101 ## Python 2.5
102 ##--------------------------------------------------------------------
103 if (inst_ver == "all") or (inst_ver == "2.5"):
104  py_ver = "2.5"
105  py_key = "SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath"
106  ret = idl_compile(py_ver, py_key, examples_path)
107  if ret == False:
108  print "Python %s Not Installed." % py_ver
109 
110 
111 ##--------------------------------------------------------------------
112 ## Python 2.6
113 ##--------------------------------------------------------------------
114 if (inst_ver == "all") or (inst_ver == "2.6"):
115  py_ver = "2.6"
116  py_key = "SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath"
117  ret = idl_compile(py_ver, py_key, examples_path)
118  if ret == False:
119  print "Python %s Not Installed." % py_ver
120 
def idl_compile(chk_ver, reg_key, exa_path)
Install check and IDL Compile
Definition: idlcompile.py:28


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Jun 6 2019 19:11:34