cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

DevNet 1040 -1042 Sessions Network Programmability; Some Python code from yesterday's discussions

1415
Views
12
Helpful
1
Comments
Cisco Employee

...great session at CiscoLive Berlin on Python Network programming yesterday!  I promised to post the Python snippit that launches a browser that points to the DevNet Python repository that I've been building - including the Ubuntu VM that I used and all the code content that we covered yesterday (remember, the username and password for everything is vagrant, vagrant;).

Anyway, here is the link to the repository followed by the code snippit - you can either run it as its own script or 'feed' the statements into the Python shell one at a time to watch it in action.  Please let me know if you have any questions or comments - hope this helps!

Vince

Here is the link to the repository:

# https://cisco.box.com/v/DevNet1040GettingStarted

# Ubuntu VM username and passwords are vagrant, vagrant

    

                                     ###     Here is the code snippit to launch a browser   ###

[SNIP]

just cut and paste the lines that come after the '###' into a file with a .py extension (you don't need to include the '#' symbols), then invoke from a command line - eg.  if you call the script 'name_of_my_program.py then

python name_of_my_program.py 

           OR

just start the Python IDLE shell and feed each line of code into the interpreter to watch it in action.....

############

import webbrowser                                                                          # webbrowser is a built-in python method

main_page = 'https://cisco.box.com/v/DevNet1040GettingStarted'      # just assign this string to the variable called main_page

webbrowser.open(main_page)                                                          # THIS is the statement that fires up the browser to your page

############

1 Comment
Beginner

Hi Vkelly
seems the URL is not working. Can you please share the files again ?

Content for Community-Ad

This widget could not be displayed.