예제 #1
0
def getHtmlPageFromCsvFile(filePath, css, title):
    """ Prepare a html page including a table """
    myHtml = html(
        head(
            link(' ', rel='stylesheet', type='text/css', href=css),
            title=filePath
            )
        )
    myHtml = myHtml.append(
        body(
            h1(title),
            getHtmlTableFromCsvFile(filePath),
            )
        )
    return myHtml
예제 #2
0
def to_html(results):
    PREAMBLE_FILE = os.getenv('LSM_PREAMBLE_FILE', "")
    preamble = ""
    methods = [
        'capabilities', 'systems', 'plugin_info', 'pools', 'job_status',
        'job_free', 'iscsi_chap_auth', 'volumes', 'volume_create',
        'volume_delete', 'volume_resize', 'volume_replicate',
        'volume_replicate_range_block_size', 'volume_replicate_range',
        'volume_enable', 'volume_disable', 'disks', 'target_ports',
        'volume_mask', 'volume_unmask', 'volume_child_dependency',
        'volume_child_dependency_rm', 'access_groups',
        'access_groups_granted_to_volume', 'access_group_create',
        'access_group_delete', 'volumes_accessible_by_access_group',
        'access_groups_granted_to_volume', 'access_group_initiator_add',
        'access_group_initiator_delete', 'fs', 'fs_create', 'fs_delete',
        'fs_resize', 'fs_clone', 'fs_file_clone', 'fs_snapshots',
        'fs_snapshot_create', 'fs_snapshot_delete', 'fs_snapshot_restore',
        'fs_child_dependency', 'fs_child_dependency_rm', 'export_auth',
        'exports', 'export_fs', 'export_remove'
    ]

    ch = []
    row_data = []

    if os.path.isfile(PREAMBLE_FILE):
        with open(PREAMBLE_FILE, 'r') as pm:
            preamble = pm.read()

    #Build column header
    for r in results:
        ch.append(r['SYSTEM']['ID'])

    # Add overall pass/fail for unit tests
    pass_fail = ['Overall Pass/Fail result']
    for r in results:
        if r['META']['ec'] == '0':
            pass_fail.append('P')
        else:
            pass_fail.append('F')
    row_data.append(pass_fail)

    # Append on link for error log
    error_log = ['Error log (click +)']
    for r in results:
        error_log.append('<a href="%s">+</a>' %
                         ('./' + os.path.basename(r['META']['error_file'])))
    row_data.append(error_log)

    for m in methods:
        row = [m]

        for r in results:
            row.append(get_result(r, m))

        row_data.append(row)

    # Build HTML
    text = '<!DOCTYPE html>'
    text += str(
        html(
            head(
                link(rel="stylesheet", type="text/css", href="../../test.css"),
                title("libStorageMgmt test results"),
            ),
            body(
                HTML(
                    h1("%s Results generated @ %s") %
                    (preamble, time.strftime("%c"))),
                div(table(_table_header(ch), _table_body(row_data)),
                    _class="angled_table"),
                div(
                    pre("                  Legend\n"
                        "                  P = Pass (Method called and returned without error)\n"
                        "                  F = Fail (Method call returned an error)\n"
                        "                  U = Unsupported or unable to test due to other errors\n"
                        "                  * = Unable to connect to array or provider totally unsupported\n"
                        "                  + = hyper link to error log")))))

    return bs(text).prettify()
