Пример #1
0
def read_from_ports(raw_paths, options, tree=None):
    event = threading.Event()

    mm = modmgr.ModuleMgr(verbose=options.verbose, paths=options.paths)
    mm.load_mods_and_poas(options.modules)
    if options.verbose:
        print('Pre-loaded modules: {0}'.format(mm.loaded_mod_names),
                file=sys.stderr)
    if options.timeout == -1:
        max = options.max
        if options.verbose:
            print('Will run {0} times.'.format(max), file=sys.stderr)
    else:
        max = -1
        if options.verbose:
            print('Will stop after {0}s'.format(options.timeout),
                    file=sys.stderr)

    targets = port_types.parse_targets(raw_paths)
    if not tree:
        paths = [t[0] for t in targets]
        tree = rtctree.tree.RTCTree(paths=paths, filter=paths)
    port_specs = port_types.make_port_specs(targets, mm, tree)
    port_types.require_all_input(port_specs)
    if options.verbose:
        print('Port specifications: {0}'.format([str(p) for p in port_specs]),
                file=sys.stderr)

    comp_name, mgr = comp_mgmt.make_comp('rtprint_reader', tree,
            rtprint_comp.Reader, port_specs, event=event, rate=options.rate,
            max=max)
    if options.verbose:
        print('Created component {0}'.format(comp_name), file=sys.stderr)
    comp = comp_mgmt.find_comp_in_mgr(comp_name, mgr)
    comp_mgmt.connect(comp, port_specs, tree)
    comp_mgmt.activate(comp)
    try:
        if options.timeout != -1:
            event.wait(options.timeout)
            comp_mgmt.disconnect(comp)
            comp_mgmt.deactivate(comp)
        elif options.max > -1:
            event.wait()
            comp_mgmt.disconnect(comp)
            comp_mgmt.deactivate(comp)
        else:
            while True:
                if sys.version_info[0] == 3:
                    input()
                else:
                    raw_input()
            # The manager will catch the Ctrl-C and shut down itself, so don't
            # disconnect/deactivate the component
    except KeyboardInterrupt:
        pass
    except EOFError:
        pass
    tree.give_away_orb()
    del tree
    comp_mgmt.shutdown(mgr)
Пример #2
0
def read_from_ports(raw_paths, options, tree=None):
    event = threading.Event()

    mm = modmgr.ModuleMgr(verbose=options.verbose, paths=options.paths)
    mm.load_mods_and_poas(options.modules)
    if options.verbose:
        print('Pre-loaded modules: {0}'.format(mm.loaded_mod_names),
                file=sys.stderr)
    if options.timeout == -1:
        max = options.max
        if options.verbose:
            print('Will run {0} times.'.format(max), file=sys.stderr)
    else:
        max = -1
        if options.verbose:
            print('Will stop after {0}s'.format(options.timeout),
                    file=sys.stderr)

    targets = port_types.parse_targets(raw_paths)
    if not tree:
        paths = [t[0] for t in targets]
        tree = rtctree.tree.RTCTree(paths=paths, filter=paths)
    port_specs = port_types.make_port_specs(targets, mm, tree)
    port_types.require_all_input(port_specs)
    if options.verbose:
        print('Port specifications: {0}'.format([str(p) for p in port_specs]),
                file=sys.stderr)

    comp_name, mgr = comp_mgmt.make_comp('rtprint_reader', tree,
            rtprint_comp.Reader, port_specs, event=event, rate=options.rate,
            max=max)
    if options.verbose:
        print('Created component {0}'.format(comp_name), file=sys.stderr)
    comp = comp_mgmt.find_comp_in_mgr(comp_name, mgr)
    comp_mgmt.connect(comp, port_specs, tree)
    comp_mgmt.activate(comp)
    try:
        if options.timeout != -1:
            event.wait(options.timeout)
            comp_mgmt.disconnect(comp)
            comp_mgmt.deactivate(comp)
        elif options.max > -1:
            event.wait()
            comp_mgmt.disconnect(comp)
            comp_mgmt.deactivate(comp)
        else:
            while True:
                if sys.version_info[0] == 3:
                    input()
                else:
                    raw_input()
            # The manager will catch the Ctrl-C and shut down itself, so don't
            # disconnect/deactivate the component
    except KeyboardInterrupt:
        pass
    except EOFError:
        pass
    tree.give_away_orb()
    del tree
    comp_mgmt.shutdown(mgr)
