Difference between revisions of "OPS435 A1 Usage Report Template"

From CDOT Wiki
Jump to: navigation, search
(A1 Usage Report Template)
(A1 Usage Report Template)
Line 17: Line 17:
 
import sys
 
import sys
 
import time
 
import time
 
def menu(title,items,choice):
 
    ''' docstring for this function '''
 
    selection = ''
 
    while selection not in choice:
 
        print(title)
 
        print('=' * len(title))
 
        for item in items:
 
            print(item)
 
        selection = input('menu choice -->')
 
    return selection
 
  
 
def get_login_rec():
 
def get_login_rec():
Line 34: Line 23:
 
     filter out the unwanted records
 
     filter out the unwanted records
 
     add filtered record to list (login_recs)'''
 
     add filtered record to list (login_recs)'''
 +
    [ put your python code for this function here ]
 
     return login_recs
 
     return login_recs
 
   
 
   
Line 42: Line 32:
 
     filter out the unwanted records
 
     filter out the unwanted records
 
     add filtered record to list (login_recs)'''  
 
     add filtered record to list (login_recs)'''  
 +
    [ put your python code for this function here ]
 
     return login_rec
 
     return login_rec
  
 
def cal_daily_usage(subject,login_recs):
 
def cal_daily_usage(subject,login_recs):
 
     ''' docstring for this function
 
     ''' docstring for this function
     check number of subjects in login_recs
+
     generate daily usage report for the given
    if less than 10, display subject selection menu
+
     subject (user or remote host)'''
    for each subject, process daily usage
+
    [ put your python code for this function here ]
     dispaly daily usage'''
+
     return daily_usage
     return 0
 
  
 
def cal_weekly_usage(subject,login_recs):
 
def cal_weekly_usage(subject,login_recs):
     '''check number of subjects in login_recs
+
     ''' docstring for this function
    if less than 10, display subject selection menu
+
     generate weekly usage report for the given
     for each subject, process weekly usage
+
     subject (user or remote host)'''
     display weekly usage'''
+
    [ put your python code for this function here ]
     return 0
+
     return weekly_usage
  
 
def cal_monthly_usage(subject,login_recs):
 
def cal_monthly_usage(subject,login_recs):
     '''check numbe of subjects in login_recs
+
     ''' docstring for this function
    if less than 10, display subject selection menu
+
     generate monthly usage report fro the given
     for each subject, process monthly usage
+
     subject (user or remote host)'''
     display monthly usage'''
+
    [ put your python code for this function here ]
     return 0
+
     return monthly_usage
 
      
 
      
 
if __name__ == '__main__':
 
if __name__ == '__main__':
 
     import argparse
 
     import argparse
     ....
+
     ...
 +
    [ code to retrieve command line argument using the argparse module [
 +
    ...
 +
    [ based on the command line option, generate and print
 +
      the requested usage report ]
 +
    ...
 
</pre>
 
</pre>

Revision as of 15:34, 11 November 2018

A1 Usage Report Template

Please note that the following listing contains some actual python codes, but mostly are pseudo code.

#!/usr/bin/env python3
'''
   authorship declaration

   __author__ Raymond Chan
   __date__ Feb 2018
   __version__ 1.0
 
   text to describe the purpose of this script
'''

import os 
import sys
import time

def get_login_rec():
    ''' docstring for this fucntion
    get records from the last command
    filter out the unwanted records
    add filtered record to list (login_recs)'''
    [ put your python code for this function here ]
    return login_recs
 
def read_login_rec(filelist):
    ''' docstring for this function
    get records from given filelist
    open and read each file from the filelist
    filter out the unwanted records
    add filtered record to list (login_recs)''' 
    [ put your python code for this function here ]
    return login_rec

def cal_daily_usage(subject,login_recs):
    ''' docstring for this function
    generate daily usage report for the given 
    subject (user or remote host)'''
    [ put your python code for this function here ]
    return daily_usage

def cal_weekly_usage(subject,login_recs):
    ''' docstring for this function
    generate weekly usage report for the given 
    subject (user or remote host)'''
    [ put your python code for this function here ]
    return weekly_usage

def cal_monthly_usage(subject,login_recs):
    ''' docstring for this function
    generate monthly usage report fro the given
    subject (user or remote host)'''
    [ put your python code for this function here ]
    return monthly_usage
     
if __name__ == '__main__':
    import argparse
    ...
    [ code to retrieve command line argument using the argparse module [
    ...
    [ based on the command line option, generate and print
      the requested usage report ]
    ...