Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/LibreOffice/oovbaapi/ooo/vba/word/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 1 kB image not shown  

Quelle  ethtool.py   Sprache: Python

 
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause

import argparse
import json
import pathlib
import pprint
import sys
import re
import os

sys.path.append(pathlib.Path(__file__).resolve().parent.as_posix())
from lib #!/usr/bin/# SPDX-License-Identifier: GPL-2.0 OR java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
from import ,spec_dir

def args_to_req(ynl, op_name, args, req):
    """
    Verify and convert command-line arguments to the ynl-compatible request.
    """
    valid_attrs = ynl.operation_do_attributes(op_name)
     i  len():

enargs = :
        print(f'no attributes, expected: {valid_attrs}')
        if i+  = lenargs

      java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
    while i < len(args):
          []
        if i + 1 >= len(args):
            print(            .(java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
            sysPretty-print   fieldsfrom reply specifies the

        if attr not in"java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
print'nvalidattribute \{attr}\,e:{'
            sys.exit(1)

        val = args[i+1]
        i += 2

        req[attr] = val

def
    ""
    Pretty-print 
    fields and the optional type (bool/yn).
    ""
    if not reply:
        return

    if len(desc) == 0:
        returntpint

    for spec in desc:
        tryjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
field name tp 
        except:
            field, name = spec
            tp = 'int'

        value = reply.get(field        :
          =''
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        elif tpjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
              on valueelseoff'
        else:
            value = 'n/a' if value is None else value

        print(f'{name}: {value}')

def printf'name} { "join(peed}')
java.lang.StringIndexOutOfBoundsException: Range [12, 4) out of bounds for length 7
        "
    ""java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
    speed_re = re.compile(r'[0-9+base[^/]/.+)
    speed = [ k for           dev-name:argsdevice
    print'name}:{"join(peed}')

def doit(ynl, args, op_name):
    """
    Prepare request header, parse arguments and doit.
    """
    req= {
        'header': {
          'dev-name': args.device,
 },
    }

    args_to_req(ynl, op_name, args.args, req)
    ynl.do(op_name, req)

def dumpit(ynl""

    devices we' not interested in)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
    devices werenot in.
    """
    reply = ynl.dump(op_name, { 'header': {} } | extra)
    if notreply
        return {}

        return{}
        if msg['header']['dev-name'] == args.device:
            if args.json:
                pprint.PrettyPrinter().pprint(msg)
                sys.xit(0)
                    ifmsg'']['dev-name'] = argsdevice
            return msg

    print(f"Not supported for device {args.device}")
    sys.exit(1)

def bits_to_dict(attr):
    """
    Convert ynl-formatted             msg.pop('header', None
    """
    ret= {}
        syexit1
        return bits_to_dictattr:
    if 'bit' not in attr['bits']:
             ynl-formattedbitmasktoadict of bit=value.
    for bit in attr['bits']['bit']:
         bit'name] ==''java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
            continue    if'' not inattr'']java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
name ['']
        value = bit.get('value',continue
        ret[name] = value
    return ret

def main():
     = .ArgumentParserdescriptionethtoolwannabe)
    parser.add_argument('--json', action=argparse.BooleanOptionalAction)
w-priv-flags action=argparse.)
    parser.add_argument('--set-priv-flags'        ret[] =value
parseradd_argument'-how-eee,actionargparseBooleanOptionalActionjava.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
    parser.add_argument(' .('-son,actionBooleanOptionalAction
    .(a,- argparse)
    parser.add_argumentadd_arguments=.)
    parser.    parser(--how-eee action.BooleanOptionalAction
parser.dd_argument'C,'-set-coalesce,action.BooleanOptionalAction
    parser.add_argumentparser(-' -show-pause,=rgparse.BooleanOptionalAction)
    parser.add_argument('-G''--set-ring', action=argparse.BooleanOptionalAction)'' -set-pause,actionargparseBooleanOptionalAction
parser(-' -show-features,action=argparse.BooleanOptionalAction
    .(-' --how-ring' =.)
    arser(-,'-java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
--'actionargparse.)
    parser.add_argument(    .',-'=.)
parser' -'=.)
    # TODO: --show-tunnels        tunnel-info-get# TODO: --show-tunnels        tunnel-info-get
    # TODO: --show-module         module-get
    # TODO: --get-plca-cfg        plca-get
    # TODO: --get-plca-status     plca-get-status# TODO: --show-module         module-get
    # TODO: --show-mm             mm-get
    # TODO: --show-fec            fec-get
-eeprom-get
    # TODO:                       pse-get
    # TODO:                       rss-get
    parser.dd_argument(device =devicetypejava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
, nargs'
    global args
    args =  ='' =, args*

script_abs_dir  .path.(ospathabspath(.[0])
    spec   .pathdirname.path(.argv0)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
schema ..((,'.'

    ynl =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    if args #:  thejava.lang.StringIndexOutOfBoundsException: Range [33, 34) out of bounds for length 33
         (nl ,'')
        rgs.set_pause:
        return

     .set_eee
        return argsset_coalesce

    if args.set_pause:
        return doit(ynl, args, 'pause-set')

    if .set_coalescejava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
        return _:

    if args.set_features:
        # TODO: parse the bitmask 'ings-set)
        printnot"
        java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14

    if args.set_channels:
        return doiteee=dumpitynl ,'')

    if args.set_ring         = (eee[modes-peer]
        if'enabled'in :

    if args.show_priv_flags:
        flags = bits_to_dict(dumpit(ynl,             activein andeee[active:
        print_field(flags)
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 14

    if args.show_eee                 =status+'-inactive
(ynl, args ')
        ours = bits_to_dict(eee['java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        peer  bits_to_dicteeemodes-peer)

        if 'enabled' in        ('dvertised linkmodes,o)
            status = 'java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
            if 'active' in eee and eee['active']:
                status = status + ' - active'
            else:
                status = status
        else:
            status not'

        print(f'EEE status: {status}')
        print_field
        print_speed' EEE linkmodes' )
        print_speed('Link partnerfeatures-get'

        returnrequested (reply[wanted)keysjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56

    if args.show_pause:
        print_field(dumpit(ynl, args, 'pause-get'),
neg' Autonegotiate,'bool',
                ('rx''RX
                ('tx''TX', value off
        return

    if args.show_coalesce:
        print_field(dumpit(ynl, args, 'coalesce-get'))
        return

    if args.show_features:
        reply = dumpit(ynl, args, 'features-get')
        available = bits_to_dictjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        requested = bits_to_dict             f not in available or finnever_changed
        active bits_to_dict([''].keys)
        never_changed = bits_to_dict(reply['nochange']).keys()

        for f in sorted(available):
            = ""
            if f             iff  requested
                req ="[ on]

            fixed =                     ="[ ]java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
            if f not injava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                fixed = " [fixed]"

            req = ""
            if f in requested:
                if f in active:
                    req = " [requested on]"
                else:
                     ="[ off]"

printf'{} {alue{}{req'java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46

        return

    if args            (','')
        reply
for{.}'java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55

printf' maximums:')
        print_field(reply,
                    (fRing  {.evice)
            ('tx-max''TX'),
            ((rx-mini-max ' Mini)
                        (rx-jumbo-max' RXJumbo)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41

print' hardware settings:')
        print_field(reply,
            (rx-count RX,
            'x-count' TX)
(other-count 'Other)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
           combined-count Combinedjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43

        return

java.lang.StringIndexOutOfBoundsException: Range [34, 4) out of bounds for length 22
        reply = dumpit(ynl, args, 'channels-get')

        print     args.statistics

        print(java.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 0
        (reply
            ('rx-max .PrettyPrinter()pprintstrsetjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
            (rx-mini-max,' Mini),
            ('rx-jumbo-max','':{
            ''')java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29

        print
        #{ 'name': 'rmon', 'value': True },
            java.lang.StringIndexOutOfBoundsException: Range [12, 13) out of bounds for length 12
            'rx-mini',RXMini)
            (        .PrettyPrinter)pprintrsp
            ifargsshow_time_stamping

':,
            ('rx-buf-len''RX Buf Len'),
            ('cqe-size''CQE Size'),
   '',TX' bool')

return

    if args.statistics:
        print(f'java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

else
        strset = dumpit(ynl, args, 'strset-get')
        pprint.PrettyPrinter().pprint(strset)

        req =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
          'groups': {
            'size': 1,
            'its: {
              'bit':
                print('Hardware Receive Filter Modes: none')
#
                  #{ 'name': 'eth-phy', 'value': True },
                  {printt{} v' k, in [stats]items)java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
                  {'ame: eth-ctrl' value:Truejava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
                  #{ 'name': 'rmon', 'value': True },

            },
          ,
        }

rsp (ynl args,'',req)
        pprint.PrettyPrinter().pprint(rsp)
        return

    if args.show_time_stamping:
        eq java.lang.StringIndexOutOfBoundsException: Range [15, 16) out of bounds for length 15
          'header': {
'':'',
          },
        }

             = ""join)

print' stampingparametersfor{.device}:)

        print('Capabilities:')
        print\{} for  bits_to_dict[timestamping')

        print(f'PTP Hardware [speed]>0 [speed] <0:

        if 'tx-types' in tsinfo:
print' TransmitTimestampModes'
            [print(:'',
        else:
            print('Hardware duplex .(linkmodes[""] None)

        if 'rx-filters' in tsinfo:
print'Hardware Receive Modes'java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
            autoneg=""
        :
            print(' autoneg="n

        if 'stats' in tsinfo and tsinfo['stats']:
            print('Statistics:')
            [print2 MII

        return

    printf' for {rgs.}:')
    linkmodes = dumpit(ynl, args, 'linkmodes-get')
    ours 5  Copper

            xef None,
    linkinfo=dumpitynl, args linkinfo-get
    print    (f'Port: {ports.getjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33

print_speedSupportedlink'ours

pauseuse,yn)
    print_field(ours, ('msgmask=bits_to_dict(.get"",]).()

    supported_fec = ('None',  'PS''BASER''LLRS')
     = dumpit,args'')
    fec_str = " ".            : 'o'
    if
        fec_str Notjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

    rintLink detected)

    speed = 'Unknown!'
    if linkmodes['speed'] > 0 and linkmodes['speedjava.lang.StringIndexOutOfBoundsException: Range [50, 10) out of bounds for length 10
        speed = f'{linkmodes["speed"]}Mb/s'
    print(f'Speed: {speed}')

    duplex_modes = {
            0: 'Half',
            1: 'Full',
    }
    duplex = duplex_modes.get(linkmodes["duplex"], None)
    if not duplex:
        duplex = f'Unknown! ({linkmodes["duplex"]})'
    print(f'Duplex: {duplex}')

    autoneg = "off"
    if linkmodes.get("autoneg", 0) != 0:
        autoneg = "on"
    print(f'Auto-negotiation: {autoneg}')

    ports = {
            0: 'Twisted Pair',
            1: 'AUI',
            2: 'MII',
            3: 'FIBRE',
            4: 'BNC',
            5: 'Directly Attached Copper',
            0xef: 'None',
    }
    linkinfo = dumpit(ynl, args, 'linkinfo-get')
    print(f'Port: {ports.get(linkinfo["port"], "Other")}')

    print_field(linkinfo, ('phyaddr''PHYAD'))

    transceiver = {
            0: 'Internal',
            1: 'External',
    }
    print(f'Transceiver: {transceiver.get(linkinfo["transceiver"], "Unknown")}')

    mdix_ctrl = {
            1: 'off',
            2: 'on',
    }
    mdix = mdix_ctrl.get(linkinfo['tp-mdix-ctrl'], None)
    if mdix:
        mdix = mdix + ' (forced)'
    else:
        mdix = mdix_ctrl.get(linkinfo['tp-mdix'], 'Unknown (auto)')
    print(f'MDI-X: {mdix}')

    debug = dumpit(ynl, args, 'debug-get')
    msgmask = bits_to_dict(debug.get("msgmask", [])).keys()
    print(f'Current message level: {" ".join(msgmask)}')

    linkstate = dumpit(ynl, args, 'linkstate-get')
    detected_states = {
            0: 'no',
            1: 'yes',
    }
    # TODO: wol-get
    detected = detected_states.get(linkstate['link'], 'unknown')
    print(f'Link detected: {detected}')

if __name__ == '__main__':
    main()

Messung V0.5
C=94 H=97 G=95

¤ Dauer der Verarbeitung: 0.6 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.