예제 #1
0
    def test02_dir(self):
        """For the same reasons as test01_kdcraw, this used to crash."""

        import cppyy, pydoc

        assert not '__abstractmethods__' in dir(cppyy.gbl.gInterpreter)
        assert '__class__' in dir(cppyy.gbl.gInterpreter)

        self.__class__.helpout = []
        pydoc.doc(cppyy.gbl.gInterpreter)
        helptext = ''.join(self.__class__.helpout)
        assert 'TInterpreter' in helptext
        assert 'CPPInstance' in helptext
        assert 'AddIncludePath' in helptext

        cppyy.cppdef("namespace cppyy_regression_test { void iii() {}; }")

        assert not 'iii' in cppyy.gbl.cppyy_regression_test.__dict__
        assert not '__abstractmethods__' in dir(cppyy.gbl.cppyy_regression_test)
        assert '__class__' in dir(cppyy.gbl.cppyy_regression_test)
        assert 'iii' in dir(cppyy.gbl.cppyy_regression_test)

        assert not 'iii' in cppyy.gbl.cppyy_regression_test.__dict__
        assert cppyy.gbl.cppyy_regression_test.iii
        assert 'iii' in cppyy.gbl.cppyy_regression_test.__dict__

        self.__class__.helpout = []
        pydoc.doc(cppyy.gbl.cppyy_regression_test)
        helptext = ''.join(self.__class__.helpout)
        assert 'CPPInstance' in helptext
예제 #2
0
def helpsql(line):
    """
    IPython extension function for getting documentaion on sql related functions in readSqlExt extension.
    :return: None
    """
    module_ = pydoc.importfile(__file__)
    pydoc.doc(module_)
예제 #3
0
    def test02_dir(self):
        """For the same reasons as test01_kdcraw, this used to crash."""

        import cppyy, pydoc

        assert not '__abstractmethods__' in dir(cppyy.gbl.gInterpreter)
        assert '__class__' in dir(cppyy.gbl.gInterpreter)

        self.__class__.helpout = []
        pydoc.doc(cppyy.gbl.gInterpreter)
        helptext = ''.join(self.__class__.helpout)
        assert 'TInterpreter' in helptext
        assert 'CPPInstance' in helptext
        assert 'AddIncludePath' in helptext

        cppyy.cppdef("namespace cppyy_regression_test { void iii() {}; }")

        assert not 'iii' in cppyy.gbl.cppyy_regression_test.__dict__
        assert not '__abstractmethods__' in dir(cppyy.gbl.cppyy_regression_test)
        assert '__class__' in dir(cppyy.gbl.cppyy_regression_test)
        assert 'iii' in dir(cppyy.gbl.cppyy_regression_test)

        assert not 'iii' in cppyy.gbl.cppyy_regression_test.__dict__
        assert cppyy.gbl.cppyy_regression_test.iii
        assert 'iii' in cppyy.gbl.cppyy_regression_test.__dict__

        self.__class__.helpout = []
        pydoc.doc(cppyy.gbl.cppyy_regression_test)
        helptext = ''.join(self.__class__.helpout)
        # TODO: it's deeply silly that namespaces inherit from CPPInstance (in CPyCppyy)
        assert ('CPPInstance' in helptext or 'CPPNamespace' in helptext)
예제 #4
0
    def test01_kdcraw(self):
        """Doc strings for KDcrawIface (used to crash)."""

        import cppyy, pydoc

        # TODO: run a find for these paths
        qtpath = "/usr/include/qt5"
        kdcraw_h = "/usr/include/KF5/KDCRAW/kdcraw/kdcraw.h"
        if not os.path.isdir(qtpath) or not os.path.exists(kdcraw_h):
            py.test.skip("no KDE/Qt found, skipping test01_kdcraw")

        # need to resolve qt_version_tag for the incremental compiler; since
        # it's not otherwise used, just make something up
        cppyy.cppdef("int qt_version_tag = 42;")
        cppyy.add_include_path(qtpath)
        cppyy.include(kdcraw_h)

        # bring in some symbols to resolve the class
        cppyy.load_library("libQt5Core.so")
        cppyy.load_library("libKF5KDcraw.so")

        from cppyy.gbl import KDcrawIface

        self.__class__.helpout = []
        pydoc.doc(KDcrawIface.KDcraw)
        helptext  = ''.join(self.__class__.helpout)
        assert 'KDcraw' in helptext
        assert 'CPPInstance' in helptext