Пример #3
0
def write_to_ports(raw_paths, options, tree=None):
    event = threading.Event()

    mm = modmgr.ModuleMgr(verbose=options.verbose, paths=options.paths)
    mm.load_mods_and_poas(options.modules)
    if options.verbose:
        print('Pre-loaded modules: {0}'.format(mm.loaded_mod_names),
              file=sys.stderr)

    if options.const:
        val = mm.evaluate(options.const)
        if options.verbose:
            print('Evaluated value to {0}'.format(val), file=sys.stderr)
    else:
        if options.verbose:
            print('Reading values from stdin.', file=sys.stderr)

    if options.timeout == -1:
        max = options.max
        if options.verbose:
            print('Will run {0} times.'.format(max), file=sys.stderr)
    else:
        max = -1
        if options.verbose:
            print('Will stop after {0}s'.format(options.timeout),
                  file=sys.stderr)

    targets = port_types.parse_targets(raw_paths)
    if not tree:
        paths = [t[0] for t in targets]
        tree = rtctree.tree.RTCTree(paths=paths, filter=paths)
    port_specs = port_types.make_port_specs(targets, mm, tree)
    port_types.require_all_output(port_specs)
    if options.verbose:
        print('Port specifications: {0}'.format([str(p) for p in port_specs]),
              file=sys.stderr)

    if options.const:
        comp_name, mgr = comp_mgmt.make_comp('rtinject_writer',
                                             tree,
                                             rtinject_comp.Writer,
                                             port_specs,
                                             event=event,
                                             rate=options.rate,
                                             max=max,
                                             val=val)
    else:
        buffer = []
        mutex = threading.RLock()
        comp_name, mgr = comp_mgmt.make_comp('rtinject_writer',
                                             tree,
                                             rtinject_comp.StdinWriter,
                                             port_specs,
                                             event=event,
                                             rate=options.rate,
                                             max=max,
                                             buf=buffer,
                                             mutex=mutex)
    if options.verbose:
        print('Created component {0}'.format(comp_name), file=sys.stderr)
    comp = comp_mgmt.find_comp_in_mgr(comp_name, mgr)
    comp_mgmt.connect(comp, port_specs, tree)
    comp_mgmt.activate(comp)
    if options.const:
        try:
            if options.timeout != -1:
                event.wait(options.timeout)
            elif options.max > -1:
                event.wait()
            else:
                if sys.version_info[0] == 3:
                    input()
                else:
                    raw_input()
        except KeyboardInterrupt:
            pass
        except EOFError:
            pass
    else:
        # Read stdin until we receive max number of values or Ctrl-C is hit
        val_cnt = 0
        try:
            while val_cnt < max or max < 0:
                l = sys.stdin.readline()
                if not l:
                    break
                if l[0] == '#':
                    continue
                val = mm.evaluate(l)
                with mutex:
                    buffer.append(val)
                val_cnt += 1
        except KeyboardInterrupt:
            pass
        # Wait until the buffer has been cleared
        while True:
            with mutex:
                if not buffer:
                    break
    comp_mgmt.disconnect(comp)
    comp_mgmt.deactivate(comp)
    tree.give_away_orb()
    del tree
    comp_mgmt.shutdown(mgr)
