Difference between revisions of "OPS435 Python Lab 1"
(→Part 2 - Setting Up Your Linux Environment For OPS435 Labs) |
(→Part 3 - Selecting a Text Editor to Use For Your OPS435 Labs) |
||
Line 92: | Line 92: | ||
− | == Part 3 - Selecting a Text Editor to Use For Your OPS435 Labs == | + | === Part 3 - Selecting a Text Editor to Use For Your OPS435 Labs === |
There are a wide range of text editors for the python language and just about any of them will do. As long as you get basic syntax highlighting and automatic indenting out of the application you are good to go. This section will go over a number of different text editors, showing off a few different text editors so students may find their favourite. There are no wrong answers here, give them all a try and use your favourite. | There are a wide range of text editors for the python language and just about any of them will do. As long as you get basic syntax highlighting and automatic indenting out of the application you are good to go. This section will go over a number of different text editors, showing off a few different text editors so students may find their favourite. There are no wrong answers here, give them all a try and use your favourite. | ||
+ | |||
+ | |||
+ | <table border="1" cellspacing="0" cellpadding="5" > | ||
+ | <tr><td>'''Text Editor'''</td><td>'''Characteristics'''</td></tr> | ||
+ | <tr><td valign="top">'''Vim Editor'''</td><td valign="top"As a system administrator you have probably spent a ton of time inside vim. Well vim is just as powerful and useful when you get to programming, all the shortcuts and commands you've learned over the years will help you edit programs efficiently. On top of what you already know, it might be time to customize vim a little more for programming. Vim can actually be modified to become a full programming environment with all the features you yould expect.</td></tr> | ||
+ | <tr><td valign="top">'''Atom Editor'''</td><td valign="top">"A hackable text editor for the 21st Century". This text editor is a powerful tools that comes with everything your need right out of the box. Atom allows for deep customization from everything from complete functionality changes to just changing the theme. Definitely worth checking out, especially for python development.</td></tr> | ||
+ | <tr><td valign="top">'''Sublime Editor'''</td><td valign="top">Sublime is a popular text editor with tons of customizations and themes.</td></tr> | ||
+ | <tr><td valign="top">'''Other Editors'''</td><td valign="top">x</td></tr> | ||
+ | </table> | ||
+ | |||
=== Vim Editor === | === Vim Editor === | ||
− | + | ||
=== Atom Editor === | === Atom Editor === | ||
− | + | ||
=== Sublime === | === Sublime === |
Revision as of 07:52, 8 March 2017
Contents
Lab Preparation
Purpose/Objectives
Selecting, installing, and setting up your Linux Distribution environment. Learning basics of interacting with python.
Investigation 1 - Installing Linux
Part 1 - Choosing Your Linux Distribution
Since Python runs independently regardless the of the Linux distribution, you have some flexibility of which Linux OS to use. Below is a table displaying the characteristics of the Centos vs Fedora distributions and related Python packages.
Linux Distribution | Characteristics | Python Version |
Centos7 | The stable version of Centos 7 - release 1151 will be chosen(tested) to be supported for this course. This is to keep the ops stream on red hat based systems, lower the amount of new linux distros that need to be learned by students. This should be the default choice for this course, as it allows for the course to run longer before getting outdated with new software and updates. | Centos 7 comes with python 2.7, which means that it is not optimal out for the box for teaching this course. However not teaching python 2.7 would be a mistake since so many programs and operating systems still depend on python 2. It would be good to note some changes and encourage new work to be done in python3 while paying attention to specific projects that work only with python 2. |
Fedora | Fedora will always be the slightly harder distribution to support for a course, so it would be great to have a alternative that is stable. The Fedora distribution has a much larger set of packages throughout its repositories, while this is usually not advantageous for a server context, it can work very well with developers. As students write code they may want more customized environments and coding applications, some of these applications may be harder to get on a server distribution. The other benefit to using Fedora is gaining experience using newer software, by practicing with newer software, students will be exposed to changes they will see in much later Centos releases. | The most recent version of Fedora is a great pick for python development since they've switched the default python installed to python3, which is primarily what this course is about. However,this may cause issues as we get to Ansible or Openstack so we will have to cover the differences between python2 and python3 including a python2 installation on Fedora. |
Perform the following steps:
- After choosing your Linux distribution to use for these labs, install the latest graphical version of that Linux OS.
This course is designed with a unit testing suite, which can be used to look at the scripts you write and give real-time feedback.
This feedback is not perfect, however it may offer some hints if you get stuck with a error. It can also be used to make sure you are on the right track, and show progress. - Download the check script. Enter the following commands from the bash shell.
cd ~/ops435/lab1/ pwd #confirm that you are in the right directory ls CheckLab1.py || wget matrix.senecacollege.ca/~acoatley-willis/CheckLab1.py python3 ./CheckLab1.py -f -v lab0a
- Before moving on to the next step make sure you identify any and all errors in "lab1a.py". When the check script tells you everything is "ok", you may proceed to the next step.
Part 2 - Setting Up Your Linux Environment For OPS435 Labs
In order to learn how to use python on your Linux machine, it is important to setup your Linux environment and learn how to interact with a Python shell.
The first step is to update your entire system. Fedora uses a new package manager: it is based on yum, yet it contains newer code and has more maintainer features as also contains improved features. It should work very similarly to the yum command, but check the man pages if you get confused.
dnf update
Perform the following steps:
- Lets start installing applications we need, first Python version 3 and version 2:
dnf install python3 python2 # Install python3.5 and python2.7
- Next, you will install a couple of useful applications called tmux and screen. They are referred to as terminal multiplexers. If you plan to spend a lot of time in the terminal, this powerful tool will help you get it done. Lets install it and plan to use it later:
dnf install screen tmux && ln -s /usr/bin/true /etc/sysconfig/bash-prompt-screen
- You will now set your hostname to the Linux Distribution we are using:
hostnamectl set-hostname fedora24 # Set hostname to distribution-name
- Installing vim(Vi IMproved) will give us syntax highlighting and allow for advanced customization for terminal editing:
dnf install vim-common vim-enhanced # Install vim
- Python pip is a package manager specifically for Python. While it is usually not recommended to install software outside of dnf or yum, sometimes the only way to get a specific or latest version will be through pip:
dnf install python-pip python3-pip # Install pip
Git is a version control system that allows you to track any changes made to files and programs. The benefit to using git is primarily found when it's used with multiple people, sharing and working on code together. While that is not how we will be using it in this course, you may find some benefits in using it for managing multiple versions of the same program or for backing up your code onto the internet. Check out bitbucket for a free private code repository. - Issue the following command to install git:
dnf install git # Install git command line tool
- IPython will be one of the tools we will use the most. Lets install it. You will learn more about it in the next section:
dnf install python-ipython python3-ipython # Install enhanced interactive python
Part 2 - Lab Check lab0b
cd ~/ops435/lab1/ pwd #confirm that you are in the right directory ls CheckLab1.py || wget matrix.senecacollege.ca/~acoatley-willis/CheckLab1.py python3 ./CheckLab1.py -f -v lab0b
Before moving on to the next step make sure you identify any and all errors in "lab1a.py". When the check script tells you everything is "ok", you may procede to the next step.
Part 3 - Selecting a Text Editor to Use For Your OPS435 Labs
There are a wide range of text editors for the python language and just about any of them will do. As long as you get basic syntax highlighting and automatic indenting out of the application you are good to go. This section will go over a number of different text editors, showing off a few different text editors so students may find their favourite. There are no wrong answers here, give them all a try and use your favourite.
Text Editor | Characteristics |
Vim Editor | <td valign="top"As a system administrator you have probably spent a ton of time inside vim. Well vim is just as powerful and useful when you get to programming, all the shortcuts and commands you've learned over the years will help you edit programs efficiently. On top of what you already know, it might be time to customize vim a little more for programming. Vim can actually be modified to become a full programming environment with all the features you yould expect.</td>