[PDF] Useful Python Libraries for Network Engineers





Previous PDF Next PDF



Python Libraries Manifest

Feb 4 2013 This publication provides a complete list of the Python libraries—including their versions—that are packaged in the ArcGIS Notebooks runtime ...



ArcGIS Notebooks Python Libraries Manifest 1.0

Sep 1 1982 ArcGIS Notebooks features the ArcGIS Python libraries



real-time forecasts New Python libraries for downloading

charts using Python and Jupyter notebooks. Milana Vu?kovi? New Python libraries for downloading processing and visualising ECMWF data.



APIScanner - Towards Automated Detection of Deprecated APIs in

Deprecated APIs in Python libraries are mainly declared by decorator hard-coded warning



Useful Python Libraries for Network Engineers

https://developer.cisco.com/netdevops/live. Hank Preston ccie 38336 R/S. Developer Advocate



ArcGIS Notebooks Python Libraries Manifest 4.0

Python Libraries Manifest. ArcGIS® Notebooks provides a spatially optimized Jupyter experience to create share



A Python Library for Historical Comparative Linguistics

Aug 26 2012 A Python Library for Historical Comparative. Linguistics. Steven Moran1 & Johann-Mattis List2. 1Research Unit Quantitative Language ...



Python libraries matplotlib seaborn and pandas for visualization

Sep 25 2020 The practical purpose of this work is to test statistical package Seaborn built on the. Python's Matplpotlib library for the geospatial data ...



Extending PyJL – Transpiling Python Libraries to Julia

This paper extends our previous work on translating Python libraries to Julia [17]. PyJL is a rule-based transpilation tool that translates Python source 



Python Libraries.key

Jun 8 2018 Basic Python Internals. • Libraries and Tools for Scientific Computing ... A Python plotting library which produces publication quality.



Python Library Reference - MIT

Python is an extensible interpreted object-oriented programming language It supports a wide range of applications from simple text processing scripts to interactive WWW browsers While the Python Reference Manual describes the exact syntax and semantics of the language it does not describe



Python for Data Analysis - Boston University

Python Libraries for Data Science Pandas: adds data structures and tools designed to work with table-like data (similar to Series and Data Frames in R) provides tools for data manipulation: reshaping merging sorting slicing aggregation etc allows handling missing data 6 Link: http://pandas pydata org/



24 Best Python Libraries You Should Check in 2022 - Hackrio

Python Package Index (PyPI) to extend and improve Python and solve the inevitable glitches that crop up In this series we'll look at seven PyPI libraries that can help you solve common Python problems Introduction



Python Tutorial

The Python installer automatically associates py ?les with python exe so that a double-click on a Python ?le will run it as a script The extension can also be pyw in that case the console window that normally appears is suppressed 2 2 3Source Code Encoding By default Python source ?les are treated as encoded in UTF-8



Useful Python Libraries - Esri

Sample from python PDF •arcpy mapping PDFDocument •reportlab (third-party) -allows rapid creation of rich PDF documents and also creation of charts in a variety of bitmap and vector formats Networking •Calls to HTTP servers -urllib2 -requests (third-party pip-install) -asyncio Computing •Numpy •Pandas * •Scipy * •Sympy *



Searches related to python libraries filetype:pdf

Python is a beautiful language It's easy to learn and fun and its syntax is simple yet elegant Python is a popular choice for beginners yet still powerful enough to to back some of the world’s most popular products and applications from companies like NASA Google Mozilla Cisco Microsoft and Instagram among others

What are some of the most popular Python libraries?

    One of the most popular general Python libraries is Requests, which aims to make HTTP requests simpler and more human-friendly. Licensed under the Apache2 license and written in Python, Requests is the de facto standard used by developers for making HTTP requests in Python.

What is the best Python library for beginners?

    Requests is a rich Python HTTP library. Released under Apache2.0 license, Requests is focused on making HTTP requests more responsive and user-friendly. This python library is a real blessing for beginners as it allows the use of most common methods of HTTP.

What are the best Python libraries for machine learning?

    Numpy is considered as one of the most popular machine learning library in Python. TensorFlow and other libraries uses Numpy internally for performing multiple operations on Tensors. Array interface is the best and the most important feature of Numpy. Interactive: Numpy is very interactive and easy to use.