Пример #4
0
def write_to_ports(raw_paths, options, tree=None):
    event = threading.Event()

    mm = modmgr.ModuleMgr(verbose=options.verbose, paths=options.paths)
    mm.load_mods_and_poas(options.modules)
    if options.verbose:
        print("Pre-loaded modules: {0}".format(mm.loaded_mod_names), file=sys.stderr)

    if options.const:
        val = mm.evaluate(options.const)
        if options.verbose:
            print("Evaluated value to {0}".format(val), file=sys.stderr)
    else:
        if options.verbose:
            print("Reading values from stdin.", file=sys.stderr)

    if options.timeout == -1:
        max = options.max
        if options.verbose:
            print("Will run {0} times.".format(max), file=sys.stderr)
    else:
        max = -1
        if options.verbose:
            print("Will stop after {0}s".format(options.timeout), file=sys.stderr)

    targets = port_types.parse_targets(raw_paths)
    if not tree:
        paths = [t[0] for t in targets]
        tree = rtctree.tree.RTCTree(paths=paths, filter=paths)
    port_specs = port_types.make_port_specs(targets, mm, tree)
    port_types.require_all_output(port_specs)
    if options.verbose:
        print("Port specifications: {0}".format([str(p) for p in port_specs]), file=sys.stderr)

    if options.const:
        comp_name, mgr = comp_mgmt.make_comp(
            "rtinject_writer", tree, rtinject_comp.Writer, port_specs, event=event, rate=options.rate, max=max, val=val
        )
    else:
        buffer = []
        mutex = threading.RLock()
        comp_name, mgr = comp_mgmt.make_comp(
            "rtinject_writer",
            tree,
            rtinject_comp.StdinWriter,
            port_specs,
            event=event,
            rate=options.rate,
            max=max,
            buf=buffer,
            mutex=mutex,
        )
    if options.verbose:
        print("Created component {0}".format(comp_name), file=sys.stderr)
    comp = comp_mgmt.find_comp_in_mgr(comp_name, mgr)
    comp_mgmt.connect(comp, port_specs, tree)
    comp_mgmt.activate(comp)
    if options.const:
        try:
            if options.timeout != -1:
                event.wait(options.timeout)
            elif options.max > -1:
                event.wait()
            else:
                if sys.version_info[0] == 3:
                    input()
                else:
                    raw_input()
        except KeyboardInterrupt:
            pass
        except EOFError:
            pass
    else:
        # Read stdin until we receive max number of values or Ctrl-C is hit
        val_cnt = 0
        try:
            while val_cnt < max or max < 0:
                l = sys.stdin.readline()
                if not l:
                    break
                if l[0] == "#":
                    continue
                val = mm.evaluate(l)
                with mutex:
                    buffer.append(val)
                val_cnt += 1
        except KeyboardInterrupt:
            pass
        # Wait until the buffer has been cleared
        while True:
            with mutex:
                if not buffer:
                    break
    comp_mgmt.disconnect(comp)
    comp_mgmt.deactivate(comp)
    tree.give_away_orb()
    del tree
    comp_mgmt.shutdown(mgr)
Пример #5
0
def record_log(raw_paths, options, tree=None):
    event = threading.Event()

    if options.end is not None and options.end < 0:
        raise rts_exceptions.BadEndPointError
    if options.end is None and options.index:
        print('{0}: WARNING: --index has no effect without --end'.format(
            os.path.basename(sys.argv[0])),
              file=sys.stderr)

    mm = modmgr.ModuleMgr(verbose=options.verbose, paths=options.paths)
    mm.load_mods_and_poas(options.modules)
    if options.verbose:
        print('Pre-loaded modules: {0}'.format(mm.loaded_mod_names),
              file=sys.stderr)

    if options.timeout is not None:
        print('Recording for {0}s.'.format(options.timeout), file=sys.stderr)
    else:
        if options.end is not None:
            if options.index:
                print('Recording {0} entries.'.format(int(options.end)),
                      file=sys.stderr)
            else:
                end_str = time.strftime('%Y-%m-%d %H:%M:%S',
                                        time.localtime(options.end))
                print('Recording until {0} ({1}).'.format(
                    end_str, options.end),
                      file=sys.stderr)

    if options.logger == 'simpkl':
        l_type = simpkl_log.SimplePickleLog
    elif options.logger == 'text':
        l_type = text_log.TextLog
    else:
        raise rts_exceptions.BadLogTypeError(options.logger)

    sources = port_types.parse_targets(raw_paths)
    if not tree:
        paths = [s[0] for s in sources]
        tree = rtctree.tree.RTCTree(paths=paths, filter=paths)
    port_specs = port_types.make_port_specs(sources, mm, tree)
    port_types.require_all_input(port_specs)
    if options.verbose:
        print('Port specifications: {0}'.format([str(p) for p in port_specs]),
              file=sys.stderr)

    if options.end is None:
        end = -1  # Send -1 as the default
    else:
        end = options.end
    comp_name, mgr = comp_mgmt.make_comp('rtlog_recorder',
                                         tree,
                                         rtlog_comps.Recorder,
                                         port_specs,
                                         event=event,
                                         logger_type=l_type,
                                         filename=options.filename,
                                         lims_are_ind=options.index,
                                         end=end,
                                         verbose=options.verbose,
                                         rate=options.exec_rate)
    if options.verbose:
        print('Created component {0}'.format(comp_name), file=sys.stderr)
    try:
        comp = comp_mgmt.find_comp_in_mgr(comp_name, mgr)
        comp_mgmt.connect(comp, port_specs, tree)
        comp_mgmt.activate(comp)
    except Exception as e:
        #comp_mgmt.shutdown(mgr)
        raise e
    try:
        if options.timeout is not None:
            event.wait(options.timeout)
            comp_mgmt.disconnect(comp)
            comp_mgmt.deactivate(comp)
        elif options.end is not None:
            event.wait()
            comp_mgmt.disconnect(comp)
            comp_mgmt.deactivate(comp)
        else:
            while True:
                if sys.version_info[0] == 3:
                    input()
                else:
                    raw_input()
            # The manager will catch the Ctrl-C and shut down itself, so don't
            # disconnect/deactivate the component
    except KeyboardInterrupt:
        pass
    except EOFError:
        pass
    tree.give_away_orb()
    del tree
    comp_mgmt.shutdown(mgr)