예제 #3
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        if not path:
            start_response('200 OK', [('Content-Type', 'text/html')])

            return [
                '%s%s' % (
                    '<!doctype html>',
                    str(
                        h.html(
                            h.head(h.meta(charset='UTF-8'),
                                   h.title('socketio echo test')),
                            h.script(src="/static/jquery-1.6.1.min.js",
                                     type="text/javascript"),
                            h.script(src="/static/socket.io.js",
                                     type="text/javascript"),
                            h.script(src="/static/echo.js",
                                     type="text/javascript"),
                            h.body(
                                h.p('''
							This is an echo test for socketio.
							When you enter values for 'bar' and 'baz'
							and push 'emit', they'll be sent over a socket,
							received by the server ('foo()'), and echoed back via
							emitting 'echo' with 'rab' and 'zab'.
							(no HTTP GET or POST is executed!)
							'''),
                                h.hr(),
                                h.form('bar: ',
                                       h.input(type='text', id='bar'),
                                       ' ',
                                       'baz: ',
                                       h.input(type='text', id='baz'),
                                       h.button('Emit', type='submit'),
                                       id='foo'),
                                h.hr(),
                                h.p(
                                    # These will get values subbed in via javascript when rab and zab are echoed from server:
                                    'rab: ',
                                    h.span(id='rab'),
                                    ' ',
                                    'zab: ',
                                    h.span(id='zab'))))))
            ]

        if path.startswith('static/'):
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"  # we don't have any other types in this simple example, so...
            else:
                return not_found(start_response)

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'/echo': EchoNamespace}, {})
        else:
            return not_found(start_response)
예제 #4
0
def to_html(results):
    PREAMBLE_FILE = os.getenv('LSM_PREAMBLE_FILE', "")
    preamble = ""
    methods = ['capabilities',
               'systems', 'plugin_info', 'pools', 'job_status', 'job_free',
               'iscsi_chap_auth',
               'volumes', 'volume_create', 'volume_delete', 'volume_resize',
               'volume_replicate', 'volume_replicate_range_block_size',
               'volume_replicate_range', 'volume_enable', 'volume_disable',
               'disks', 'target_ports',
               'volume_mask',
               'volume_unmask',
               'volume_child_dependency',
               'volume_child_dependency_rm',
               'access_groups',
               'access_groups_granted_to_volume',
               'access_group_create',
               'access_group_delete',
               'volumes_accessible_by_access_group',
               'access_groups_granted_to_volume',
               'access_group_initiator_add',
               'access_group_initiator_delete',
               'fs',
               'fs_create',
               'fs_delete',
               'fs_resize',
               'fs_clone',
               'fs_file_clone',
               'fs_snapshots',
               'fs_snapshot_create',
               'fs_snapshot_delete',
               'fs_snapshot_restore',
               'fs_child_dependency',
               'fs_child_dependency_rm',
               'export_auth',
               'exports',
               'export_fs',
               'export_remove'
               ]

    ch = []
    row_data = []

    if os.path.isfile(PREAMBLE_FILE):
        with open(PREAMBLE_FILE, 'r') as pm:
            preamble = pm.read()

    #Build column header
    for r in results:
        ch.append(r['SYSTEM']['ID'])

    # Add overall pass/fail for unit tests
    pass_fail = ['Overall Pass/Fail result']
    for r in results:
        if r['META']['ec'] == '0':
            pass_fail.append('P')
        else:
            pass_fail.append('F')
    row_data.append(pass_fail)

    # Append on link for error log
    error_log = ['Error log (click +)']
    for r in results:
        error_log.append('<a href="%s">+</a>' %
                         ('./' + os.path.basename(r['META']['error_file'])))
    row_data.append(error_log)

    for m in methods:
        row = [m]

        for r in results:
            row.append(get_result(r, m))

        row_data.append(row)

    # Build HTML
    text = '<!DOCTYPE html>'
    text += str(html(
                head(link(rel="stylesheet", type="text/css",
                          href="../../test.css"),
                title("libStorageMgmt test results"), ),
                body(
                    HTML(h1("%s Results generated @ %s") % (preamble, time.strftime("%c"))),
                    div(table(_table_header(ch), _table_body(row_data)),
                         _class="angled_table"),
                    div(pre(
                           "                  Legend\n"
                           "                  P = Pass (Method called and returned without error)\n"
                           "                  F = Fail (Method call returned an error)\n"
                           "                  U = Unsupported or unable to test due to other errors\n"
                           "                  * = Unable to connect to array or provider totally unsupported\n"
                           "                  + = hyper link to error log\n\n\n",
                           HTML('                  Source code for plug-in for this test run <a href=./smis.py.html>is here. </a>'))))
                ))

    return bs(text).prettify()