NetOps Coding 101 building your first robot!
|
|
- Briana Payne
- 5 years ago
- Views:
Transcription
1 NetOps Coding 101 building your first robot! NANOG 66 david swafford
2 what we ll accomplish 2
3 automating 3
4 the remediation of network faults 4
5 using the examples of link flaps & line card failures 5
6 based on parsing of syslog messages 6
7 focusing today 7
8 coding in Python 8
9 interacting with network devices through software 9
10 regular expressions 10
11 keeping track of what happened 11
12 12
13 how it works 13
14 system design device 1 sends message 4 remediates syslog server 2 tails 3 messages runs parser remediation 14
15 system design device 1 sends message 4 remediates syslog server 2 tails 3 messages runs parser remediation 15
16 system design device 1 sends message 4 remediates syslog server 2 tails 3 messages runs parser remediation 16
17 system design device 1 sends message 4 remediates syslog server 2 tails 3 messages runs parser remediation 17
18 live demo! 18
19 19
20 20
21 21
22 22
23 23
24 24
25 25
26 26
27 syslog message problem identified solution suggested 27
28 28
29 the lab environment 29
30 a virtual machine of Ubuntu desktop 30
31 customized with ipython! and extras Python & MySQL server & Python libs 31
32 importing the virtual appliance 32
33 download it from netengcode.com! 33
34 34
35 35
36 36
37 37
38 TERMINAL log-in details user: demo pass: demo 38
39 keyboard shortcuts to break out of the VM f enter or leave full-screen 39
40 40
41 introducing IPython! 41
42 42
43 43
44 simple prototyping 44
45 simple prototyping 45
46 scrolling back 46
47 scrolling back 47
48 leaving 48
49 a few Python basics 49
50 the basic data structures 50
51 the basic data structures strings lists tuples dictionaries 51
52 strings in Python any sequence of characters enclosed by single or double-quotes 52
53 lists in Python comma-separated values (items) between square brackets" 53
54 tuples in Python comma-separated values 54
55 lists vs tuples? 55
56 lists vs tuples the contents of a list may be changed the contents of a tuple may not be changed 56
57 quick caveat! "...it is actually the comma which makes a tuple, not the parentheses." 57
58 dictionaries ( hash tables ) 58
59 dictionaries in Python an unordered set of key: value pairs keys must be unique 59
60 dictionaries in Python 66 is the key and San Diego the value 60
61 dictionaries in Python values are accessed using the notation of [key] 61
62 try it out! 62
63 try it out! create a variable with your neighbor's name create a list of your adjacent neighbor's names create a dictionary mapping those last names to first names 63
64 try it out! create a variable with your neighbor's name name = '' create a list of your adjacent neighbor's names names = [] create a dictionary mapping those last names to first names names = {'last': 'first'} 64
65 questions? 65
66 66
67 working with modules 67
68 what is a module? 68
69 imports, or makes available, the re module part of the standard library 69
70 re is the module s namespace 70
71 as imports the module under a different namespace 71
72 methods from a module are accessed by namespace.method() 72
73 we will be using re.match() 73
74 using re.match() two inputs a regex and thing to match against 74
75 using re.match() it returns None or a match object 75
76 try it out! 76
77 try it out! import the "re" module type help(re) type re.match('eth', 'ethernet') 77
78 questions? 78
79 79
80 reading syslog messages 80
81 reading in a file assigning the file path to a variable 81
82 reading in a file opening a file handle 82
83 reading in a file using.readlines() to get a list of lines 83
84 reading in a file 84
85 try it out! 85
86 try it out! open the file "syslog.txt" try out ".readlines()" 86
87 questions? 87
88 88
89 parsing syslog messages 89
90 a syslog message 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 90
91 looking with an abstract lens 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 91
92 looking with an abstract lens DATESTAMP 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 92
93 looking with an abstract lens DATESTAMP 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 93
94 looking with an abstract lens DATESTAMP TIMESTAMP switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 94
95 looking with an abstract lens DATESTAMP TIMESTAMP DEVICE %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 95
96 looking with an abstract lens DATESTAMP TIMESTAMP DEVICE %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 96
97 looking with an abstract lens DATESTAMP TIMESTAMP DEVICE ERROR_CODE: Interface Ethernet5/1 is down (Interface removed) 97
98 looking with an abstract lens DATESTAMP TIMESTAMP DEVICE ERROR_CODE: Interface Ethernet5/1 is down (Interface removed) 98
99 looking with an abstract lens DATESTAMP TIMESTAMP DEVICE ERROR_CODE: ERROR_MESSAGE 99
100 from log message to structured data 100
101 structured data LOG MESSAGE DATESTAMP TIMESTAMP DEVICE ERROR CODE ERROR MESSAGE 101
102 102
103 regular expressions! 103
104 a way to ask does this pattern exist in a given block of text? 104
105 where this pattern is created by you 105
106 specifying the pattern is often called building a regex 106
107 an example with BGP ip as-path access-list 1 permit "^$" 107
108 "^$" beginning of line followed by end of line (an empty line!) 108
109 getting started with regular expressions in Python 109
110 try it out! 110
111 try it out! a raw string, with an opening grouping symbol 111
112 try it out! \ to indicate that a pattern-matching character follows 112
113 try it out! d to match one digit (integer) 113
114 try it out! instead of pattern-matching, we could put exact text too -- "2015" for example 114
115 try it out! + to indicate one or more (of the previous thing) 115
116 try it out! \d+ will match
117 try it out! \s will match one space 117
118 try it out! \w+ will match one or more characters (Jun) 118
119 try it out! assigning the return of re.match() to a variable (matched) 119
120 try it out! a match object was returned (it matched) 120
121 try it out! accessing the matched data using.group() 121
122 questions? 122
123 123
124 parsing syslog 124
125 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) DATESTAMP_RE = r'(\d+\s+\w+\s+\d+)' one or \d+ more digits 125
126 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) DATESTAMP_RE = r'(\d+\s+\w+\s+\d+)' one or \s+ more spaces 126
127 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) DATESTAMP_RE = r'(\d+\s+\w+\s+\d+)' one or \w+ more characters 127
128 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) DEVICE_NAME_RE = r'(\s+)' one or more \S+ non-space characters 128
129 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) ERROR_CODE_RE = r'%(\s+):' one or more \S+ non-space characters 129
130 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) ERROR_MESSAGE_RE = r'(\.*)' one or more \.* non-newline characters 130
131 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) DATESTAMP_RE = r'(\d+\s+\w+\s+\d+)' TIMESTAMP_RE = r'(\d+:\d+:\d+)' DEVICE_NAME_RE = r'(\s+)' ERROR_CODE_RE = r'%(\s+):' ERROR_MESSAGE_RE = r'(\.*)' COLUMN_DELIMITER_RE = r'(\s+)' 131
132 132
133 using the re module to match 133
134 using the re module to match 134
135 using the re module to match 135
136 using the re module to match continue skip this log line and go to the next 136
137 using the re module to match 137
138 start of group 1 end of group 1 DATESTAMP_RE = r'(\d+\s+\w+\s+\d+)' TIMESTAMP_RE = r'(\d+:\d+:\d+)' DEVICE_NAME_RE = r'(\s+)' ERROR_CODE_RE = r'%(\s+):' ERROR_MESSAGE_RE = r'(\.*)' 138
139 try it out! 139
140 try it out! 140
141 try it out! note - SYSLOG_RE is already staged 141
142 try it out! 142
143 try it out! 143
144 try it out! 144
145 try it out! 145
146 questions? 146
147 147
148 building our first remediation 148
149 first remediation a linecard failure 149
150 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 150
151 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 151
152 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 152
153 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 153
154 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 154
155 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) Did the interface regex find a match? 155
156 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) Group "1" is the data matched by the first set of ( ) 156
157 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 157
158 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 158
159 try it out! 159
160 try it out! parse out only the module number from: Ethernet5/1 populate that value into the string: show module {module} 160
161 sending commands over SSH 161
162 sending commands over SSH 162
163 sending commands over SSH a wrapper around Paramiko (Python SSH client) included with our demo code 163
164 no paramiko? 164
165 installing paramiko 165
166 installing paramiko 166
167 sending commands over ssh commands over ssh 167
168 sending commands over ssh commands over ssh 168
169 sending commands over ssh commands over ssh Connection opened! 169
170 sending commands over ssh 170
171 sending commands over ssh 171
172 sending commands over ssh 172
173 try it out! 173
174 try it out! open a dummy ssh connection using: import ssh_helper ssh = ssh_helper.sshsession('switch1') inspect the output from: show module 5 174
175 inspecting the output output is a list [0:5] is a slice of the first 5 lines 175
176 inspecting the output 176
177 inspecting the output checking if one string is present in another string 177
178 inspecting the output ignoring case using.lower() 178
179 inspecting the output 179
180 inspecting the output 180
181 reacting to the output using on-device filtering with egrep 181
182 reacting to the output 182
183 reacting to the output idea! parse the uptime and react based on the value 183
184 reacting to the output 184
185 questions? 185
186 186
187 next remediation link flaps & light level checking 187
188 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 188
189 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 189
190 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 190
191 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 191
192 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 192
193 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 193
194 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 194
195 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 195
196 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 196
197 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 197
198 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 198
199 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 199
200 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 200
201 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 201
202 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 202
203 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 203
204 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 204
205 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 205
206 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 206
207 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 207
208 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 208
209 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 209
210 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) "show transceiver details" 210
211 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) example output: ' Rx Power dbm...' 211
212 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) example output: ' Rx Power dbm...' 212
213 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) example output: ' Rx Power dbm...' 213
214 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) example output: ' Rx Power dbm...' 214
215 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) example output: ' Rx Power dbm...' 215
216 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) example output: ' Rx Power dbm...' 216
217 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) converting a string to a float for mathematical comparison 217
218 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 218
219 2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) send_ () 219
220 questions? 220
221 keeping track of what happened 221
222 options in memory (lists, dictionaries, etc) on disk (as a file) in a database 222
223 comparing a few database options sqlite mysql 223
224 an event as a database table EVENT ID DATESTAMP DEVICE ERROR CODE ERROR MESSAGE RESULT 224
225 getting started with sqlite 225
226 building the database 226
227 building the database 227
228 creating events the safe way to handle string substitution 228
229 creating events auto-generated by the database 229
230 updating events 230
231 updating events 231
232 questions? 232
233 opportunities for improvement 233
234 scoping globally scoped code is a bad design use functions, classes, and modules to keep things organized 234
235 scoping globally scoped code and code inside large functions are both hard to test concise functions are easier to test testability saves much pain and suffering later 235
236 organization remediation and system code together - it can be quite a lot to digest. "sparse is better than dense" - use smaller concise files and split logically. 236
237 scaling it's not a real-time system, but would need to be. for log parsing, continuous parsing with some intelligence re: new vs old events. 237
238 stability persistence is key! a restart to the parsing script should not re-run previously handled events / remediations. 238
239 perf one by one processing is okay for a demo... in real life though, this should break up the load within the script, or as separate scripts/instances. 239
240 system design device 1 sends message 4 remediates syslog server 2 tails 3 messages runs parser remediation 240
241 system design device 1 sends message 4 remediates syslog server 2 tails 3 messages runs parser remediation 241
242 appendix 242
243 separating backend code from remediation logic 243
244 separating the backend from remediations a dictionary where the values are functions! 244
245 separating the backend from remediations 245
246 separating the backend from remediations a function 246
247 running a function who s name is not defined in this block of code 247
248 248
249 249
250 250
251 #netengcode NANOG 66 david swafford
Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationPython INTRODUCTION: Understanding the Open source Installation of python in Linux/windows. Understanding Interpreters * ipython.
INTRODUCTION: Understanding the Open source Installation of python in Linux/windows. Understanding Interpreters * ipython * bpython Getting started with. Setting up the IDE and various IDEs. Setting up
More informationGIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes
GIS 4653/5653: Spatial Programming and GIS More Python: Statements, Types, Functions, Modules, Classes Statement Syntax The if-elif-else statement Indentation and and colons are important Parentheses and
More informationTopic 7: Lists, Dictionaries and Strings
Topic 7: Lists, Dictionaries and Strings The human animal differs from the lesser primates in his passion for lists of Ten Best H. Allen Smith 1 Textbook Strongly Recommended Exercises The Python Workbook:
More informationPython Training. Complete Practical & Real-time Trainings. A Unit of SequelGate Innovative Technologies Pvt. Ltd.
Python Training Complete Practical & Real-time Trainings A Unit of. ISO Certified Training Institute Microsoft Certified Partner Training Highlights : Complete Practical and Real-time Scenarios Session
More informationCS108 Lecture 19: The Python DBAPI
CS108 Lecture 19: The Python DBAPI Sqlite3 database Running SQL and reading results in Python Aaron Stevens 6 March 2013 What You ll Learn Today Review: SQL Review: the Python tuple sequence. How does
More informationWebgurukul Programming Language Course
Webgurukul Programming Language Course Take One step towards IT profession with us Python Syllabus Python Training Overview > What are the Python Course Pre-requisites > Objectives of the Course > Who
More informationTUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL
TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL We have spent the first part of the course learning Excel: importing files, cleaning, sorting, filtering, pivot tables and exporting
More informationIterators & Generators
Iterators & Generators Sequences A sequence is something that you can: Index into Get the length of What are some examples of sequences? Sequences We ve been working with sequences all semester! Examples:
More informationTUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL
TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL We have spent the first part of the course learning Excel: importing files, cleaning, sorting, filtering, pivot tables and exporting
More information\n is used in a string to indicate the newline character. An expression produces data. The simplest expression
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationJSON Support for Junos OS
JSON Support for Junos OS 1 Introduction: Java Script Object Notation alias JSON a light weight data exchange format is being extensively used for data exchange between web application and servers. With
More information[301] JSON. Tyler Caraza-Harter
[301] JSON Tyler Caraza-Harter Learning Objectives Today JSON differences with Python syntax creating JSON files reading JSON files Read: Sweigart Ch 14 https://automatetheboringstuff.com/chapter14/ JSON
More informationSTATS Data Analysis using Python. Lecture 8: Hadoop and the mrjob package Some slides adapted from C. Budak
STATS 700-002 Data Analysis using Python Lecture 8: Hadoop and the mrjob package Some slides adapted from C. Budak Recap Previous lecture: Hadoop/MapReduce framework in general Today s lecture: actually
More informationCh.1 Introduction. Why Machine Learning (ML)?
Syllabus, prerequisites Ch.1 Introduction Notation: Means pencil-and-paper QUIZ Means coding QUIZ Why Machine Learning (ML)? Two problems with conventional if - else decision systems: brittleness: The
More informationAPIs and API Design with Python
APIs and API Design with Python Lecture and Lab 5 Day Course Course Overview Application Programming Interfaces (APIs) have become increasingly important as they provide developers with connectivity to
More informationPython review. 1 Python basics. References. CS 234 Naomi Nishimura
Python review CS 234 Naomi Nishimura The sections below indicate Python material, the degree to which it will be used in the course, and various resources you can use to review the material. You are not
More informationIntroduction to Bioinformatics
Introduction to Bioinformatics Variables, Data Types, Data Structures, Control Structures Janyl Jumadinova February 3, 2016 Data Type Data types are the basic unit of information storage. Instances of
More informationCeng 111 Fall 2015 Week 8a
Ceng 111 Fall 2015 Week 8a Container data and Actions Credit: Some slides are from the Invitation to Computer Science book by G. M. Schneider, J. L. Gersting and some from the Digital Design book by M.
More informationPYTHON TRAINING COURSE CONTENT
SECTION 1: INTRODUCTION What s python? Why do people use python? Some quotable quotes A python history lesson Advocacy news What s python good for? What s python not good for? The compulsory features list
More informationAbout Python. Python Duration. Training Objectives. Training Pre - Requisites & Who Should Learn Python
About Python Python course is a great introduction to both fundamental programming concepts and the Python programming language. By the end, you'll be familiar with Python syntax and you'll be able to
More informationPython Basics. Lecture and Lab 5 Day Course. Python Basics
Python Basics Lecture and Lab 5 Day Course Course Overview Python, is an interpreted, object-oriented, high-level language that can get work done in a hurry. A tool that can improve all professionals ability
More information10/18/2017. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414
Announcements Database Systems CSE 414 Lecture 11: NoSQL & JSON (mostly not in textbook only Ch 11.1) HW5 will be posted on Friday and due on Nov. 14, 11pm [No Web Quiz 5] Today s lecture: NoSQL & JSON
More information15-388/688 - Practical Data Science: Data collection and scraping. J. Zico Kolter Carnegie Mellon University Spring 2017
15-388/688 - Practical Data Science: Data collection and scraping J. Zico Kolter Carnegie Mellon University Spring 2017 1 Outline The data collection process Common data formats and handling Regular expressions
More informationCh.1 Introduction. Why Machine Learning (ML)? manual designing of rules requires knowing how humans do it.
Ch.1 Introduction Syllabus, prerequisites Notation: Means pencil-and-paper QUIZ Means coding QUIZ Code respository for our text: https://github.com/amueller/introduction_to_ml_with_python Why Machine Learning
More informationPython Working with files. May 4, 2017
Python Working with files May 4, 2017 So far, everything we have done in Python was using in-memory operations. After closing the Python interpreter or after the script was done, all our input and output
More informationPython Intro GIS Week 1. Jake K. Carr
GIS 5222 Week 1 Why Python It s simple and easy to learn It s free - open source! It s cross platform IT S expandable!! Why Python: Example Consider having to convert 1,000 shapefiles into feature classes
More informationLevel 3 Computing Year 2 Lecturer: Phil Smith
Level 3 Computing Year 2 Lecturer: Phil Smith Previously We learnt what a computer program does. What a procedural program does. What a procedure is. We had a first look at IDLE. Now Learning Outcomes
More informationCS2304: Python for Java Programmers. CS2304: Sequences and Collections
CS2304: Sequences and Collections Sequences In Python A sequence type in python supports: The in membership operator. The len() function. Slicing like we saw with strings, s[1:3]. And is iterable (for
More informationData type built into Python. Dictionaries are sometimes found in other languages as associative memories or associative arrays.
NETB 329 Lecture 4 Data Structures in Python Dictionaries Data type built into Python. Dictionaries are sometimes found in other languages as associative memories or associative arrays. 1 of 70 Unlike
More informationJME Language Reference Manual
JME Language Reference Manual 1 Introduction JME (pronounced jay+me) is a lightweight language that allows programmers to easily perform statistic computations on tabular data as part of data analysis.
More informationLING115 Lecture Note Session #7: Regular Expressions
LING115 Lecture Note Session #7: Regular Expressions 1. Introduction We need to refer to a set of strings for various reasons: to ignore case-distinction, to refer to a set of files that share a common
More informationIntro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming
Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals
More informationThe Pyth Language. Administrivia
Administrivia The Pyth Language Lecture 5 Please make sure you have registered your team, created SSH keys as indicated on the admin page, and also have electronically registered with us as well. Prof.
More informationPart III Appendices 165
Part III Appendices 165 Appendix A Technical Instructions Learning Outcomes This material will help you learn how to use the software you need to do your work in this course. You won t be tested on it.
More informationComputer and Programming: Lab 1
01204111 Computer and Programming: Lab 1 Name ID Section Goals To get familiar with Wing IDE and learn common mistakes with programming in Python To practice using Python interactively through Python Shell
More informationScript language: Python Data structures
Script language: Python Data structures Cédric Saule Technische Fakultät Universität Bielefeld 3. Februar 2015 Immutable vs. Mutable Previously known types: int and string. Both are Immutable but what
More informationMastering Modern Linux by Paul S. Wang Appendix: Pattern Processing with awk
Mastering Modern Linux by Paul S. Wang Appendix: Pattern Processing with awk The awk program is a powerful yet simple filter. It processes its input one line at a time, applying user-specified awk pattern
More informationIntroduction to Scientific Python, CME 193 Jan. 9, web.stanford.edu/~ermartin/teaching/cme193-winter15
1 LECTURE 1: INTRO Introduction to Scientific Python, CME 193 Jan. 9, 2014 web.stanford.edu/~ermartin/teaching/cme193-winter15 Eileen Martin Some slides are from Sven Schmit s Fall 14 slides 2 Course Details
More informationTable of Contents EVALUATION COPY
Table of Contents Introduction... 1-2 A Brief History of Python... 1-3 Python Versions... 1-4 Installing Python... 1-5 Environment Variables... 1-6 Executing Python from the Command Line... 1-7 IDLE...
More informationPython: Short Overview and Recap
Python: Short Overview and Recap Benjamin Roth CIS LMU Benjamin Roth (CIS LMU) Python: Short Overview and Recap 1 / 39 Data Types Object type Example creation Numbers (int, float) 123, 3.14 Strings this
More informationComputational Programming with Python
Numerical Analysis, Lund University, 2017 1 Computational Programming with Python Lecture 1: First steps - A bit of everything. Numerical Analysis, Lund University Lecturer: Claus Führer, Alexandros Sopasakis
More informationPlaylist Builder 1.5 Manual
Playlist Builder 1.5 Manual Playlist Builder is a database and schedule system for your audio files. It supports the following audio formats: WAV SND/MP2 MP3 OTS Before you run the program, make sure you
More informationCMSC 201 Fall 2015 Lab 12 Tuples and Dictionaries
CMSC 201 Fall 2015 Lab 12 Tuples and Dictionaries Assignment: Lab 12 Tuples and Dictionaries Due Date: During discussion, November 30 th through December 3 rd Value: 1% of final grade Part 1: Data Types
More informationBasics of Stata, Statistics 220 Last modified December 10, 1999.
Basics of Stata, Statistics 220 Last modified December 10, 1999. 1 Accessing Stata 1.1 At USITE Using Stata on the USITE PCs: Stata is easily available from the Windows PCs at Harper and Crerar USITE.
More informationS206E Lecture 19, 5/24/2016, Python an overview
S206E057 Spring 2016 Copyright 2016, Chiu-Shui Chan. All Rights Reserved. Global and local variables: differences between the two Global variable is usually declared at the start of the program, their
More informationBasic Scripting, Syntax, and Data Types in Python. Mteor 227 Fall 2017
Basic Scripting, Syntax, and Data Types in Python Mteor 227 Fall 2017 Basic Shell Scripting/Programming with Python Shell: a user interface for access to an operating system s services. The outer layer
More informationDefining Functions. CSc 372. Comparative Programming Languages. 5 : Haskell Function Definitions. Department of Computer Science University of Arizona
Defining Functions CSc 372 Comparative Programming Languages 5 : Haskell Function Definitions Department of Computer Science University of Arizona collberg@gmail.com When programming in a functional language
More informationPython Class-Lesson1 Instructor: Yao
Python Class-Lesson1 Instructor: Yao What is Python? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined
More informationJava+- Language Reference Manual
Fall 2016 COMS4115 Programming Languages & Translators Java+- Language Reference Manual Authors Ashley Daguanno (ad3079) - Manager Anna Wen (aw2802) - Tester Tin Nilar Hlaing (th2520) - Systems Architect
More informationComp Exam 1 Overview.
Comp 170-400 Exam 1 Overview. Resources During the Exam The exam will be closed book, no calculators or computers, except as a word processor. In particular no Python interpreter running in a browser or
More informationHuman-Computer Interaction Design
Human-Computer Interaction Design COGS120/CSE170 - Intro. HCI Instructor: Philip Guo Lab 4 - Simulating a backend without needing a server (2017-11-03) made by Philip Guo, derived from labs by Michael
More informationDictionaries. Looking up English words in the dictionary. Python sequences and collections. Properties of sequences and collections
Looking up English words in the dictionary Comparing sequences to collections. Sequence : a group of things that come one after the other Collection : a group of (interesting) things brought together for
More informationPython - Variable Types. John R. Woodward
Python - Variable Types John R. Woodward Variables 1. Variables are nothing but named reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.
More informationConfiguring the Embedded Event Manager
This chapter describes how to configure the Embedded Event Manager (EEM) to detect and handle critical events on Cisco NX-OS devices. This chapter includes the following sections: About EEM, page 1 Licensing
More information1. BASICS OF PYTHON. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman
1. BASICS OF PYTHON JHU Physics & Astronomy Python Workshop 2017 Lecturer: Mubdi Rahman HOW IS THIS WORKSHOP GOING TO WORK? We will be going over all the basics you need to get started and get productive
More informationChapter 4. Unix Tutorial. Unix Shell
Chapter 4 Unix Tutorial Users and applications interact with hardware through an operating system (OS). Unix is a very basic operating system in that it has just the essentials. Many operating systems,
More informationPlay with Python: An intro to Data Science
Play with Python: An intro to Data Science Ignacio Larrú Instituto de Empresa Who am I? Passionate about Technology From Iphone apps to algorithmic programming I love innovative technology Former Entrepreneur:
More informationTUPLES AND RECURSIVE LISTS 5
TUPLES AND RECURSIVE LISTS 5 COMPUTER SCIENCE 61A July 3, 2012 1 Sequences From the Pig project, we discovered the utility of having structures that contain multiple values. Today, we are going to cover
More informationpylatexenc Documentation
pylatexenc Documentation Release 1.2 Philippe Faist Apr 28, 2017 Contents: 1 Simple Parser for LaTeX Code 3 1.1 The main LatexWalker class....................................... 3 1.2 Exception Classes............................................
More informationCS1110 Lab 1 (Jan 27-28, 2015)
CS1110 Lab 1 (Jan 27-28, 2015) First Name: Last Name: NetID: Completing this lab assignment is very important and you must have a CS 1110 course consultant tell CMS that you did the work. (Correctness
More informationPython I. Some material adapted from Upenn cmpe391 slides and other sources
Python I Some material adapted from Upenn cmpe391 slides and other sources Overview Names & Assignment Data types Sequences types: Lists, Tuples, and Strings Mutability Understanding Reference Semantics
More informationCS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)
CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going
More informationMUTABLE LISTS AND DICTIONARIES 4
MUTABLE LISTS AND DICTIONARIES 4 COMPUTER SCIENCE 61A Sept. 24, 2012 1 Lists Lists are similar to tuples: the order of the data matters, their indices start at 0. The big difference is that lists are mutable
More informationCS 2316 Individual Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 18th, before 11:55 PM Out of 100 points
CS 2316 Individual Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 18th, before 11:55 PM Out of 100 points Files to submit: 1. HW4.py This is an INDIVIDUAL assignment! Collaboration at a
More informationCS 11 python track: lecture 3. n Today: Useful coding idioms
CS 11 python track: lecture 3 Today: Useful coding idioms Useful coding idioms "Idiom" Standard ways of accomplishing a common task Using standard idioms won't make your code more correct, but more concise
More informationLING/C SC/PSYC 438/538. Lecture 3 Sandiway Fong
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong Today s Topics Homework 4 out due next Tuesday by midnight Homework 3 should have been submitted yesterday Quick Homework 3 review Continue with Perl intro
More information[CHAPTER] 1 INTRODUCTION 1
FM_TOC C7817 47493 1/28/11 9:29 AM Page iii Table of Contents [CHAPTER] 1 INTRODUCTION 1 1.1 Two Fundamental Ideas of Computer Science: Algorithms and Information Processing...2 1.1.1 Algorithms...2 1.1.2
More informationExceptions & a Taste of Declarative Programming in SQL
Exceptions & a Taste of Declarative Programming in SQL David E. Culler CS8 Computational Structures in Data Science http://inst.eecs.berkeley.edu/~cs88 Lecture 12 April 18, 2016 Computational Concepts
More informationJavaScript. History. Adding JavaScript to a page. CS144: Web Applications
JavaScript Started as a simple script in a Web page that is interpreted and run by the browser Supported by most modern browsers Allows dynamic update of a web page More generally, allows running an arbitrary
More informationGNU ccscript Scripting Guide IV
GNU ccscript Scripting Guide IV David Sugar GNU Telephony 2008-08-20 (The text was slightly edited in 2017.) Contents 1 Introduction 1 2 Script file layout 2 3 Statements and syntax 4 4 Loops and conditionals
More information1 of 7 7/24/2014 8:16 PM
1 of 7 7/24/2014 8:16 PM Instructions for Windows XP Instructions for Windows Vista Instructions for Windows 7 Windows XP Enabling Indic Language Support 1. Click Start, click Control Panel, and then double-click
More informationPython for ArcGIS. Lab 1.
Python for ArcGIS. Lab 1. Python is relatively new language of programming, which first implementation arrived around early nineties of the last century. It is best described as a high level and general
More informationPart IV. More on Python. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26,
Part IV More on Python Compact Course @ Max-Planck, February 16-26, 2015 36 More on Strings Special string methods (excerpt) s = " Frodo and Sam and Bilbo " s. islower () s. isupper () s. startswith ("
More informationExercise: The basics - variables and types
Exercise: The basics - variables and types Aim: Introduce python variables and types. Issues covered: Using the python interactive shell In the python interactive shell you don t need print Creating variables
More informationMITOCW watch?v=rvrkt-jxvko
MITOCW watch?v=rvrkt-jxvko The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To
More informationAdvanced Algorithms and Computational Models (module A)
Advanced Algorithms and Computational Models (module A) Giacomo Fiumara giacomo.fiumara@unime.it 2014-2015 1 / 34 Python's built-in classes A class is immutable if each object of that class has a xed value
More informationData Acquisition and Processing
Data Acquisition and Processing Adisak Sukul, Ph.D., Lecturer,, adisak@iastate.edu http://web.cs.iastate.edu/~adisak/bigdata/ Topics http://web.cs.iastate.edu/~adisak/bigdata/ Data Acquisition Data Processing
More informationCorreLog. SQL Table Monitor Adapter Users Manual
CorreLog SQL Table Monitor Adapter Users Manual http://www.correlog.com mailto:support@correlog.com CorreLog, SQL Table Monitor Users Manual Copyright 2008-2018, CorreLog, Inc. All rights reserved. No
More informationVisualize ComplexCities
Introduction to Python Chair of Information Architecture ETH Zürich February 22, 2013 First Steps Python Basics Conditionals Statements Loops User Input Functions Programming? Programming is the interaction
More informationCS 1803 Pair Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 29th, before 6 PM Out of 100 points
CS 1803 Pair Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 29th, before 6 PM Out of 100 points Files to submit: 1. HW4.py This is a PAIR PROGRAMMING Assignment: Work with your partner!
More informationIT 374 C# and Applications/ IT695 C# Data Structures
IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation
More informationCMSC201 Computer Science I for Majors
CMSC201 Computer Science I for Majors Lecture 12 Tuples All materials copyright UMBC and Dr. Katherine Gibson unless otherwise noted Modularity Meaning Benefits Program design Last Class We Covered Top
More informationContrail Sandbox Tutorial Script
Contrail Sandbox Tutorial Script Tutorial Flow Login to lab setup Add security rules Add IP address manager Add two networks Add network policy Add two VMs (can t ping) Add network policy to networks (VMs
More informationIntroduction to Python Part 1. Brian Gregor Research Computing Services Information Services & Technology
Introduction to Python Part 1 Brian Gregor Research Computing Services Information Services & Technology RCS Team and Expertise Our Team Scientific Programmers Systems Administrators Graphics/Visualization
More informationThis class is about understanding how programs work
CMSC 245 Wrap-up This class is about understanding how programs work To do this, we re going to have to learn how a computer works Learned a ton in the class Lexical vs. Dynamic Scoping Regexp Parsing
More informationProgramming in Python 3
Programming in Python 3 A Complete Introduction to the Python Language Mark Summerfield.4.Addison-Wesley Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich
More informationPLOG Proposal: A programming language for graph operations
PLOG Proposal: A programming language for graph operations wab2125@columbia.edu COMS 4115 Summer session - Project proposal June 9, 2016 Introduction: Graphs are familiar structures used throughout mathematics
More informationUsing Python for shell scripts
Using Python for shell scripts January 2018 1/29 Using Python for shell scripts Peter Hill Outline Using Python for shell scripts January 2018 2/29 Advantages/disadvantages of Python Running a parameter
More informationLISTS WITH PYTHON. José M. Garrido Department of Computer Science. May College of Computing and Software Engineering Kennesaw State University
LISTS WITH PYTHON José M. Garrido Department of Computer Science May 2015 College of Computing and Software Engineering Kennesaw State University c 2015, J. M. Garrido Lists with Python 2 Lists with Python
More informationIntroduction to Python: Data types. HORT Lecture 8 Instructor: Kranthi Varala
Introduction to Python: Data types HORT 59000 Lecture 8 Instructor: Kranthi Varala Why Python? Readability and ease-of-maintenance Python focuses on well-structured easy to read code Easier to understand
More informationN-grams in Python. L445/L515 Autumn 2010
N-grams in Python L445/L515 Autumn 2010 Calculating n-grams We want to take a practical task, i.e., using n-grams for natural language processing, and see how we can start implementing it in Python. Some
More informationCOMP-520 GoLite Tutorial
COMP-520 GoLite Tutorial Alexander Krolik Sable Lab McGill University Winter 2019 Plan Target languages Language constructs, emphasis on special cases General execution semantics Declarations Types Statements
More informationPython. Objects. Geog 271 Geographic Data Analysis Fall 2010
Python This handout covers a very small subset of the Python language, nearly sufficient for exercises in this course. The rest of the language and its libraries are covered in many fine books and in free
More informationCSC148H Week 3. Sadia Sharmin. May 24, /20
CSC148H Week 3 Sadia Sharmin May 24, 2017 1/20 Client vs. Developer I For the first couple of weeks, we have played the role of class designer I However, you are also often in the opposite role: when a
More informationData! CS 133: Databases. Goals for Today. So, what is a database? What is a database anyway? From the textbook:
CS 133: Databases Fall 2018 Lec 01 09/04 Introduction & Relational Model Data! Need systems to Data is everywhere Banking, airline reservations manage the data Social media, clicking anything on the internet
More informationCS Summer 2013
CS 1110 - Summer 2013 intro to programming -- how to think like a robot :) we use the Python* language (www.python.org) programming environments (many choices): Eclipse (free from www.eclipse.org), or
More informationSQLite vs. MongoDB for Big Data
SQLite vs. MongoDB for Big Data In my latest tutorial I walked readers through a Python script designed to download tweets by a set of Twitter users and insert them into an SQLite database. In this post
More informationTopics to Learn. Important concepts. Tree-based index. Hash-based index
CS143: Index 1 Topics to Learn Important concepts Dense index vs. sparse index Primary index vs. secondary index (= clustering index vs. non-clustering index) Tree-based vs. hash-based index Tree-based
More informationPyROOT: Seamless Melting of C++ and Python. Pere MATO, Danilo PIPARO on behalf of the ROOT Team
PyROOT: Seamless Melting of C++ and Python Pere MATO, Danilo PIPARO on behalf of the ROOT Team ROOT At the root of the experiments, project started in 1995 Open Source project (LGPL2) mainly written in
More information