Пример #6
0
def play_log(raw_paths, options, tree=None):
    event = threading.Event()

    if not options.filename:
        raise rts_exceptions.NoLogFileNameError
    if options.start is not None and options.start < 0:
        raise rts_exceptions.BadStartPointError
    if options.end is not None and options.end < 0:
        raise rts_exceptions.BadEndPointError
    if options.end is None and options.start is None and options.index:
        print('{0}: WARNING: --index has no effect without '\
                '--start or --end'.format(os.path.basename(sys.argv[0])),
                file=sys.stderr)

    mm = modmgr.ModuleMgr(verbose=options.verbose, paths=options.paths)
    mm.load_mods_and_poas(options.modules)
    if options.verbose:
        print('Pre-loaded modules: {0}'.format(mm.loaded_mod_names),
              file=sys.stderr)

    if options.timeout is not None:
        print('Playing for {0}s.'.format(options.timeout), file=sys.stderr)
    else:
        if options.end is not None:
            if options.start is not None:
                if options.index:
                    print('Playing from entry {0} to entry {1}.'.format(
                        int(options.start), int(options.end)),
                          file=sys.stderr)
                else:
                    start_str = time.strftime('%Y-%m-%d %H:%M:%S',
                                              time.localtime(options.start))
                    end_str = time.strftime('%Y-%m-%d %H:%M:%S',
                                            time.localtime(options.end))
                    print('Playing from {0} ({1}) until {2} ({3}).'.format(
                        start_str, options.start, end_str, options.end),
                          file=sys.stderr)
            else:
                if options.index:
                    print('Playing {0} entries.'.format(int(options.end)),
                          file=sys.stderr)
                else:
                    end_str = time.strftime('%Y-%m-%d %H:%M:%S',
                                            time.localtime(options.end))
                    print('Playing until {0} ({1}).'.format(
                        end_str, options.end),
                          file=sys.stderr)
        elif options.start is not None:
            if options.index:
                print('Playing from entry {0}.'.format(int(options.start)),
                      file=sys.stderr)
            else:
                start_str = time.strftime('%Y-%m-%d %H:%M:%S',
                                          time.localtime(options.start))
                print('Playing from {0} ({1}).'.format(start_str,
                                                       options.start),
                      file=sys.stderr)

    if options.logger == 'simpkl':
        l_type = simpkl_log.SimplePickleLog
    elif options.logger == 'text':
        raise rts_exceptions.UnsupportedLogTypeError('text', 'playback')
    else:
        raise rts_exceptions.BadLogTypeError(options.logger)

    targets = port_types.parse_targets(raw_paths)
    if not tree:
        paths = [t[0] for t in targets]
        tree = rtctree.tree.RTCTree(paths=paths, filter=paths)
    port_specs = port_types.make_port_specs(targets, mm, tree)
    if options.verbose:
        print('Port specifications: {0}'.format([str(p) for p in port_specs]),
              file=sys.stderr)
    port_types.require_all_output(port_specs)

    if options.start is None:
        start = 0  # Send 0 as the default
    else:
        start = options.start
    if options.end is None:
        end = -1  # Send -1 as the default
    else:
        end = options.end
    comp_name, mgr = comp_mgmt.make_comp('rtlog_player',
                                         tree,
                                         rtlog_comps.Player,
                                         port_specs,
                                         event=event,
                                         logger_type=l_type,
                                         filename=options.filename,
                                         lims_are_ind=options.index,
                                         start=start,
                                         end=end,
                                         scale_rate=options.rate,
                                         abs_times=options.abs_times,
                                         ignore_times=options.ig_times,
                                         verbose=options.verbose,
                                         rate=options.exec_rate)
    if options.verbose:
        print('Created component {0}'.format(comp_name), file=sys.stderr)
    comp = comp_mgmt.find_comp_in_mgr(comp_name, mgr)
    comp_mgmt.connect(comp, port_specs, tree)
    comp_mgmt.activate(comp)
    try:
        if options.timeout is not None:
            event.wait(options.timeout)
            comp_mgmt.disconnect(comp)
            try:
                comp_mgmt.deactivate(comp)
            except rts_exceptions.DeactivateError:
                # Don't care about this because the component will be shut down
                # soon anyway
                pass
        #elif options.end is not None:
        else:
            event.wait()
            comp_mgmt.disconnect(comp)
            try:
                comp_mgmt.deactivate(comp)
            except rts_exceptions.DeactivateError:
                # Don't care about this because the component will be shut down
                # soon anyway
                pass
        #else:
        #while True:
        #raw_input()
        # The manager will catch the Ctrl-C and shut down itself, so don't
        # disconnect/deactivate the component
    except KeyboardInterrupt:
        pass
    except EOFError:
        pass
    tree.give_away_orb()
    del tree
    comp_mgmt.shutdown(mgr)
