Changes

Jump to: navigation, search

OPS435 Assignment 1 A

5,089 bytes removed, 11:09, 31 May 2018
Instructions
=== Program Name and valid command line arguments ===
Name your Python3 program as <code>usage_reportur.py</code>. The program should accept zero one or more "file name" as its command line parameters. for examplesYour ur.py script should produce the following usage when run with the --help option:* <b><codepre>[rchan@centos7 a1]$ python3 usage_report./ur.py</code></b>, or-h* <b><code>python3 usage_reportusage: ur.py filename</code></b>[-h] [-l {user,host}] [-r RHOST] [-t {daily,weekly, ormonthly}] [-u USER] [-v]* <b><code>python3 usage_report.py filename1 filename2 </code></b> etc F [F ... ] Usage Report based on the last command positional arguments: F list of files to be processed optional arguments: -h, --help show this help message and exit -l {user,host}, --list {user,host} generate user name or remote host IP from the given files -r RHOST, --rhost RHOST usage report for the given remote host IP -t {daily,weekly,monthly}, -- any number type {daily,weekly,monthly} type of file names from 1 to as many as report: daily, weekly, and monthly -u USER, --user USER usage report for the commandgiven user name -v, --verbose tune on output verbosity Copyright 2018 -Raymond Chan <pre>Replace the last line supports.with your own full name
 If there one of the file name given is no command line argument"last", your python program should get the login records from the 'last' command with the appropriate flags.
If there is one file name provided at the command line, read the login records from the contents of the given file. The format of each line in the file should be the same as the output of 'last -Fiw'.
</source>
=== Main Menu ===
When your Python program is running, it should present the user with the following menu:
 
<source>Reading login records... Done.
 
Usage Report - Main Menu
========================
d) Daily Usage Report
w) Weekly Usage Report
m) Monthly Usage Report
q) Quit
</source>
 
Display an appropriate sub-menu when option <b>d</b>, <b>w</b>, or <b>m</b> is selected.
 
When option <b>q</b> is selected, you program should terminate.
 
Redisplay the same menu if the user entered any other letters.
 
=== Daily Usage Menu ===
* If the Daily Usage Report option is selected from the Main Menu, the following sub-menu should be presented on the screen:
 
<source>
Daily Usage Report Menu
=======================
u) By User
h) By Remote Host
r) Return to Main Menu
</source>
 
When option <b>u</b> is selected, the sub-menu for Daily Usage Report by User should be displayed.
 
When option <b>h</b> is selected, the sub-menu for Daily Usage Report by Remote Host should be displayed.
 
When option <b>r</b> is selected, the main menu should be displayed.
 
Redisplay the same menu if the user entered any other letters.
==== Daily Usage Report by User ====
<source>
Daily Usage Report - by User
============================
0) All users
1) user1
2) user2
3) user3
...
9) user9
r) Return to Daily Usage Report Menu
</source>
 
<b>Note</b>: If there are fewer than 9 users, display only the actual number of users on the menu.
 
When option <b>r</b> is selected, the previous Daily Usage Report menu should be displayed.
 
When one of <b>0-9</b> is selected, the Daily Usage Report for the selected user(s) should be generated.
Redisplay the same menu if the user entered any other digits/letters.
 
The following is a sample Daily Usage Report for user1 on host.cty.senecacollege.ca:
<pre>
==== Daily Usage Report by Remote Host====
<source>
Daily Usage Report - by Remote Host
===================================
0) All Remote Host
1) 10.94.10.25
2) 10.94.10.120
3) 172.16.99.1
...
9) 192.168.45.3
r) Return to Daily Usage Report Menu
</source>
 
<b>Note</b>: If there are fewer than 9 remote hosts, display only the actual number of remote host on the menu.
 
When option <b>r</b> is selected, the previous Daily Usage Report menu should be displayed.
 
When one of <b>0-9</b> is selected, the Daily Usage Report for the selected Remote Host(s) should be generated.
 
Redisplay the same menu if the user entered any other digits/letters.
 
The following is a sample Daily Usage Report from Remote Host 10.94.10.25 on host.cty.senecacollege.ca:
Total 80
</pre>
 
=== Weekly Usage Menu ===
* If the Weekly Usage Report option is selected from the Main Menu, the following sub-menu should be presented on the screen:
 