예제 #5
0
    def test01_kdcraw(self):
        """Doc strings for KDcrawIface (used to crash)."""

        import cppyy, pydoc

        # TODO: run a find for these paths
        qtpath = "/usr/include/qt5"
        kdcraw_h = "/usr/include/KF5/KDCRAW/kdcraw/kdcraw.h"
        if not os.path.isdir(qtpath) or not os.path.exists(kdcraw_h):
            import warnings
            warnings.warn("no KDE/Qt found, skipping test01_kdcraw")
            return

        # need to resolve qt_version_tag for the incremental compiler; since
        # it's not otherwise used, just make something up
        cppyy.cppdef("int qt_version_tag = 42;")
        cppyy.add_include_path(qtpath)
        cppyy.include(kdcraw_h)

        from cppyy.gbl import KDcrawIface

        self.__class__.helpout = []
        pydoc.doc(KDcrawIface.KDcraw)
        helptext  = ''.join(self.__class__.helpout)
        assert 'KDcraw' in helptext
        assert 'CPPInstance' in helptext
예제 #6
0
def main():
    """ 
    Print the documentation then perform the demonstration(s).
    """
    print(plain(doc(static_route_delete)))

    print('Determine which devices are capable.')
    print('inventory_static_route()')
    inventory = inventory_static_route()
    print_table(inventory, headers='device-name')
    if not inventory:
        print(
            "There are no 'static route' capable devices. Demonstration cancelled."
        )
    else:
        print()
        for device_name in inventory:
            print('static_route_list(%s)' % device_name)
            route_list = static_route_list(device_name)
            print_table(route_list, headers='destination-network')
            print()
            if route_list:
                demonstrate_one(device_name, route_list[0])
                if len(route_list) > 1:
                    demonstrate_all(device_name)
                return EX_OK
        print(
            "There are no devices with a 'static route' configured. Demonstration cancelled."
        )
    return EX_TEMPFAIL
def main():
    print(plain(doc(device_dismount)))
    for device_name in inventory_mounted():
        demonstrate(device_name)
        return os.EX_OK
    print('There are no mounted devices to dismount. Demonstration cancelled.')
    return os.EX_TEMPFAIL
def main():
    """
    Print the function documentation then demonstrate the function usage.
    """
    print(plain(doc(inventory_static_route)))
    
    return EX_OK if demonstrate() else EX_TEMPFAIL
def main():
    """ 
    Print the documentation then perform the demonstration(s).
    """
    print(plain(doc(static_route_json)))

    print('Determine which devices are capable.')
    print('inventory_static_route()')
    inventory = inventory_static_route()
    if not inventory:
        print(None)
        print(
            "There are no 'static route' capable devices. Demonstration cancelled."
        )
    else:
        print_table(inventory)
        print()
        for device_name in inventory:
            route_list = demonstrate_all(device_name)
            if route_list:
                return EX_OK if demonstrate_one(device_name,
                                                route_list[0]) else EX_TEMPFAIL
            else:
                print()
        print(
            "There are no devices with a 'static route' configured. Demonstration cancelled."
        )
    return EX_TEMPFAIL
def main():
    """ 
    Print the documentation then perform the demonstration(s).
    """
    print(plain(doc(static_route_delete)))

    print('Determine which devices are capable.')
    print('inventory_static_route()')
    inventory = inventory_static_route()
    print_table(inventory, headers='device-name')
    if not inventory:
        print("There are no 'static route' capable devices. Demonstration cancelled.")
    else:
        print()
        for device_name in inventory:
            print('static_route_list(%s)' % device_name)
            route_list = static_route_list(device_name)
            print_table(route_list, headers='destination-network')
            print()
            if route_list:
                demonstrate_one(device_name, route_list[0])
                if len(route_list) > 1:
                    demonstrate_all(device_name)
                return EX_OK
        print("There are no devices with a 'static route' configured. Demonstration cancelled.")
    return EX_TEMPFAIL
