Example #1
0
def status(linkstring=None):
    """ Query the status of the links.  """
    links = list(api.expand_links([linkstring]))
    fake_output = {}
    for link in map(str, links):
        fake_output[link] = []
        for flag in api.STATUS_FLAGS.keys():
            fake_output[link].append((flag, int(random.random() < 0.8)))
    return json.jsonify(**fake_output)
Example #2
0
def status(linkstring=None):
    """ Query the status of the links.  """
    links = list(api.expand_links([linkstring]))
    fake_output = {}
    for link in map(str, links):
        fake_output[link] = []
        for flag in api.STATUS_FLAGS.keys():
            fake_output[link].append((flag, int(random.random() < 0.8)))
    return json.jsonify(**fake_output)
Example #3
0
    if args.verbose:
        logging.basicConfig(level=logging.INFO)
        uhal.setLogLevelTo(uhal.LogLevel.WARNING)
    else:
        uhal.setLogLevelTo(uhal.LogLevel.WARNING)
        logging.basicConfig(level=logging.WARNING)

    if not args.connection:
        args.connection = os.environ['CTP6_CONNECTION']

    if not args.links:
        log.debug("Using all links")
        args.links = range(48)
    else:
        args.links = list(api.expand_links(args.links))

    hw_connection = 'file://%s' % args.connection
    log.info("Setting up connection: %s", hw_connection)
    manager = uhal.ConnectionManager(hw_connection)

    hw = manager.getDevice('ctp6.frontend')

    commands = {
        'reset': do_reset,
        'status': do_status,
        'capture': do_capture
    }

    print hw
    print args
Example #4
0
def main():
    parser = argparse.ArgumentParser()

    parser.add_argument("command",
                        choices=['reset', 'status', 'capture'],
                        help="Action to perform")

    parser.add_argument("links",
                        nargs='*',
                        help="Specify links. "
                        "If none are specified, reset all.")

    parser.add_argument("--connection",
                        help="Manually connection XML file. "
                        "If not specified, take from CTP6_CONNECTION env.")
    parser.add_argument("--verbose",
                        action='store_true',
                        help="Increase verbosity")

    parser_rst = parser.add_argument_group('reset')
    parser_stat = parser.add_argument_group('status')
    parser_cap = parser.add_argument_group('capture')

    # Reset arguments
    parser_rst.add_argument("--power-down",
                            action='store_true',
                            dest='power_down',
                            help="Additionally power down the links")

    # Capture arguments
    parser_cap.add_argument("--orbit-capture-char",
                            dest='capture_char',
                            type=str,
                            metavar='0xbc',
                            default='0xbc',
                            help="character to trigger capture "
                            "- default: %(default)s")

    parser_cap.add_argument("--nwords",
                            dest='ncapture',
                            type=int,
                            metavar='N',
                            default=4,
                            help="Number of words to capture from each link"
                            "- default: 0x%(default)i")

    parser_cap.add_argument("--expected",
                            metavar='pattern.txt',
                            help="Pattern file with 1 word/line in hex")

    args = parser.parse_args()

    if args.verbose:
        logging.basicConfig(level=logging.INFO)
        uhal.setLogLevelTo(uhal.LogLevel.WARNING)
    else:
        uhal.setLogLevelTo(uhal.LogLevel.WARNING)
        logging.basicConfig(level=logging.WARNING)

    if not args.connection:
        args.connection = os.environ['CTP6_CONNECTION']

    if not args.links:
        log.debug("Using all links")
        args.links = range(48)
    else:
        args.links = list(api.expand_links(args.links))

    hw_connection = 'file://%s' % args.connection
    log.info("Setting up connection: %s", hw_connection)
    manager = uhal.ConnectionManager(hw_connection)

    hw = manager.getDevice('ctp6.frontend')

    commands = {'reset': do_reset, 'status': do_status, 'capture': do_capture}

    commands[args.command](hw, args)

    log.info("done.")

    return 0
Example #5
0
def main():
    parser = argparse.ArgumentParser()

    parser.add_argument("command", choices=['reset', 'status', 'capture'],
                        help="Action to perform")

    parser.add_argument("links", nargs='*', help="Specify links. "
                        "If none are specified, reset all.")

    parser.add_argument("--connection",
                        help="Manually connection XML file. "
                        "If not specified, take from CTP6_CONNECTION env.")
    parser.add_argument("--verbose", action='store_true',
                        help="Increase verbosity")

    parser_rst = parser.add_argument_group('reset')
    parser_stat = parser.add_argument_group('status')
    parser_cap = parser.add_argument_group('capture')

    # Reset arguments
    parser_rst.add_argument("--power-down", action='store_true',
                            dest='power_down',
                            help="Additionally power down the links")

    # Capture arguments
    parser_cap.add_argument("--orbit-capture-char", dest='capture_char',
                            type=str, metavar='0xbc', default='0xbc',
                            help="character to trigger capture "
                            "- default: %(default)s")

    parser_cap.add_argument("--nwords", dest='ncapture',
                            type=int, metavar='N', default=4,
                            help="Number of words to capture from each link"
                            "- default: 0x%(default)i")

    parser_cap.add_argument("--expected", metavar='pattern.txt',
                            help="Pattern file with 1 word/line in hex")

    args = parser.parse_args()

    if args.verbose:
        logging.basicConfig(level=logging.INFO)
        uhal.setLogLevelTo(uhal.LogLevel.WARNING)
    else:
        uhal.setLogLevelTo(uhal.LogLevel.WARNING)
        logging.basicConfig(level=logging.WARNING)

    if not args.connection:
        args.connection = os.environ['CTP6_CONNECTION']

    if not args.links:
        log.debug("Using all links")
        args.links = range(48)
    else:
        args.links = list(api.expand_links(args.links))

    hw_connection = 'file://%s' % args.connection
    log.info("Setting up connection: %s", hw_connection)
    manager = uhal.ConnectionManager(hw_connection)

    hw = manager.getDevice('ctp6.frontend')

    commands = {
        'reset': do_reset,
        'status': do_status,
        'capture': do_capture
    }

    commands[args.command](hw, args)

    log.info("done.")

    return 0