What are the best Python libraries for data analysis?

    NumPy is one of the most widely-used Python libraries. It contains functionality for fast and efficient numerical computations, but its strength lies in working with arrays. In Python, arrays can contain integers, floats, strings, or even complex numbers. For example, a 2-dimensional NumPy array can be created as follows:

Hank Preston, ccie38336 R/S

Developer Advocate, DevNet

Season 1, Talk 1

Useful Python Libraries for Network

Engineers

Twitter: @hfpreston

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Libraries to Work with Data

API Libraries

Configuration Management

Tools and Libraries

Some Other Cool Python Stuff

What are we going to talk about?

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Libraries to Work with Data

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

XML -xmltodict

pip install xmltodict import xmltodict JSON import json

YAML -PyYAML

pip install PyYAML import yaml CSV import csv

YANG -pyang

import pyang

Manipulating Data of All Formats

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Easily work with XML data

Convert from XML -> Dict*

and back xmltodict.parse(xml_data) xmltodict.unparse(dict)

Python includes a native

Markup(html/xml) interfaces

as well

More powerful, but also more

complex * Technically to an OrderedDict # Import the xmltodict library importxmltodict # Open the sample xml file and read it into variable withopen("xml_example.xml") asf: xml_example = f.read() # Print the raw XML data print(xml_example) # Parse the XML into a Python dictionary xml_dict = xmltodict.parse(xml_example) # Save the interface name into a variable using XML nodes as keys int_name = xml_dict["interface"]["name"] # Print the interface name print(int_name) # Change the IP address of the interface xml_dict["interface"]["ipv4"]["address"]["ip"] = "192.168.0.2" # Revert to the XML string version of the dictionary print(xmltodict.unparse(xml_dict))

Treat XML like Python Dictionaries with xmltodict

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

JSON and Python go

together like peanut butter and jelly json.loads(json_data) json.dumps(object)

JSON Objects convert to

Dictionaries

JSON Arrays convert to

Lists # Import the jsontodictlibrary import json # Open the sample jsonfile and read it into variable with open("json_example.json") as f: json_example= f.read() # Print the raw jsondata print(json_example) # Parse the jsoninto a Python dictionary json_dict= json.loads(json_example) # Save the interface name into a variable int_name= json_dict["interface"]["name"] # Print the interface name print(int_name) # Change the IP address of the interface json_dict["interface"]["ipv4"]["address"][0]["ip"] = \ "192.168.0.2" # Revert to the jsonstring version of the dictionary print(json.dumps(json_dict))

To JSON and back again with json

# Import the jsontodictlibrary importjson # Open the sample jsonfile and read it into variable withopen("json_example.json") asf: json_example= f.read() # Print the raw jsondata print(json_example) # Parse the jsoninto a Python dictionary json_dict= json.loads(json_example) # Save the interface name into a variable int_name= json_dict["interface"]["name"] # Print the interface name print(int_name) # Change the IP address of the interface json_dict["interface"]["ipv4"]["address"][0]["ip"] = \ "192.168.0.2" # Revert to the jsonstring version of the dictionary print(json.dumps(json_dict)) © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Easily convert a YAML file

to a Python Object yaml.load(yaml_data) yaml.dump(object)

YAML Objects become

Dictionaries

YAML Lists become Lists

# Import the yamltodictlibrary import yaml # Open the sample yamlfile and read it into variable with open("yaml_example.yaml") as f: yaml_example= f.read() # Print the raw yamldata print(yaml_example) # Parse the yamlinto a Python dictionary yaml_dict= yaml.load(yaml_example) # Save the interface name into a variable int_name= yaml_dict["interface"]["name"] # Print the interface name print(int_name) # Change the IP address of the interface yaml_dict["interface"]["ipv4"]["address"][0]["ip"] = \ "192.168.0.2" # Revert to the yamlstring version of the dictionary print(yaml.dump(yaml_dict, default_flow_style=False))

YAML? Yep, Python Can Do That Too!