def main():
    print(plain(doc(device_dismount)))
    for device_name in inventory_mounted():
        demonstrate(device_name)
        return EX_OK
    print('There are no mounted devices to dismount. Demonstration cancelled.')
    return EX_TEMPFAIL
예제 #12
0
def main():
    print(plain(doc(inventory_summary)))
    print('InventorySummary fields:',
          *InventorySummary._fields,
          sep='\n\t',
          end='\n\n')
    print_table(inventory_summary())
def main():
    ''' Document and demonstrate the function.'''
    print(plain(doc(inventory_static_route)))
    if demonstrate():
        return os.EX_OK
    else:
        return os.EX_TEMPFAIL
def main():
    ''' Select a device and demonstrate.'''
    print(plain(doc(acl_apply_packet_filter)))
    inventory = inventory_acl()
    if not inventory:
        print(
            'There are no ACL capable devices to examine. Demonstration cancelled.'
        )
    else:
        for device_name in inventory:
            mgmt_name = management_interface(device_name)
            acl_names = acl_list(device_name)
            if not acl_names:
                print('Skip device with no ACLs: ', device_name)
                continue
            else:
                random.shuffle(acl_names)
                acl_name = acl_names[0]
            for ic in interface_configuration_tuple(device_name):
                if ic.name == mgmt_name:
                    continue
                print('Consider %s %s in=%s, out=%s' %
                      (device_name, ic.name, ic.packet_filter_inbound,
                       ic.packet_filter_outbound))
                if not ic.packet_filter_outbound:
                    demonstrate(device_name, ic.name, 'outbound', acl_name)
                    return os.EX_OK
                if not ic.packet_filter_inbound:
                    demonstrate(device_name, ic.name, 'inbound', acl_name)
                    return os.EX_OK
        print(
            'There are no network interfaces available to apply an ACL. Demonstration cancelled.'
        )
    return os.EX_TEMPFAIL
예제 #15
0
def main():
    ''' Document and demonstrate the function.'''
    print(plain(doc(inventory_acl)))
    if demonstrate():
        return os.EX_OK
    else:
        return os.EX_TEMPFAIL
def main():
    print(plain(doc(device_mount)))
    for device_name in inventory_unmounted():
        demonstrate(device_name)
        return os.EX_OK
    print('All configured devices are mounted. Demonstration cancelled.')
    return os.EX_TEMPFAIL
예제 #17
0
def draw():
    """ Select a device/interface and demonstrate."""
    print(plain(doc(interface_configuration)))
    foundInterface = False

    G = nx.Graph()

    for device_name in sorted(inventory_connected()):
        G.add_node(device_name)
        print("%s:" % device_name)
        mgmt_name = management_interface(device_name)
        for interface_name in sorted(interface_names(device_name)):
            # Choose interface on 'data plane' not 'control plane'.
            if interface_name == mgmt_name:
                continue
            else:
                match(device_name, interface_name)
                foundInterface = True
                demonstrate(device_name, interface_name)
                to_interface = interface_configuration(device_name, interface_name)[1].split(" ")[1]
                print("interface:%s" % to_interface)
                G.add_edge(device_name, to_interface)
        if not foundInterface:
            print("There are no suitable network interfaces for this device.")

    print(G.nodes())
    print(G.edges())
    # nx.draw(G)
    nx.draw_networkx(G, with_labels=True)
    plt.show()
def main():
    ''' Select a device and demonstrate.'''
    print(plain(doc(acl_apply_packet_filter)))
    inventory = inventory_acl()
    if not inventory:
        print('There are no ACL capable devices to examine. Demonstration cancelled.')
    else:
        for device_name in inventory:
            mgmt_name = management_interface(device_name)
            acl_names = acl_list(device_name)
            if not acl_names:
                print('Skip device with no ACLs: ', device_name)
                continue
            else:
                random.shuffle(acl_names)
                acl_name = acl_names[0]
            for ic in interface_configuration_tuple(device_name):
                if ic.name == mgmt_name:
                    continue
                print('Consider %s %s in=%s, out=%s' % (device_name, ic.name, ic.packet_filter_inbound, ic.packet_filter_outbound))
                if not ic.packet_filter_outbound:
                    demonstrate(device_name, ic.name, 'outbound', acl_name)
                    return EX_OK
                if not ic.packet_filter_inbound:
                    demonstrate(device_name, ic.name, 'inbound', acl_name)
                    return EX_OK
        print('There are no network interfaces available to apply an ACL. Demonstration cancelled.')
    return EX_TEMPFAIL
