idlcompile.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # @brief IDL Compile for OpenRTM-aist-Python
00004 #
00005 # Target Python version 2.4, 2.5, 2.6
00006 #
00007 
00008 import os, glob, sys, _winreg
00009 
00010 ##--------------------------------------------------------------------
00011 ## commandline argument
00012 ## argvs[1]: Python version (2.4, 2.5, 2.6)
00013 ## argvs[2]: OpenRTM examples Path
00014 ##--------------------------------------------------------------------
00015 argvs = sys.argv
00016 argc = len(argvs)
00017 inst_ver = "all"
00018 examples_path = ""
00019 
00020 if argc > 1:
00021     inst_ver = str(argvs[1])
00022     examples_path = str(argvs[2])
00023 
00024 
00025 ##--------------------------------------------------------------------
00026 ## Install check and IDL Compile
00027 ##--------------------------------------------------------------------
00028 def idl_compile(chk_ver, reg_key, exa_path):
00029   reg_root = _winreg.HKEY_LOCAL_MACHINE
00030 
00031   try:
00032     InstallPath = None
00033     index = 0
00034 
00035     ## Get InstallPath
00036     reg_hdl = _winreg.OpenKey(reg_root, reg_key)
00037     reg_data = _winreg.EnumValue(reg_hdl, index)
00038     InstallPath = reg_data[1]
00039     _winreg.CloseKey(reg_hdl)
00040 
00041     if InstallPath.rfind("\\") != (len(InstallPath) -1):
00042       InstallPath += "\\"
00043 
00044     ## RTM_IDL Directory
00045     curr_dir = InstallPath + "Lib\site-packages\OpenRTM_aist\RTM_IDL"
00046     os.chdir(curr_dir)
00047 
00048     ## make idl list
00049     idl_cmd = InstallPath + "omniidl.exe -bpython"
00050     idl_list = glob.glob("*.idl")
00051     idl_cnt = len(idl_list)
00052     for i in range(idl_cnt):
00053       idl_cmd += " " + idl_list[i]
00054 
00055     ## idl compile
00056     os.system(idl_cmd)
00057 
00058     ## device_interfaces Directory
00059     ## make idl list
00060     idl_cmd = InstallPath + "omniidl.exe -bpython"
00061     idl_list = glob.glob("device_interfaces\*.idl")
00062     idl_cnt = len(idl_list)
00063     for i in range(idl_cnt):
00064       idl_cmd += " " + idl_list[i]
00065 
00066     ## idl compile
00067     os.system(idl_cmd)
00068 
00069     ## SimpleService Directory
00070     ExamplesPath = exa_path
00071     if ExamplesPath.rfind("\\") != (len(ExamplesPath) -1):
00072       ExamplesPath += "\\"
00073 
00074     curr_dir = ExamplesPath + "SimpleService"
00075     os.chdir(curr_dir)
00076 
00077     ## idl compile
00078     idl_cmd = InstallPath + "omniidl.exe -bpython MyService.idl"
00079     os.system(idl_cmd)
00080 
00081     return True
00082 
00083   except EnvironmentError:
00084     return False
00085 
00086   return False
00087 
00088 
00089 ##--------------------------------------------------------------------
00090 ## Python 2.4
00091 ##--------------------------------------------------------------------
00092 if (inst_ver == "all") or (inst_ver == "2.4"):
00093   py_ver = "2.4"
00094   py_key = "SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath"
00095   ret = idl_compile(py_ver, py_key, examples_path)
00096   if ret == False:
00097     print "Python %s Not Installed." % py_ver
00098 
00099 
00100 ##--------------------------------------------------------------------
00101 ## Python 2.5
00102 ##--------------------------------------------------------------------
00103 if (inst_ver == "all") or (inst_ver == "2.5"):
00104   py_ver = "2.5"
00105   py_key = "SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath"
00106   ret = idl_compile(py_ver, py_key, examples_path)
00107   if ret == False:
00108     print "Python %s Not Installed." % py_ver
00109 
00110 
00111 ##--------------------------------------------------------------------
00112 ## Python 2.6
00113 ##--------------------------------------------------------------------
00114 if (inst_ver == "all") or (inst_ver == "2.6"):
00115   py_ver = "2.6"
00116   py_key = "SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath"
00117   ret = idl_compile(py_ver, py_key, examples_path)
00118   if ret == False:
00119     print "Python %s Not Installed." % py_ver
00120 


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Aug 27 2015 14:17:28