OPS435 Assignment 1 for Section C

From CDOT Wiki
Revision as of 15:11, 9 October 2020 by Eric.brauer (talk | contribs) (The First Milestone (due October 19))
Jump to: navigation, search


Programs such as screenfetch and top are used to generate a summary of the computer's current state. These types of programs are useful because they present a lot of information quickly, and can quickly suggest a possible avenue of investigation for the systems administrator. For this assignment you will create a "System Information" type program. This program will briefly present important information about the state of the computer system.

The preliminary code should look like this:

Hostname: NeoMex
Kernel Release: 5.4.0-48-generic
Uptime: up 1 week, 1 day, 17 hours, 14 minutes
/dev        [                    ] 0  %
/           [=============       ] 65 %
/boot/efi   [====                ] 18 %
/home       [===============     ] 77 %
Mem         [========            ] 40 %
Swap        [=                   ] 3  %

In addition, you will be expected to build on this capability with some relevant functions.

Assignment Requirements

Permitted Modules

Your python script is allowed to import only the os, subprocess and sys modules from the standard library.

Required Functions

You will need to complete the functions inside the provided file called assignment1.py. The provided checkA1.py will be used to test these functions.

  • call_df() should take no arguments return a list of strings returned by the shell command.
  • call_free() should take no arguments, and should return a list of strings from the shell.
  • call_hostname() and call_uptime() should take no arguments, and should return strings from the shell.
  • percent_to_graph(percent) will take an integer 'percent' and return a bar graph that represents this percentage. The bar graph should begin with '[', and end with ']'. Then contents inside should be 20 characters long.
  • print_percent_line(name, percent) is provided as a convenience for you. It will print a properly formatted line, such as the one in the example above.

Additional Functions

Your code will need to have some additional functions that will accomplish the following:

  • The output from call_df() should be filtered to omit any lines that contain loop or tmpfs. These are not proper file systems and should not be displayed.
  • The output from call_free() should be used to calculate a percent of memory used divided by total memory.
  • The output from uptime should be in "pretty" format, that is, in weeks, days, and so on. You may create this as a Python function, or you may also want to explore another way to do this.

Part of your evaluation will be on how "re-usable" your functions are, and sensible use of arguments and return values.

Use of GitHub

You will be graded partly on the quality of your Github commits. Assignments that do not adhere to these requirements may not be accepted.

Professionals generally follow these guidelines:

  • commit their code after every significant change,
  • the code should run without errors after each commit, and
  • every commit has a descriptive commit message.

After completing each function, make a commit and push your code.

After fixing a problem, make a commit and push your code.

GitHub is your backup and your proof of work.

These guidelines are not always possible, but you will be expected to follow these guidelines as much as possible. Break your problem into smaller pieces, and work iteratively to solve each small problem. Test your code after each small change you make, and address errors as soon as they arise. It will make your life easier!

Additional Features

After completing the above, you are expected to add some additional (two or more) functions providing useful information. Some programs you might want to look at are:

It is expected that the additional features you provided should be useful, non-trivial, they should not require super-user privileges and should not require the installation of additional modules or packages. In this part of the assignment, it is better to try for something useful and fail than it is to implement something trivial! I am looking for evidence that you have worked with Linux machines and know what kinds of information are useful to see at a glance.

You might consider:

  • Network information/IP addresses
  • The state of some important daemons/systemd services
  • process information
  • information about online users
  • number of packages installed
  • cpu load

You may even choose to make the output more attractive/colourful etc. If so, you are permitted to use more modules than those specified above, but make sure that the required functions still succeed as they are. You may want to look into default arguments, ask me for clarification if you're interested.

Coding Standard

Your python script must follow the following coding guide:


  • Please use python's docstring to document your python script (script level documentation) and each of the functions (function level documentation) you created for this assignment. The docstring should describe 'what' the function does, not 'how' it does.
  • Your script should also include in-line comments to explain anything that isn't immediately obvious to a beginner programmer. It is expected that you will be able to explain how each part of your code works in detail.
  • Refer to the docstring for after() to get an idea of the function docstrings required.

Authorship Declaration

All your Python code for this assignment must be placed in the provided Python file called assignment1.py. Do not change the name of this file. Please complete the declaration as part of the docstring in your Python source code file (replace "Student Name" with your own name).

Submission Guidelines

The first step will be to clone the Assignment 1 repository. The invite link will be provided to you by your professor. The repo will contain a check script, a README file, and the file where you will enter your code.

The First Milestone (due October 19)

  • Before you begin programming, it is important to plan your algorithm. Therefore your first task will be to complete and submit an algorithm document. This document should be named algorithm.txt. This file should be plaintext and located in your GitHub repository. The document will contain two sections:
 * A description of how you plan to implement the "percent_to_graph()" function. This explanation should be line-by-line. You will be graded based on your attention to detail. 
 * A description of how you plan to implement the required output overall. Consider the input you are working with, and consider the output you need to present. Break the problem down into smaller problems, and consider any issues you might encounter. You will be graded on evidence that you have considered the task, but not on "getting it right the first time."
 * A brief description of the additional features you'd like to implement.  
  • Once you have completed this file, add it to your GitHub repository. Use git add algorithm.txt, then git commit -m "added algorithm.txt" and git push.

The Assignment (due November 2, 11:59pm)

  • As stated before, your code will be inside the file "assignment1.py". Begin by completing the required functions, committing your changes as you go. Complete and test each function before moving to the next.
  • When you have completed the task, make sure that all your changes have been committed and pushed to GitHub. In addition, you will submit assignment1.py to Blackboard.

The Debrief (due November 12)

This part of the assignment will be completed under GitHub's "Issues" tab.

  • Your professor will examine the code and post questions under "Issues". Answer the questions for full credit of your work.
  • Create new issues to answer the following questions:
 * Is your code portable, ie. have you tested on other Linux machines? How can we make programs portable?
 * Why did you choose the additional features that you did?
 * What challenges did you encounter during the assignment, and what resources did you use to solve your issues? (help from classmates, help from Stackoverflow, debuggers, etc.)


Task Maximum mark Actual mark
Program Authorship Declaration 5
Check script passed 30
today() function design 2
before() function design 5
dbda() function design 10
script level docstring 5
leap_year() function design 2
valid_date() function design 5
usage() function design 1
First Milestone 10
Reflection Essay 10
github.com repository: Commit messages and use 15
Total 100

Due Date and Final Submission requirement

Please submit the following files by the due date:

  • [ ] your algorithm document, named as 'algorithm.txt', in your GitHub repo, by October 19.
  • [ ] your python script, named as 'assignment1.py', in your repository, and also submitted to Blackboard, by November 2 at 11:59pm.
  • [ ] your debrief answers should be submitted as issues to GitHub by November 12.