예제 #19
0
def main():
    print(plain(doc(device_mount)))
    for device_name in inventory_unmounted():
        demonstrate(device_name)
        return os.EX_OK
    print('All configured devices are mounted. Demonstration cancelled.')
    return os.EX_TEMPFAIL
예제 #20
0
def main():
    """ 
    Print the function documentation then demonstrate the function usage on a selected device.
     
    Repeat for another device if no 'static route' is configured.
    """
    print(plain(doc(static_route_list)))

    print('Determine which devices are capable.')
    print('inventory_static_route()')
    device_names = inventory_static_route()
    if not device_names:
        print(
            "There are no 'static route' capable devices to examine. Demonstration cancelled."
        )
    else:
        print_table(device_names, headers='device-name')
        print()
        for device_name in device_names:
            if demonstrate(device_name):
                return EX_OK
        print(
            "There are no devices with a 'static route' configured. Demonstration cancelled."
        )
    return EX_TEMPFAIL
예제 #21
0
def main():
    ''' Select a device and demonstrate.'''
    print(plain(doc(management_interface)))
    for device_name in inventory_mounted():
        demonstrate(device_name)
        return EX_OK
    print("There are no suitable network devices. Demonstration cancelled.")
    return EX_TEMPFAIL
def main():
    print(plain(doc(connected)))
    device_names = inventory_mounted()
    if not device_names:
        print('There are no devices mounted on the Controller.')
    else:
        device_name = device_names[0]
        print('is connected(%s):' % device_name, connected(device_name))
def main():
    ''' Select a device and demonstrate.'''
    print(plain(doc(management_interface)))
    for device_name in inventory_mounted():
        demonstrate(device_name)
        return os.EX_OK
    print("There are no suitable network devices. Demonstration cancelled.")
    return os.EX_TEMPFAIL
def main():
    print(plain(doc(mounted)))
    device_names = settings.config['network_device'].keys()
    if not device_names:
        print('There are no devices configured in the settings.')
    else:
        device_name = next(iter(device_names))
        print('is mounted(%s):' % device_name, mounted(device_name))
def main():
    print(plain(doc(connected)))
    device_names = inventory_mounted()
    if not device_names:
        print('There are no devices mounted on the Controller.')
    else:
        device_name = device_names[0]
        print('is connected(%s):' % device_name, connected(device_name))
def main():
    print(plain(doc(mounted)))
    device_names = settings.config['network_device'].keys()
    if not device_names:
        print('There are no devices configured in the settings.')
    else:
        device_name = next(iter(device_names))
        print('is mounted(%s):' % device_name, mounted(device_name))
예제 #27
0
def main():
    """ Select a device and demonstrate."""
    print(plain(doc(device_control)))
    print("DeviceControl fields:", *DeviceControl._fields, sep="\n\t", end="\n\n")
    for device_name in inventory_mounted():
        demonstrate(device_name)
        return EX_OK
    print("There are no suitable network devices. Demonstration cancelled.")
    return EX_TEMPFAIL
예제 #28
0
    def test03_pyfunc_doc(self):
        """Help on a generated pyfunc used to crash."""

        import cppyy, distutils, pydoc, sys

        cppyy.add_include_path(distutils.sysconfig_get_python_inc())
        if sys.hexversion < 0x3000000:
            cppyy.cppdef("#undef _POSIX_C_SOURCE")
            cppyy.cppdef("#undef _XOPEN_SOURCE")
        else:
            cppyy.cppdef("#undef slots")     # potentially pulled in by Qt/xapian.h

        cppyy.cppdef("""#include "Python.h"
           long py2long(PyObject* obj) { return PyLong_AsLong(obj); }""")

        pydoc.doc(cppyy.gbl.py2long)

        assert 1 == cppyy.gbl.py2long(1)
