Open main menu

CDOT Wiki β

Changes

OPS435 Assignment 2 for Section C

2,182 bytes added, 22:21, 6 November 2022
update deadlines for fall
'''Due Date:''' Please follow the three stages of submission schedule:
* Complete the requirements for the first milestone and push to GitHub by April 4November 25, 2021 2022 by 11:59 PM,* Complete the requirements for the second milestone and push to GitHub by December 2, 2022 by 11:59 PM,* Complete the your Python script and push to GitHub by April 18, 2021 December 9 2022 at 11:59 PM, and* Copy your Python script into a Word document and submit to Blackboard by April 18December 9, 2021 2022 at 11:59 PM.
==Overview==
* the <b>os, sys</b> modules
* the <b>argparse</b> module
* The <b>datetime</b> module
* The <b>subprocess</b> module
** === Argparse ===Argparse is a much, much better way of dealing with command line arguments. It not only handles positional arguments, but options as well and will generate usage messages.It's <i>very highly recommended</i> that you spend at least a few minutes reading through the [https://docs.python.org/3/howto/argparse.html Argparse Tutorial] . === Datetime ===Since Python is a <i>batteries</i> included language, it's important to get accustomed with using some of the modules in the standard library. Since we are dealing with dates and times, you are required to work with the datetime module. The full docs can be found [https://docs.python.org/3/library/datetime.html here]. Datetime objects can be initialized from strings that match a particular format. One example is provided for you in the codebase: [https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime the strptime] function. Once you have created datetime objects, you can do useful things with them: * <code> d1 > d2 </code> will return True is d1 is <b>later</b> than d2.* <code> d2 - should read d1 </code> will return a <i>timedelta</i> object, which is an amount of time between d2 and d1. More interesting methods are in the [https://docs.python.org/3/library/datetime.html#datetime.datetime.fold table] in the docs. === Timedelta ===When performing some operations with datetime objects, we may see timedelta objects being created. In math, <b>delta</b> refers to a difference. So a timedelta object is essentially an object that represents a duration. You can do useful things with timedelta objects:* <code> delta1 + delta2 </code> will add up two durations. For example, if delta1 is two hours and delta2 is three hours, then this firstoperation will return five hours.** <code> str(delta1) </code> will represent the timedelta in a friendly format: H:MM:SS if the duration is less than 24 hours.  More interesting methods are in the [https://docs.python.org/3/library/argparsedatetime.html Argparse API reference information page#datetime.datetime.fold table]in the docs.
== Instructions ==
-v, --verbose turn on output verbosity
Copyright 2021 2022 - Eric Brauer
All your Python codes for this assignment 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 - Winter 2021Fall 2022
Program: assignment2.py
Author: "Student Name"
=== Sample Outputs ===
The following are the reports generated by the usage report script (ur.py) with the "usage_data_file" mentioned in the overview section. You can download the file [https://scs.senecac.on.ca/~raymond.chan/ops435/a2/usage_data_file here] to test your ur.py script.
==== User List ====
The following is the user list extracted from the usage_data_file created by the command:
<pre>
[eric@centos a2]$ ./a2assignment2.py -u rchan -t daily usage_data_file
</pre>
The following is a Daily Usage Report created for the Remote Host 10.40.105.103 by the command:
<pre>
[eric@centos7 a2]$ ./a2assignment2.py -r 10.40.105.130 -t daily usage_data_file
</pre>
<pre>
Weekly Usage Report for 10.4340.115105.162130
=====================================
Date Usage
Running the script with <B>no filename</b> as a file argument should call a subprocess.Popen object and run the command <code>last -Fiw</code>.
<pre>
[eric@mtrx-node06pd ~]$ ./a2assignment2.py -l user
</pre>
<pre>
[eric@mtrx-node06pd ~]$ ./a2assignment2.py -u adas20 -t daily
</pre>
=== First Milestone ===
TODOYou should have your <code>TestHelp</code>, <code>TestList</code> and <code>TestDate</code> tests all passing. Make sure that the code is in your GitHub repository. I will use a pull request comment to give feedback, suggest changes or get you unstuck.
=== Python script coding and debugging ===
! Task !! Maximum mark !! Actual mark
|-
| Algorithm Submission First Milestone || 10 ||
|-
| Check Script Results || 30 ||
| List Functions || 5 ||
|-
| Daily/Monthly Weekly Functions || 10 ||
|-
| Output Date Functions || 5 ||
|-
| Other Output/other Functions || 5 ||
|-
| Overall Design/Coherence || 10 ||
== Submission ==
* Stage 1: Complete the first milestone on GitHub by April 4November 25, 20212022.* Stage 2: Complete the second milestone on GitHub by December 2, 2022.* Stage 3: Use commits to push your python script for this assignment to Github.com. The final state of your repository will be looked at on April 18December 9, 2021 2022 at 11:59 PM.* Stage 34: Copy your python script into a Word document and submit to Blackboard by April 18December 9, 2021 2022 at 11:59 PM.