def main(): """ Open a file called show_ip_int_brie.txt. Parse through interface data and create an Interface object for each one found. """ interfaces = [] INTERFACE_REGEX = '^(FastEthernet|GigabitEthernet)([0-9]+) .*(up|down)' # open the file called 'show_ip_int_brief.txt' with open('show_ip_int_brief.txt', 'r') as interface_info: for line in interface_info: # Iterate over each line and match against the string INTERFACE_REGEX m = re.match(INTERFACE_REGEX, line) if m is not None: # When the line matches the REGEX, create an Interface() object interface = Interface(m.group(1) + m.group(2), m.group(3)) # Append the interface to the list, so we can iterate over it interfaces.append(interface) # for each interface print the name and status for interface in interfaces: interface.prints() # call the check_down() function to print any interfaces in the down state with a warning for interface in interfaces: interface.check_down()
def main(): """Simple main method calling our function.""" list_interfaces = [] result = get_interface_state(HOST, PORT, USER, PASS, FILE) print(xml.dom.minidom.parseString(result.xml).toprettyxml()) # get a list of interfaces by parsing for the <interface> element interfaces = xml.dom.minidom.parseString( result.xml).getElementsByTagName('interface') # iterate over each instance of the <interface> element for each in interfaces: # parse out the <name> and <oper-status> nodes when the # <name> text node contains "GigabitEthernet|FastEthernet" if re.match('(Gigabit|Fast)Ethernet', each.getElementsByTagName('name')[0].firstChild.nodeValue): # instantiate an Interface() object for each instance of an interface interface = Interface( each.getElementsByTagName('name')[0].firstChild.nodeValue, each.getElementsByTagName('oper-status') [0].firstChild.nodeValue) list_interfaces.append(interface) # call the prints() method to print the interface data for each in list_interfaces: each.prints() # call the check_down() method to print each down interface and a warning for each in list_interfaces: each.check_down()
def __init__(self, screen, book): self.screen = screen self.clock = pygame.time.Clock() # init interface self.interface = Interface() # init books self.book = book # init the player self.music = Player(self.book)
def __init__(self, screen, funcs, hardware_instance, book): # declare important variables self.screen = screen # important for framerate self.clock = pygame.time.Clock() # contain all interface methods self.interface = Interface() # functions for the menu items self.funcs = funcs # cached book for last played window self.book = book
def __init__(self, screen, library, function): # define screen variables self.screen = screen # define music folder self.library = library # important for framerate self.clock = pygame.time.Clock() # contain all interface methods self.interface = Interface() # declare functions self.function = function
def __init__(self, book): # init the mixer of pygame module self.mixer = pygame.mixer self.mixer.init() # init the interface module self.interface = Interface() # load actual audio book object self.book = book self.chapter = self.book.get_chapter() # set position to position in audio book class self.position = self.book.get_pos() # set playing status self.playing = False