def main():
    print(plain(doc(device_dismount)))
    mounted_list = inventory_mounted()
    if not mounted_list:
        print("There are no mounted devices to dismount.")
    else:
        for device_name in mounted_list:
            print("device_dismount(" + device_name, end=")\n")
            device_dismount(device_name)
def main():
    ''' Select a device and demonstrate.'''
    print(plain(doc(interface_names)))
    mounted_list = inventory_mounted()
    connected_list = inventory_connected()
    device_list = list(set(connected_list) & set(mounted_list))
    for device_name in device_list:
        return demonstrate(device_name)
    print('There are no mounted, connected devices to examine. Demonstration cancelled.')
예제 #31
0
def main():
    ''' Select a device and demonstrate.'''
    print(plain(doc(device_control)))
    print('DeviceControl fields:', *DeviceControl._fields, sep='\n\t', end='\n\n')
    for device_name in inventory_mounted():
        demonstrate(device_name)
        return os.EX_OK
    print("There are no suitable network devices. Demonstration cancelled.")
    return os.EX_TEMPFAIL
def main():
    print(plain(doc(device_dismount)))
    mounted_list = inventory_mounted()
    if not mounted_list:
        print('There are no mounted devices to dismount.')
    else:
        for device_name in mounted_list:
            print('device_dismount(' + device_name, end=')\n')
            device_dismount(device_name)
예제 #33
0
    def test03_pyfunc_doc(self):
        """Help on a generated pyfunc used to crash."""

        import cppyy, distutils, pydoc, sys
        import distutils.sysconfig as sc

        cppyy.add_include_path(sc.get_python_inc())
        if sys.hexversion < 0x3000000:
            cppyy.cppdef("#undef _POSIX_C_SOURCE")
            cppyy.cppdef("#undef _XOPEN_SOURCE")
        else:
            cppyy.cppdef("#undef slots")     # potentially pulled in by Qt/xapian.h

        cppyy.cppdef("""#include "Python.h"
           long py2long(PyObject* obj) { return PyLong_AsLong(obj); }""")

        pydoc.doc(cppyy.gbl.py2long)

        assert 1 == cppyy.gbl.py2long(1)
def main():
    ''' Select a device/interface and demonstrate.'''
    print(plain(doc(interface_configuration_tuple)))
    for device_name in inventory_connected():
        mgmt_name = management_interface(device_name)
        for interface_name in interface_names(device_name):
            # Choose interface on 'data plane' not 'control plane'.
            if interface_name == mgmt_name:
                continue
            return demonstrate(device_name, interface_name)
    print("There are no suitable network devices. Demonstration cancelled.")
def main():
    ''' Select a device and demonstrate on potential routes, repeat until information found.'''
    print(plain(doc(static_route_json)))
    inventory = inventory_static_route()
    if not inventory:
        print("There are no 'static route' capable devices to examine. Demonstration cancelled.")
    else:
        for device_name in inventory:
            if demonstrate(device_name):
                return os.EX_OK
    return os.EX_TEMPFAIL
def main():
    ''' Select a device and demonstrate.'''
    print(plain(doc(interface_names)))
    mounted_list = inventory_mounted()
    connected_list = inventory_connected()
    device_list = list(set(connected_list) & set(mounted_list))
    for device_name in device_list:
        return demonstrate(device_name)
    print(
        'There are no mounted, connected devices to examine. Demonstration cancelled.'
    )
예제 #37
0
def main():
    print(plain(doc(inventory_json)))
    print('Summary of lengthy JSON response:')
    print(*[
        InventorySummary(
            item[name_field],
            connected_field in item and item[connected_field],
            len(item[capability_field]) if capability_field in item else 0
        )
        for item in inventory_json()
    ], sep='\n')
예제 #38
0
def main():
    ''' Select a device and demonstrate.'''
    print(plain(doc(acl_list)))
    inventory = inventory_acl()
    if not inventory:
        print('There are no ACL capable devices to examine. Demonstration cancelled.')
    else:
        for device_name in inventory:
            if demonstrate(device_name):
                return EX_OK
    return EX_TEMPFAIL
