...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
############