Changes

Jump to: navigation, search

OPS435 Python Assignment 2

1,316 bytes added, 15:59, 14 March 2019
Bonus item 10% extra
asmith pts/11 10.40.105.130 Tue Feb 13 14:07:43 2018 - Tue Feb 13 16:07:43 2018 (02:00)
</pre>
It is always desirable to have a daily, weekly, monthly usage reports by user or by remote host based on the above information.
== Tasks for this assignment ==In this assignment, your duty is to should preform the following activities:# work Work out an algorithm for producing daily, weekly, and monthly usage reports by user or by remote host based on the information obtained from the 'last' command or any given files which contain similar information as the 'last' command. # Once you believe you have a workable algorithm, you should then identify <b>design the structure of your python script</b> by identifying the different tasks appropriate python objects and functions to be used for each task in your algorithm and any repeated sub-the main control logic. Make sure to identify all the input data, computation tasks,and outputs.# implement your computational solution using a single python script with the proper . You can use of any built-in functions, and finallyfunctions from the allowed python modules to implement your solution.# review your working python code to see whether you can improve the interface of each function and to facilitate better core code re-use (this process is called <b>refactoring</b>).
== Allowed Python Modules you can use in your script for this assignment ==
* the <b>os, sys</b> modules
* the <b>argparse</b> module
=== Program Name and valid command line arguments ===
Name your Python3 script as <code>ur_[student_id].py</code>. Create a symbolic link to your script as ur.py (e.g. use the command ln -s ur_rchan.py ur.py to create the linelink) so that you can refer to your script as ur.py. Your script must accept one or more "file name" as its command line parameters and other optional parameters as shown below. Your python script should produce the following usage text when run with the --help option:
<pre>
[rchan@centos7 a1]$ python3 ./ur.py -h
-v, --verbose tune on output verbosity
Copyright 2018 2019 - Raymond Chan
</pre>
Replace the last line with your own full name
=== Header ===
All your Python codes for this program must be placed in a <font color='red'><b><u>single source file</u></b></font>. Please include the following declaration by <b><u>you</u></b> as the <font color='blue'><b>script level docstring </b></font> in your Python source code file (replace [Student_id] with your Seneca email user name, and "Student Name" with your own name):
<source>OPS435 Assignment 2 - Fall 2018Winter 2019
Program: ur_[Stduent_id].py
Author: "Student Name"
<pre>
User list for usage_data_file
=============================
asmith
bigia
</pre>
<pre>Host list for usage_data_file=============================10.40.105.130
10.40.43.94
10.40.91.236
== Suggested Script Development and Testing ==
The following python functions (to be created) are useful in handling the following sub-tasks:
* gets login records from the output of "last" command and filters out unwanted records
* reads login records from files and filters out unwanted records
* generate convert login records into proper python object type so that it can be processed using as much built-in functions as possible * create function which generates daily usage reports by user and/or by remote host* generate create function which generates weekly usage reports by user and/or by remote host* generate create function which generates monthly usage reports by user and/or by remote hostTo help you with this assignment, [[OPS435 A1 Usage Report Template|here is a template]] you can use as a starting point in developing designing your own Python Usage Report script. For each function, identify what type of objects should be passed to the function, and what type of objects should be returned to the caller.
Once you have finished coding a function, you should start a Python3 interactive shell, import your functions and manually call the function you want to test under interactive modeand verify its correctness.
Once you have all the individual function tested and that each is working properly, perform the final test with test data provided by your professor and verify that your script produces the correct results before submitting your python program on Blackboard.
! Task !! Maximum mark !! Actual mark
|-
| Program Authorship Declaration Algorithm and program design||1 15 ||
|-
| Program usage Authorship Declaration || 2 5 ||
|-
| Program Options usage || 2 5 ||
|-
| Generate user name list Program Options || 2 15 ||
|-
| Generate remote host IP user name list|| 2 10 ||
|-
| Daily Usage Report by User Generate remote host IP list|| 2 10 ||
|-
| Daily Usage Report by Remote Host User || 2 10 ||
|-
| Weekly Daily Usage Report by User Remote Host || 2 10 ||
|-
| Weekly Usage Report by Remote Host User || 2 5 ||
|-
| Monthly Weekly Usage Report by User Remote Host || 2 5 ||
|-
| Monthly Usage Report by Remote Host User || 2 5 ||
|-
| pass verbose option test Monthly Usage Report by Remote Host || 2 5 ||
|-
| pass multiple input data file || 2 || |-| '''Total''' || 25 100 ||
|}
== Bonus item 10% extra ==
* Create a function to capture that output of the 'last -Fiw' on the system your script is being executed and return the contents in the type of object as what you get from a regular login/logout record file.
* Call this function and use the objects it returned when the file name input at the command line is 'last'.
== Submission ==
After fully testing your program, submit your python file script ur_[student_id].py and your algorithm and program design report ur_[student_id].pdf in pdf format on Blackboardby April 5th, 2019.
1,760
edits

Navigation menu