Esempio n. 1
0
    def launch_eclipse(self, workbench=".", argv=None, nonblock=True, verbose=False):
        """ Launch Eclipse. 
        :param string workbench: Directory of workspace.
        :param list<string> argv: Command-line argument for eclipse.
        :param bool nonblock: If true, this function returns immediately, if false, this function blocks until ecilpse halts.
        :param bool verbose: message verbosity
        :rtype int:
        :return: Zero if success. Non-zero if failed.
        """
        eclipse_dir = os.path.join(wasanbon.home_path, 'eclipse')
        if sys.platform == 'darwin':
            eclipse_dir = os.path.join(eclipse_dir, 'Eclipse.app/Contents/MacOS')
        curdir = os.getcwd()

        if not os.path.isdir(eclipse_dir):
            sys.stdout.write('# Install ecipse by $wasanbon-admin.py environment install eclipse\n')
            return -1
        os.chdir(eclipse_dir)

        if sys.platform == 'win32':
            eclipse_cmd = 'eclipse.exe'
        else:
            eclipse_cmd = './eclipse'

        # Set Environmental Variable
        env = os.environ
        env['RTM_ROOT'] = wasanbon.get_rtm_root()

        if not os.path.isdir(workbench) or workbench == '.':
            if verbose: sys.stdout.write("## Starting eclipse in current directory.\n")
            cmd = [eclipse_cmd]
        else:
            if verbose: sys.stdout.write("## Starting eclipse in current package directory(%s).\n" % workbench)
            cmd = [eclipse_cmd, '-data', workbench]
        if argv != None:
            cmd = cmd + argv

        stdout = None if verbose else subprocess.PIPE
        stderr = None if verbose else subprocess.PIPE
        if sys.platform == 'win32':
            p = subprocess.Popen(cmd, creationflags=512, env=env, stdout=stdout, stderr=stderr)
        else:
            p = subprocess.Popen(cmd, env=env, stdout=stdout, stderr=stderr)

        if not nonblock:
            p.wait()

        os.chdir(curdir)
        return 0
Esempio n. 2
0
    def forEachIDL(self, func, idls=[], idl_dirs=[], except_files=[]):
        """ Apply func function to each IDLs.
        """
        default_idl_dirs = [
            os.path.join(wasanbon.get_rtm_root(), "rtm", "idl"),
            os.path.join(wasanbon.home_path, "idl"),
        ]

        default_except_files = ["RTM.idl", "RTC.idl", "OpenRTM.idl", "DataPort.idl", "Manager.idl", "SDOPackage.idl"]

        if self._parser is None:
            self._parser = parser.IDLParser()

        except_files = except_files + default_except_files
        self._parser.forEachIDL(func, idl_dirs=idl_dirs + default_idl_dirs, except_files=except_files)
Esempio n. 3
0
    def forEachIDL(self, func, idls=[], idl_dirs=[], except_files=[]):
        """ Apply func function to each IDLs.
        """
        default_idl_dirs = [
            os.path.join(wasanbon.get_rtm_root(), 'rtm', 'idl'),
            os.path.join(wasanbon.home_path, 'idl')
        ]

        default_except_files = [
            'RTM.idl', 'RTC.idl', 'OpenRTM.idl', 'DataPort.idl', 'Manager.idl',
            'SDOPackage.idl'
        ]

        if self._parser is None:
            self._parser = parser.IDLParser()

        except_files = except_files + default_except_files
        self._parser.forEachIDL(func,
                                idl_dirs=idl_dirs + default_idl_dirs,
                                except_files=except_files)
Esempio n. 4
0
    def generate(self, argv):
        """ Generate RTC skeleton code.
         # Usage: mgr.py generate_rtc generate [RTC_NAME]
        """
        self.parser.add_option('-f',
                               '--force',
                               help='Force option (default=False)',
                               default=False,
                               action='store_true',
                               dest='force_flag')
        options, argv = self.parse_args(argv[:], self._print_alternatives)
        verbose = options.verbose_flag  # This is default option
        force = options.force_flag

        wasanbon.arg_check(argv, 4)

        rtm_root_path = wasanbon.get_rtm_root()
        default_idl_path = os.path.join(rtm_root_path, 'rtm')
        except_files = [
            'SDOPackage.idl', 'Manager.idl', 'OpenRTM.idl', 'RTC.idl'
        ]
        idls, idl_dirs = self.search_idls(default_idl_path,
                                          except_files=except_files)

        idls = [
            os.path.join(default_idl_path, 'idl', 'BasicDataType.idl'),
            os.path.join(default_idl_path, 'idl', 'ExtendedDataTypes.idl'),
            os.path.join(default_idl_path, 'idl', 'InterfaceDataTypes.idl')
        ]

        self._parser = parser.IDLParser(verbose=verbose)
        self._parser.parse(idls=idls,
                           idl_dirs=idl_dirs,
                           except_files=except_files)

        pack = admin.package.get_package_from_path(os.getcwd())
        rtc = admin.rtc.get_rtc_from_package(pack, argv[3], verbose=verbose)

        self.generate_codes_from_profile(rtc)
Esempio n. 5
0
    def launch_eclipse(self,
                       workbench=".",
                       argv=None,
                       nonblock=True,
                       verbose=False):
        """ Launch Eclipse. 
        :param string workbench: Directory of workspace.
        :param list<string> argv: Command-line argument for eclipse.
        :param bool nonblock: If true, this function returns immediately, if false, this function blocks until ecilpse halts.
        :param bool verbose: message verbosity
        :rtype int:
        :return: Zero if success. Non-zero if failed.
        """
        eclipse_dir = os.path.join(wasanbon.home_path, 'eclipse')
        if sys.platform == 'darwin':
            eclipse_dir = os.path.join(eclipse_dir,
                                       'Eclipse.app/Contents/MacOS')
        curdir = os.getcwd()

        if not os.path.isdir(eclipse_dir):
            sys.stdout.write(
                '# Install ecipse by $wasanbon-admin.py environment install eclipse\n'
            )
            return -1
        os.chdir(eclipse_dir)

        if sys.platform == 'win32':
            eclipse_cmd = 'eclipse.exe'
        else:
            eclipse_cmd = './eclipse'

        # Set Environmental Variable
        env = os.environ
        env['RTM_ROOT'] = wasanbon.get_rtm_root()

        if not os.path.isdir(workbench) or workbench == '.':
            if verbose:
                sys.stdout.write("## Starting eclipse in current directory.\n")
            cmd = [eclipse_cmd]
        else:
            if verbose:
                sys.stdout.write(
                    "## Starting eclipse in current package directory(%s).\n" %
                    workbench)
            cmd = [eclipse_cmd, '-data', workbench]
        if argv != None:
            cmd = cmd + argv

        stdout = None if verbose else subprocess.PIPE
        stderr = None if verbose else subprocess.PIPE
        if sys.platform == 'win32':
            p = subprocess.Popen(cmd,
                                 creationflags=512,
                                 env=env,
                                 stdout=stdout,
                                 stderr=stderr)
        else:
            p = subprocess.Popen(cmd, env=env, stdout=stdout, stderr=stderr)

        if not nonblock:
            p.wait()

        os.chdir(curdir)
        return 0