# Import the yamltodictlibrary importyaml # Open the sample yamlfile and read it into variable withopen("yaml_example.yaml") asf: yaml_example= f.read() # Print the raw yamldata print(yaml_example) # Parse the yamlinto a Python dictionary yaml_dict= yaml.load(yaml_example) # Save the interface name into a variable int_name= yaml_dict["interface"]["name"] # Print the interface name print(int_name) # Change the IP address of the interface yaml_dict["interface"]["ipv4"]["address"][0]["ip"] = \ "192.168.0.2" # Revert to the yamlstring version of the dictionary print(yaml.dump(yaml_dict, default_flow_style=False)) © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Treat CSV data as lists

csv.reader(file_object)

Efficiently processes large

files without memory issues

Options for header rows

and different formats # Import the csv library importcsv # Open the sample csv file and print it to screen withopen("csv_example.csv") asf: print(f.read()) # Open the sample csv file, and create a csv.reader object withopen("csv_example.csv") asf: csv_python= csv.reader(f) # Loop over each row in csv and leverage the data # in code forrow incsv_python: print("{device} is in {location} "\ "and has IP {ip}.".format( device = row[0], location = row[2], ip= row[1]

Import Spreadsheets and Data with csv

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Modulethat is a self-contained

top-level hierarchy of nodes

Usescontainersto group related

nodes

Liststo identify nodes that are

stored in sequence

Each individual attribute of a node

is represented by aleaf

Every leaf must have an