예제 #39
0
def main():
    ''' Select a device and demonstrate, repeat until one ACL found.'''
    print(plain(doc(acl_json_all)))
    inventory = inventory_acl()
    if not inventory:
        print('There are no ACL capable devices to examine. Demonstration cancelled.')
    else:
        for device_name in inventory:
            if demonstrate(device_name):
                return os.EX_OK
    return os.EX_TEMPFAIL
def main():
    """ Select a device and demonstrate. If no information is found then retry with a different device."""
    print(plain(doc(static_route_list)))
    device_names = inventory_static_route()
    if not device_names:
        print("There are no 'static route' capable devices to examine. Demonstration cancelled.")
    else:
        for device_name in device_names:
            if demonstrate(device_name):
                return os.EX_OK
    return os.EX_TEMPFAIL
def main():
    print(plain(doc(inventory_json)))
    print('Summary of lengthy JSON response:')
    print(*[
        InventorySummary(
            item[name_field], connected_field in item
            and item[connected_field],
            len(item[capability_field]) if capability_field in item else 0)
        for item in inventory_json()
    ],
          sep='\n')
def main():
    ''' Select a device/interface and demonstrate.'''
    print(plain(doc(interface_configuration)))
    for device_name in inventory_connected():
        mgmt_name = management_interface(device_name)
        for interface_name in interface_names(device_name):
            # Choose interface on 'data plane' not 'control plane'.
            if interface_name == mgmt_name:
                continue
            return demonstrate(device_name, interface_name)
    print("There are no suitable network devices. Demonstration cancelled.")
예제 #43
0
def main():
    ''' Select a device and demonstrate for each acl_sample ACL.'''
    print(plain(doc(acl_exists)))
    inventory = inventory_acl()
    if not inventory:
        print('There are no ACL capable devices to examine. Demonstration cancelled.')
    else:
        for device_name in inventory:
            for acl_sample in acl_fixture.fixtures:
                demonstrate(device_name, acl_sample.name)
            return EX_OK
    return EX_TEMPFAIL
예제 #44
0
def main():
    print(plain(doc(interface_configuration_update)))
    for device_name in inventory_connected():
        mgmt_name = management_interface(device_name)
        for interface_name in interface_names(device_name):
            # Avoid modifying the management interface.
            if interface_name == mgmt_name:
                continue
            demonstrate(device_name, interface_name)
            return EX_OK
    print("There are no suitable network devices. Demonstration cancelled.")
    return EX_TEMPFAIL
def main():
    ''' Select a device and demonstrate.'''
    print(plain(doc(device_control)))
    print('DeviceControl fields:',
          *DeviceControl._fields,
          sep='\n\t',
          end='\n\n')
    for device_name in inventory_mounted():
        demonstrate(device_name)
        return EX_OK
    print("There are no suitable network devices. Demonstration cancelled.")
    return EX_TEMPFAIL
def main():
    print(plain(doc(interface_configuration_update)))
    for device_name in inventory_connected():
        mgmt_name = management_interface(device_name)
        for interface_name in interface_names(device_name):
            # Avoid modifying the management interface.
            if interface_name == mgmt_name:
                continue
            demonstrate(device_name, interface_name)
            return os.EX_OK
    print("There are no suitable network devices. Demonstration cancelled.")
    return os.EX_TEMPFAIL
예제 #47
0
def main():
    ''' Select a device and demonstrate with each ACL.'''
    print(plain(doc(acl_create_port_grant)))
    inventory = inventory_acl()
    if not inventory:
        print('There are no ACL capable devices to examine. Demonstration cancelled.')
    else:
        try:
            demonstrate(device_name, acl_name, acl_port, acl_grant, acl_protocol)
            return EX_OK
        except Exception as e:
            print(e)
    return EX_TEMPFAIL
예제 #48
0
def main():
    ''' Select a device and demonstrate, repeat until one ACL found.'''
    print(plain(doc(acl_json_all)))
    inventory = inventory_acl()
    if not inventory:
        print(
            'There are no ACL capable devices to examine. Demonstration cancelled.'
        )
    else:
        for device_name in inventory:
            if demonstrate(device_name):
                return os.EX_OK
    return os.EX_TEMPFAIL
