コード例 #1
0
ファイル: dimi.py プロジェクト: kontron/python-hpi
def main():
    ep_str = sys.argv[1]
    dimi_num = int(sys.argv[2])
    try:
        test_num = int(sys.argv[3])
    except ValueError:
        test_num = None
        test_name = sys.argv[3]

    cancel_test = False
    if len(sys.argv) > 4:
        if sys.argv[4] == 'cancel':
            cancel_test = True
        else:
            params = None
            if len(sys.argv[4:]):
                params = [a.split('=', 1) for a in sys.argv[4:]]

    s = Session()
    s.open()

    s.discover()

    # set source
    ep = EntityPath()
    ep.from_string(ep_str)

    print 'Entity path is "%s"' % ep
    r = s.get_resources_by_entity_path(ep)[0]
    d = r.dimi_handler_by_num(dimi_num)

    if test_num is not None:
        t = d.test_list()[test_num]
    else:
        for test in d.test_list():
            if test.name == test_name:
                t = test
                break
        else:
            print 'No test with name "%s" found.' % test_name
            sys.exit(1)

    if cancel_test:
        t.cancel()
        print_dimi_status(t.status()[0])
        sys.exit(0)

    print_test_info(t)
    print 'Starting Test'
    t.start(params)
    print_dimi_status(t.status()[0])
    status = poll_unless_equal(lambda *f: t.status(*f)[0],
            SAHPI_DIMITEST_STATUS_RUNNING)
    print_dimi_status(status)
    print_result(t.results())
コード例 #2
0
ファイル: fumi.py プロジェクト: kontron/python-hpi
def main():
    try:
        s = Session()
        s.open()
        s.discover()

        # set source
        ep = EntityPath()
        ep.from_string(sys.argv[1])

        print 'Entity path is "%s"' % ep
        r = s.get_resources_by_entity_path(ep)[0]
        f = r.fumi_handler_by_num(fumi_num=int(sys.argv[2]))
        b = f.logical_bank()

        print 'Setting Source to "%s"' % (sys.argv[3],)
        b.set_source(sys.argv[3])

        # validation
        print '[1] Validate'
        b.start_validation()
        status = b.status()
        print '  Polling status'
        status = poll_unless_equal(b.status, SAHPI_FUMI_SOURCE_VALIDATION_INITIATED)
        print_fumi_status(status)
        if status != SAHPI_FUMI_SOURCE_VALIDATION_DONE:
            print 'FAILED'
            sys.exit(1)

        print '  Source image informations:'
        info = b.source_info()
        print """
        URI: %(source_uri)s
        Status: %(source_status)s
        Identifier: %(identifier)s
        Description: %(description)s
        Date: %(date_time)s
        Version: %(major_version)s.%(minor_version)s.%(aux_version)08x
    """[1:-1] % info.__dict__

        # installation
        print '[2] Install'
        b.start_installation()
        print '  Polling status'
        status = poll_unless_equal(b.status, SAHPI_FUMI_INSTALL_INITIATED)
        print_fumi_status(status)
        if status != SAHPI_FUMI_INSTALL_DONE:
            print 'FAILED'
            sys.exit(1)

        # activation
        print '[3] Activate'
        f.start_activation()
        print '  Polling status'
        status = poll_unless_equal(b.status, SAHPI_FUMI_ACTIVATE_INITIATED)
        print_fumi_status(status)
        if status != SAHPI_FUMI_ACTIVATE_DONE:
            print 'FAILED'
            sys.exit(1)

        # cleanup
        print '[4] Cleanup'
        b.cleanup()

        s.close()
    except SaHpiError, e:
        print 'ERROR: %s' % e.error