Пример #7
0
def record_log(raw_paths, options, tree=None):
    event = threading.Event()

    if options.end is not None and options.end < 0:
        raise rts_exceptions.BadEndPointError
    if options.end is None and options.index:
        print('{0}: WARNING: --index has no effect without --end'.format(
            os.path.basename(sys.argv[0])), file=sys.stderr)

    mm = modmgr.ModuleMgr(verbose=options.verbose, paths=options.paths)
    mm.load_mods_and_poas(options.modules)
    if options.verbose:
        print('Pre-loaded modules: {0}'.format(mm.loaded_mod_names),
                file=sys.stderr)

    if options.timeout is not None:
        print('Recording for {0}s.'.format(options.timeout), file=sys.stderr)
    else:
        if options.end is not None:
            if options.index:
                print('Recording {0} entries.'.format(int(options.end)),
                        file=sys.stderr)
            else:
                end_str = time.strftime('%Y-%m-%d %H:%M:%S',
                        time.localtime(options.end))
                print('Recording until {0} ({1}).'.format(end_str,
                    options.end), file=sys.stderr)

    if options.logger == 'simpkl':
        l_type = simpkl_log.SimplePickleLog
    elif options.logger == 'text':
        l_type = text_log.TextLog
    else:
        raise rts_exceptions.BadLogTypeError(options.logger)

    sources = port_types.parse_targets(raw_paths)
    if not tree:
        paths = [s[0] for s in sources]
        tree = rtctree.tree.RTCTree(paths=paths, filter=paths)
    port_specs = port_types.make_port_specs(sources, mm, tree)
    port_types.require_all_input(port_specs)
    if options.verbose:
        print('Port specifications: {0}'.format([str(p) for p in port_specs]),
                file=sys.stderr)

    if options.end is None:
        end = -1 # Send -1 as the default
    else:
        end = options.end
    comp_name, mgr = comp_mgmt.make_comp('rtlog_recorder', tree,
            rtlog_comps.Recorder, port_specs, event=event,
            logger_type=l_type, filename=options.filename,
            lims_are_ind=options.index, end=end,
            verbose=options.verbose, rate=options.exec_rate)
    if options.verbose:
        print('Created component {0}'.format(comp_name), file=sys.stderr)
    try:
        comp = comp_mgmt.find_comp_in_mgr(comp_name, mgr)
        comp_mgmt.connect(comp, port_specs, tree)
        comp_mgmt.activate(comp)
    except Exception as e:
        #comp_mgmt.shutdown(mgr)
        raise e
    try:
        if options.timeout is not None:
            event.wait(options.timeout)
            comp_mgmt.disconnect(comp)
            comp_mgmt.deactivate(comp)
        elif options.end is not None:
            event.wait()
            comp_mgmt.disconnect(comp)
            comp_mgmt.deactivate(comp)
        else:
            while True:
                if sys.version_info[0] == 3:
                    input()
                else:
                    raw_input()
            # The manager will catch the Ctrl-C and shut down itself, so don't
            # disconnect/deactivate the component
    except KeyboardInterrupt:
        pass
    except EOFError:
        pass
    tree.give_away_orb()
    del tree
    comp_mgmt.shutdown(mgr)