<source>
Weekly Usage Report Menu
========================
u) By User
h) By Remote Host
r) Return to Main Menu
</source>
 
When option <b>u</b> is selected, the sub-menu for Weekly Usage Report by User should be displayed.
 
When option <b>h</b> is selected, the sub-menu for Weekly Usage Report by Remote Host should be displayed.
 
When option <b>r</b> is selected, the main menu should be displayed.
==== Weekly Usage Report by User ====
Weekly Usage Report - by User
=============================
0) All Users
1) User1
2) User2
3) User3
...
9) User9
r) Return to Weekly Usage Report Menu
</source>
 
<b>Note</b>: If there are fewer than 9 users, display only the actual number of user on the menu.
 
When option <b>r</b> is selected, the previous Weekly Usage Report menu should be displayed.
 
When one of <b>0-9</b> is selected, the Weekly Usage Report for the selected user(s) should be generated from week 1 to week 52, skips the week where the weekly usage is zero.
 
Redisplay the same menu if the user entered any other digits/letters.
 
The following is a sample Weekly Usage Report for user1 on host.cty.senecacollege.ca:
Weekly Usage Report - by Remote Host
===================================
0) All Remote Hosts
1) 10.94.10.25
2) 10.94.10.120
3) 172.16.99.1
...
9) 192.168.45.3
r) Return to Weekly Usage Report Menu
</source>
 
<b>Note</b>: If there are fewer than 9 remote hosts, display only the actual number of remote host on the menu.
 
When option <b>r</b> is selected, the previous Weekly Usage Report menu should be displayed.
 
When one of <b>0-9</b> is selected, the Weekly Usage Report for the selected Remote Host(s) should be generated from week 1 to week 52, skip the week where the weekly usage is zero.
 
Redisplay the same menu if the user entered any other digits/letters.
 
The following is a sample Weekly Usage Report from the remote host 10.94.10.25 on host.cty.senecacollege.ca:
Total 91
</pre>
 
=== Monthly Usage Menu ===
* If the Monthly Usage Report option is selected from the Main Menu, the following sub-menu should be presented on the screen:
 
<source>
Monthly Usage Report Menu
=========================
u) By User
h) By Remote Host
r) Return to Main Menu
</source>
 
When option <b>u</b> is selected, the sub-menu for Monthly Usage Report by User should be displayed.
 
When option <b>h</b> is selected, the sub-menu for Monthly Usage Report by Remote Host should be displayed.
 
When option <b>r</b> is selected, the main menu should be displayed.
==== Monthly Usage Report by User ====
<source>
Monthly Usage Report - by User
==============================
0) All Users
1) User1
2) User2
3) User3
...
9) User 9
r) Return to Monthly Usage Report Menu
</source>
 
<b>Note</b>: If there are fewer than 9 users, display only the actual number of user on the menu.
 
When option <b>r</b> is selected, the previous Monthly Usage Report menu should be displayed.
 
When one of <b>0-9</b> is selected, the Monthly Usage Report for the selected user(s) should be generated for Jan to Dec. Skips the month where the Monthly Usage is zero.
 
Redisplay the same menu if the user entered any other digits/letters.
 
The following is a sample Monthly Usage Report for user1 on host.cty.senecacollege.ca:
<pre>
==== Monthly Usage Report by Remote Host ====
<source>
Monthly Usage Report - by Remote Host
=====================================
0) All Remote Hosts
1) 10.94.10.25
2) 10.94.10.120
3) 172.16.99.1
...
9) 192.168.45.3
r) Return to Monthly Usage Report Menu
</source>
 
<b>Note</b>: If there are fewer than 9 remote hosts, display only the actual number of remote host on the menu.
 
When option <b>r</b> is selected, the previous Monthly Usage Report menu should be displayed.
 
When one of <b>0-9</b> is selected, the Monthly Usage Report for the selected Remote Host(s) should be generated for Jan to Dec. Skips that month where the Monthly Usage is zero.
 
Redisplay the same menu if the user entered any other digits/letters.
 
The following is a sample Monthly Usage Report for 10.94.10.25 on host.cty.senecacollege.ca:
1,760
edits

Navigation menu