Changes

Jump to: navigation, search

OPS435 Online Lab1

2,800 bytes added, 15 January
Task 2: Create a project and make a pull request on GitHub
[[Category:rchan]][[Category:OPS435-Online]]
'''Introduction to git, github.com, and Python'''
= Lab Objectives =
:* Using the "git clone" command to clone a repository into a new directory
= Overview =
:*In this lab, you will create an account on github.com and follow the Github "Hello World guide" to create a new public repository on github to and explore the basic workflow of using github to track and manage revisions of software or other contents. The essential operations provided by Github includes:**creating new repository, :**creating a new branch, :**making changes to files, :**creating a pull request, and :**opening and merging a pull request. :*You will then use the git client (git clone) on matrix.senecacollege.ca to access and download the contents of the repository you created on github. Note: if you have your own Linux VM ready, you can also install and use the git client on your VM.:*You will also use the git client on matrix.senecacollege.ca to clone the repository on github.com which hosts the Python scripts for lab 1. :Study *Finally, study, create and execute the simple Python scripts downloaded from the lab 1 repository.
= Reference=
:* Open a pull request, and
:* Merge your pull request
: Please make the following <font color='red'>changes </font> when following the guide::* name the new repository using your <b><u>Seneca user name </u></b> instead of "hello-world".
:* add your full name, and OPS435 section to the README file, do not post any other personal information there.
:* run the following two commands and capture their output to the named files:
<pre>
git log > ~/ops435/lab1/gitlog.txt
</pre>
<pre>
tree -a > ~/ops435/lab1/repo_tree.txt
</pre>
:* Make sure that gitlog.txt and repo_tree.txt are not emptyand are under the ~/ops435/lab1 directory. Review and study the contents of gitlog.txt and repo_tree.txt :*Download the check script and check your work. Enter the following commands from the bash shell.<source lang="bash"> cd ~/ops435/lab1/ pwd #confirm that you are in the right directory ls -l lab1a.py #confirm that you have the directory for you github repo, the files gitlog.txt and repo_tree.txt ls CheckLab1.py || wget https://ict.senecacollege.ca/~raymond.chan/ops435/labs/LabCheckScripts/CheckLab1.py python3 ./CheckLab1.py -f -v lab0a</source>
= Investigation 2 - Python on Matrix =
:* You can access the Python Interpreter on Matrix from a Linux machine or a Windows 10 machine.
=== Login to matrix.senecacollege.ca from a CentOS 7 machine ===
:<font color='red'>This option won't work after September 1, 2020 as matrix.senecacollege.ca had been moved under Seneca's VPN. The latest version of the openconnect client is need to connect to the Seneca VPN. We are working on the instruction on how to do that. In the mean time, please use the Windows 10 as described below to connect to matrix.</font>:* To login to matrix.senecacollege.ca must you must have a active Seneca user account.
:* The following is a screen shot showing the login from a CentOS Linux (host or vm) system with an active Seneca user name: <br /><br />[[image:centos_ssh.png|Ssh to matrix from Linux]]
=== Login to matrix.senecacollege.ca from a Windows 10 machine ===
:* Please follow the instruction at [https://inside.senecacollege.ca/its/services/vpn/studentvpn.html Seneca Student VPN] to download and install the GlobalProtect VPN client and connect to the Seneca VPN to your Windows Machine.
:* Login to matrix.senecacollege.ca with your Seneca user name from Windows 10's run box.<br /><br />[[image:window10_ssh.png|ssh to matrix from Windows 10]]
:** <source>python3 sample.py 2>/dev/null</source>
:** <source>python3 sample.py test 2>/dev/null </source>
:*Download the check script and check your work. Enter the following commands from the bash shell.<source lang="bash">
cd ~/ops435/lab1/
pwd #confirm that you are in the right directory
ls -l ~/ops435/ #confirm that you have create the directory structure under ~/ops435
ls CheckLab1.py || wget https://ict.senecacollege.ca/~raymond.chan/ops435/labs/LabCheckScripts/CheckLab1.py
python3 ./CheckLab1.py -f -v lab0b
</source>
= Investigation 3 - exploring and using Python's built-in functions =
>>>
</source>
:* We are interested in the '''object''' named '''__builtins__'''at this moment. We can ask the Python interpreter to tell use us more about the '''__builtins__''' object by passing its name '''__builtins__builtins__''' as a the function argument to the '''dir()''' function: <source>>>> dir(__builtins__)
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BlockingIOError',
...
'type', 'vars', 'zip']
</source>
:* The above output shows a list of the so-called '''built-in run-time error codes''' items and '''bulit-in functionsfunction names''' items. We are going to learn how to use them effectively in order to save our coding effort when writing Python programs/scripts.
:* Let starts with the following built-in functions:
:** print()
=LAB 1 SIGN-OFF Upload the following files individually to Blackboard=
:* gitlog'''Run the CheckLab1.py script and capture the result'''<source>python3 ./CheckLab1.py -f -v &> lab1_[seneca_id].txt</source> : contains Submit the output of the command "git log" from Task 3following files individually to Blackboard::* repo_tree.txt: contains the output of the command <span style="tree color:green;font-asize:1.5em;" from Task 3>&#x2713;</span> <code>lab1_[seneca_id].txt</code>:* lab1_check.txt: contains the output of the command <span style="python3 color:green;font-size:1.5em;">&#x2713;</checkLab1span> <code>gitlog.txt, repo_tree.txt, lab1a.py, lab1b.py lab1c.py -f -v", lab1d.py</code>
= Lab Review =
:# What is the name of the definitive branch in a git repository?
:# What is a "pull request" related to a branch in a git repository?
:# Write Python code that when run, will perform the following tasks:<ol type="a"><li>Contain a she-bang line</li><li>Display a greetings message to the user</li><li>display an empty line ('''hint:''' use the special character '''\n''' to print the a new-line character)</li><li>Display text, '''"Your current directory is:"''' (You are NOT required to display quotation marks)</li><li>Display the current working directory pathname (using an appropriate command)</li><li>Display another empty line</li></ol>
:# How do you execute a Python script when you are within the interactive <u>python3</u> shell? (Hint: make use of a function provided by the os python module.)
:# How do you execute a Python script when you are in the <u>Bash</u> Shell (i.e. NOT within the python3 shell)?
:# Write the pipeline command to check if the CheckLab1.py checking script exists, and download it from the location:<br>https://ict.senecacollege.ca/~raymond.chan/ops435/labs/LabCheckScripts/CheckLab1.py
1,687
edits

Navigation menu