예제 #49
0
def main():
    ''' Select a capable device and demonstrate.'''
    print(plain(doc(static_route_create)))
    print('inventory_static_route()')
    device_names = inventory_static_route()
    print('\t', device_names)
    if not device_names:
        print("There are no 'static route' capable devices to examine. Demonstration cancelled.")
    else:
        for device_name in device_names:
            if demonstrate(device_name):
                return os.EX_OK
    return os.EX_TEMPFAIL
def main():
    print(plain(doc(device_dismount)))
    assert not mounted(device_name)
    try:
        print('device_dismount(' + device_name, end=')\n')
        device_dismount(device_name)
        exception = False
        print('no exception')
    except Exception:
        exception = True
    finally:
        print('exception:', exception)
        assert not mounted(device_name)
def main():
    ''' Select a device and demonstrate. Retry with a different device until information is deleted.'''
    print(plain(doc(static_route_delete)))
    print('inventory_static_route()')
    device_names = inventory_static_route()
    print('\t', device_names)
    if not device_names:
        print("There are no 'static route' capable devices to examine. Demonstration cancelled.")
    else:
        for device_name in device_names:
            if demonstrate(device_name):
                return os.EX_OK
    return os.EX_TEMPFAIL
def main():
    ''' Select a device and demonstrate for each potential static route prefix.'''
    print(plain(doc(static_route_exists)))
    print('inventory_static_route()')
    device_names = inventory_static_route()
    print('\t', device_names)
    if not device_names:
        print("There are no 'static route' capable devices to examine. Demonstration cancelled.")
    else:
        for device_name in device_names:
            if demonstrate(device_name):
                return os.EX_OK
    return os.EX_TEMPFAIL
def main():
    ''' Select a device and demonstrate, repeat until information found.'''
    print(plain(doc(static_route_json_all)))
    inventory = inventory_static_route()
    if not inventory:
        print(
            "There are no 'static route' capable devices to examine. Demonstration cancelled."
        )
    else:
        for device_name in inventory:
            if demonstrate(device_name):
                return os.EX_OK
    return os.EX_TEMPFAIL
def main():
    print(plain(doc(device_dismount)))
    assert not mounted(device_name)
    try:
        print('device_dismount(' + device_name, end=')\n')
        device_dismount(device_name)
        exception = False
        print('no exception')
    except Exception:
        exception = True
    finally:
        print('exception:', exception)
        assert not mounted(device_name)
예제 #55
0
def main():
    """ Select a device and demonstrate. If no information is found then retry with a different device."""
    print(plain(doc(static_route_list)))
    device_names = inventory_static_route()
    if not device_names:
        print(
            "There are no 'static route' capable devices to examine. Demonstration cancelled."
        )
    else:
        for device_name in device_names:
            if demonstrate(device_name):
                return os.EX_OK
    return os.EX_TEMPFAIL
예제 #56
0
def main():
    ''' Select a device and demonstrate for each acl_sample ACL.'''
    print(plain(doc(acl_exists)))
    inventory = inventory_acl()
    if not inventory:
        print(
            'There are no ACL capable devices to examine. Demonstration cancelled.'
        )
    else:
        for device_name in inventory:
            for acl_sample in acl_fixture.fixtures:
                demonstrate(device_name, acl_sample.name)
            return EX_OK
    return EX_TEMPFAIL
def main():
    ''' Select a device and demonstrate. Retry with a different device until an ACL is deleted.'''
    print(plain(doc(acl_delete)))
    inventory = inventory_acl()
    if not inventory:
        print('There are no ACL capable devices to examine. Demonstration cancelled.')
    else:
        for device_name in inventory:
            for acl_sample in acl_fixture.fixtures:
                try:
                    demonstrate(device_name, acl_sample.name)
                    return EX_OK
                except Exception as e:
                    print(e)
    return EX_TEMPFAIL
예제 #58
0
def wrapper_helper():
  """
    params: 
      package: a package name
  """
  import pydoc
  import inspect

  if inspect.isroutine(object):
    dictionary = generate_corpus(object)
  else:
    dictionary = pydoc.doc(object)
  if dictionary:
    for key, value in dictionary.items():
      print("{}: {}".format(key, value))