def main():
    with open("show_version.txt", "r") as version_file:
        show_ver = version_file.read()

    #print "Model: "+(show_version.obtain_model(show_ver))

# print "%15s: %-50s" % ("model", model)
    print "%15s: %-70s" % ("Model", (show_version.obtain_model(show_ver)))
    print "%15s: %-50s" % ("Version",
                           (show_version.obtain_os_version(show_ver)))
    print "%15s: %-50s" % ("Uptime", (show_version.obtain_uptime(show_ver)))
Example #2
0
def main():

    with open("show_version.txt", "r") as show_ver_file:
        show_ver = show_ver_file.read()

        uptime = show_version.obtain_uptime(show_ver)
        model = show_version.obtain_model(show_ver)
        os_version = show_version.obtain_os_version(show_ver)

    print
    print "%15s %-50s" % ("model:", model)
    print "%15s %-50s" % ("os_version:", os_version)
    print "%15s %-50s" % ("uptime:", uptime)
    print
def main():
    '''
    Write a script that processes the show_version output using the 'show_version' package
    It should return something similar to the following:
    model:        881
    os_version:   Version 15.0(1)M4
    uptime:       uptime is 12 weeks, 5 days, 1 hour, 4 minutes
    '''

    with open("show_version.txt", "r") as version_file:
        show_ver = version_file.read()

    model = show_version.obtain_model(show_ver)
    os_version = show_version.obtain_os_version(show_ver)
    uptime = show_version.obtain_uptime(show_ver)

    print
    print "%15s: %-50s" % ("model", model)
    print "%15s: %-50s" % ("os_version", os_version)
    print "%15s: %-50s" % ("uptime", uptime)
    print
Example #4
0
def main():
    '''
    Write a script that processes the show_version output using the 'show_version' package

    It should return something similar to the following:
    model:        881
    os_version:   Version 15.0(1)M4
    uptime:       uptime is 12 weeks, 5 days, 1 hour, 4 minutes
    '''

    with open("show_version.txt", "r") as version_file:
        show_ver = version_file.read()

    model = show_version.obtain_model(show_ver)
    os_version = show_version.obtain_os_version(show_ver)
    uptime = show_version.obtain_uptime(show_ver)

    print
    print "%15s: %-50s" % ("model", model)
    print "%15s: %-50s" % ("os_version", os_version)
    print "%15s: %-50s" % ("uptime", uptime)
    print
Example #5
0
>>> show_version.obtain_uptime(show_ver)
'12 weeks, 5 days, 1 hour, 4 minutes'


    C. Write a script that processes the show_version output using
this package.  It should return something similar to the following:

        model:        881
        os_version:   Version 15.0(1)M4
        uptime:       uptime is 12 weeks, 5 days, 1 hour, 4 minutes

'''

import show_version

if __name__ == "__main__":

    f = open("show_version.txt")

    show_ver = f.read()

    model = show_version.obtain_model(show_ver)
    os_version = show_version.obtain_os_version(show_ver)
    uptime = show_version.obtain_uptime(show_ver)

    print
    print "%15s: %-50s" % ("model", model)
    print "%15s: %-50s" % ("os_version", os_version)
    print "%15s: %-50s" % ("uptime", uptime)
    print
"""Create three functions in three separate modules and put them in a show_version directory (in practice you wouldn't do this--you would just have them all in one file, but this will let you experiment with packages).
            1. Function1 = obtain_os_version -- process the show version output and return the OS version (Version 15.0(1)M4) else return None.
            2. Function2 = obtain_uptime -- process the show version output and return the network device's uptime string (uptime is 12 weeks, 5 days, 1 hour, 4 minutes) else return None.
            3. Function3 = obtain_model -- process the show version output and return the model (881) else return None.

    B. Make a package out of this 'show_version' directory using a blank __init__.py file.
"""
import show_version


with open("show_version.txt") as f:
    lines = f.read()
    print "Version: %s" % show_version.obtain_os_version(lines)
    print "Model: %s" % show_version.obtain_model(lines)
    print "Uptime: %s" % show_version.obtain_uptime(lines)
Example #7
0
>>> show_version.obtain_uptime(show_ver)
'12 weeks, 5 days, 1 hour, 4 minutes'


    C. Write a script that processes the show_version output using
this package.  It should return something similar to the following:

        model:        881
        os_version:   Version 15.0(1)M4
        uptime:       uptime is 12 weeks, 5 days, 1 hour, 4 minutes

"""

import show_version

if __name__ == "__main__":

    f = open("show_version.txt")

    show_ver = f.read()

    model = show_version.obtain_model(show_ver)
    os_version = show_version.obtain_os_version(show_ver)
    uptime = show_version.obtain_uptime(show_ver)

    print
    print "%15s: %-50s" % ("model", model)
    print "%15s: %-50s" % ("os_version", os_version)
    print "%15s: %-50s" % ("uptime", uptime)
    print