Пример #8
0
def play_log(raw_paths, options, tree=None):
    event = threading.Event()

    if not options.filename:
        raise rts_exceptions.NoLogFileNameError
    if options.start is not None and options.start < 0:
        raise rts_exceptions.BadStartPointError
    if options.end is not None and options.end < 0:
        raise rts_exceptions.BadEndPointError
    if options.end is None and options.start is None and options.index:
        print('{0}: WARNING: --index has no effect without '\
                '--start or --end'.format(os.path.basename(sys.argv[0])),
                file=sys.stderr)

    mm = modmgr.ModuleMgr(verbose=options.verbose, paths=options.paths)
    mm.load_mods_and_poas(options.modules)
    if options.verbose:
        print('Pre-loaded modules: {0}'.format(mm.loaded_mod_names),
                file=sys.stderr)

    if options.timeout is not None:
        print('Playing for {0}s.'.format(options.timeout), file=sys.stderr)
    else:
        if options.end is not None:
            if options.start is not None:
                if options.index:
                    print('Playing from entry {0} to entry {1}.'.format(
                        int(options.start), int(options.end)), file=sys.stderr)
                else:
                    start_str = time.strftime('%Y-%m-%d %H:%M:%S',
                            time.localtime(options.start))
                    end_str = time.strftime('%Y-%m-%d %H:%M:%S',
                            time.localtime(options.end))
                    print('Playing from {0} ({1}) until {2} ({3}).'.format(
                        start_str, options.start, end_str, options.end),
                        file=sys.stderr)
            else:
                if options.index:
                    print('Playing {0} entries.'.format(int(options.end)),
                            file=sys.stderr)
                else:
                    end_str = time.strftime('%Y-%m-%d %H:%M:%S',
                            time.localtime(options.end))
                    print('Playing until {0} ({1}).'.format(end_str,
                        options.end), file=sys.stderr)
        elif options.start is not None:
            if options.index:
                print('Playing from entry {0}.'.format(int(options.start)),
                        file=sys.stderr)
            else:
                start_str = time.strftime('%Y-%m-%d %H:%M:%S',
                        time.localtime(options.start))
                print('Playing from {0} ({1}).'.format(start_str,
                    options.start), file=sys.stderr)

    if options.logger == 'simpkl':
        l_type = simpkl_log.SimplePickleLog
    elif options.logger == 'text':
        raise rts_exceptions.UnsupportedLogTypeError('text', 'playback')
    else:
        raise rts_exceptions.BadLogTypeError(options.logger)

    targets = port_types.parse_targets(raw_paths)
    if not tree:
        paths = [t[0] for t in targets]
        tree = rtctree.tree.RTCTree(paths=paths, filter=paths)
    port_specs = port_types.make_port_specs(targets, mm, tree)
    if options.verbose:
        print('Port specifications: {0}'.format([str(p) for p in port_specs]),
                file=sys.stderr)
    port_types.require_all_output(port_specs)

    if options.start is None:
        start = 0 # Send 0 as the default
    else:
        start = options.start
    if options.end is None:
        end = -1 # Send -1 as the default
    else:
        end = options.end
    comp_name, mgr = comp_mgmt.make_comp('rtlog_player', tree,
            rtlog_comps.Player, port_specs, event=event, logger_type=l_type,
            filename=options.filename, lims_are_ind=options.index, start=start,
            end=end, scale_rate=options.rate, abs_times=options.abs_times,
            ignore_times=options.ig_times, verbose=options.verbose,
            rate=options.exec_rate)
    if options.verbose:
        print('Created component {0}'.format(comp_name), file=sys.stderr)
    comp = comp_mgmt.find_comp_in_mgr(comp_name, mgr)
    comp_mgmt.connect(comp, port_specs, tree)
    comp_mgmt.activate(comp)
    try:
        if options.timeout is not None:
            event.wait(options.timeout)
            comp_mgmt.disconnect(comp)
            try:
                comp_mgmt.deactivate(comp)
            except rts_exceptions.DeactivateError:
                # Don't care about this because the component will be shut down
                # soon anyway
                pass
        #elif options.end is not None:
        else:
            event.wait()
            comp_mgmt.disconnect(comp)
            try:
                comp_mgmt.deactivate(comp)
            except rts_exceptions.DeactivateError:
                # Don't care about this because the component will be shut down
                # soon anyway
                pass
        #else:
            #while True:
                #raw_input()
            # The manager will catch the Ctrl-C and shut down itself, so don't
            # disconnect/deactivate the component
    except KeyboardInterrupt:
        pass
    except EOFError:
        pass
    tree.give_away_orb()
    del tree
    comp_mgmt.shutdown(mgr)