associatedtype module ietf-interfaces { import ietf-yang-types { prefix yang; container interfaces { list interface { key "name"; leaf name { type string; leaf enabled { type boolean; default "true";

YANG Data Modeling Language -IETF Standard

Example edited for simplicity and brevity

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Working in native YANG can be

challenging pyangis a Python library for validating and working with

YANG files

Excellent for network

developers working with

NETCONF/RESTCONF/gRPC

Quickly understand the key

operational view of a model echo "Print the YANG module in a simple text tree" pyang-f tree ietf-interfaces.yang echo "Print only part of the tree" pyang-f tree --tree-path=/interfaces/interface \ ietf-interfaces.yang echo "Print an example XML skeleton (NETCONF)" pyang-f sample-xml-skeleton ietf-interfaces.yang echo "Create an HTTP/JS view of the YANG Model" pyang-f jstree-o ietf-interfaces.html\ ietf-interfaces.yang open ietf-interfaces.html echo 'Control the "nested depth" in trees' pyang-f tree --tree-depth=2 ietf-ip.yang echo "Include deviation models in the processing" pyang-f tree \ ietf-ip.yang

Investigate YANG Models with pyang

data_manipulation/yang/pyang-examples.sh © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

API Libraries

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

REST APIs ²requests

pip install requests import requests

NETCONF ²ncclient

pip install ncclient import ncclient

Network CLI ²netmiko

pip install netmiko import netmiko

SNMP ²PySNMP

pip install pysnmp import pysnmp

Access Different APIs Easily

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Full HTTP Client

Simplifies authentication,

headers, and response tracking

Great for REST API calls, or any

HTTP request

Network uses include

RESTCONF, native REST APIs,

JSON-RPC

0MNH +773 FMOOV RLPO (MVH XVLQJ ´UHTXHVPVµ

http://docs.python-requests.org © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Example: Retrieving

Configuration Details with

RESTCONF

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public # Import libraries importrequests, urllib3 importsys # Add parent directory to path to allow importing common vars sys.path.append("..") # noqa fromdevice_infoimportios_xe1 asdevice # noqa # Disable Self-Signed Cert warning for demo # Setup base variable for request restconf_headers= {"Accept": "application/yang-data+json"} restconf_base= "https://{ip}:{port}/restconf/data" interface_url= restconf_base+ "/ietf-interfaces:interfaces/interface={int_name}"

RESTCONF: Basic Request for Device Data 1/2

device_apis/rest/restconf_example1.pyCode edited for display on slide © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public # Create URL and send RESTCONF request to core1 for GigE2 Config url= interface_url.format(ip= device["address"], port = device["restconf_port"], int_name= "GigabitEthernet2" r = requests.get(url, headers = restconf_headers, auth=(device["username"], device["password"]), verify=False) # Print returned data print(r.text) # Process JSON data into Python Dictionary and use interface = r.json()["ietf-interfaces:interface"] print("The interface {name} has ipaddress {ip}/{mask}".format( name = interface["name"], ip= interface["ietf-ip:ipv4"]["address"][0]["ip"], mask = interface["ietf-ip:ipv4"]["address"][0]["netmask"],

RESTCONF: Basic Request for Device Data 2/2

device_apis/rest/restconf_example1.pyCode edited for display on slide © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Example: Updating

Configuration with

RESTCONF

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public # Setup base variable for request restconf_headers["Content-Type"]= "application/yang-data+json" # New Loopback Details loopback = {"name": "Loopback101", "description": "Demo interface by RESTCONF", "ip": "192.168.101.1", "netmask": "255.255.255.0"} # Setup data body to create new loopback interface data = { "ietf-interfaces:interface": { "name": loopback["name"], "description": loopback["description"], "type": "iana-if-type:softwareLoopback", "enabled": True, "ietf-ip:ipv4": { "address": [ {"ip": loopback["ip"], "netmask": loopback["netmask"]}

RESTCONF: Creating a New Loopback 1/2

device_apis/rest/restconf_example2.pyOnly showing significant code changes © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public # Create URL and send RESTCONF request to core1 for GigE2 Config url= interface_url.format(ip= core1_ip, int_name= loopback["name"]) r = requests.put(url, headers = restconf_headers, auth=(username, password), json= data, verify=False) # Print returned data print("Request Status Code: {}".format(r.status_code))

RESTCONF: Creating a New Loopback 2/2

device_apis/rest/restconf_example2.pyOnly showing significant code changes © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Full NETCONF Manager (ie

client) implementation in Python

See later presentation on

NETCONF details

Handles all details including

authentication, RPC, and operations

Deals in raw XML

Easily Interface with NETCONF and ncclient

https://ncclient.readthedocs.io © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Example: Retrieving

Configuration Details with

NETCONF

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public # Import libraries fromncclientimportmanager importxmltodict # Create filter template for an interface interface_filter= """ {int_name}

NETCONF: Basic Request for Device Data 1/2

device_apis/netconf/netconf_example1.pyCode edited for display on slide © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public # Open NETCONF connection to device withmanager.connect(host=core1_ip, username=username, password=password, hostkey_verify=False) asm: # Create desired NETCONF filter and filter= interface_filter.format(int_name= "GigabitEthernet2") r = m.get_config("running", filter) # Process the XML data into Python Dictionary and use interface = xmltodict.parse(r.xml) interface = interface["rpc-reply"]["data"]["interfaces"]["interface"] print("The interface {name} has ipaddress {ip}/{mask}".format( name = interface["name"]["#text"], ip= interface["ipv4"]["address"]["ip"], mask = interface["ipv4"]["address"]["netmask"],

NETCONF: Basic Request for Device Data 2/2

device_apis/netconf/netconf_example1.pyCode edited for display on slide © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Example: Updating

Configuration with

NETCONF

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public # Create config template for an interface config_data= """ {int_name} {description} ianaift:softwareLoopback true
{ip} {netmask}

NETCONF: Creating a New Loopback 1/2

device_apis/netconf/netconf_example2.pyOnly showing significant code changes © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public # New Loopback Details loopback = {"int_name": "Loopback102", "description": "Demo interface by NETCONF", "ip": "192.168.102.1", "netmask": "255.255.255.0"} # Open NETCONF connection to device withmanager.connect(host=core1_ip, username=username, password=password, hostkey_verify=False) asm: # Create desired NETCONF config payload and config = config_data.format(**loopback) r = m.edit_config(target = "running", config = config) # Print OK status print("NETCONF RPC OK: {}".format(r.ok))

NETCONF: Creating a New Loopback 2/2

device_apis/netconf/netconf_example2.pyOnly showing significant code changes © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

If no other API is available"

quotesdbs_dbs20.pdfusesText_26
[PDF] python machine learning by example pdf github

[PDF] python machine learning packt pdf

[PDF] python machine learning pdf raschka

[PDF] python machine learning projects

[PDF] python machine learning sebastian raschka pdf github

[PDF] python mcq online test

[PDF] python midterm exam pdf

[PDF] python mini projects with database

[PDF] python mit pdf

[PDF] python mysql connector

[PDF] python numpy partial differential equation

[PDF] python oop

[PDF] python oop exercises with solutions

[PDF] python oracle database programming examples pdf

[PDF] python oracle database programming pdf