Changes

Jump to: navigation, search

OPS435 Assignment 1 for Section C

2,708 bytes added, 13:54, 9 October 2020
update for fall 2020
[[Category:OPS435-Python]][[Category:rchanebrauer]]
= Overview =
When making back up 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 data files or log filesinformation quickly, it is and can quickly suggest a very common practice to name possible avenue of investigation for the backup directories and/or files based on the date the backup was donesystems administrator.For this assignment you will create a "System Information" type program. In order to restore or locate This program will briefly present important information about the directory/file, we often need to find out state of the backup date from today's datecomputer system.
The computational task for preliminary code should look like this assignment is to design an algorithm and write a python script according to your algorithm with appropriate functions:<b><code>Hostname: NeoMexKernel Release: 5. The script should take two dates in the "DD4.0-MM48-YYYY" format and return the number of days from the first to the second date. That isgenericUptime: up 1 week, 1 day, 17 hours, if the user enters "14 minutes----------------------------------------/dev [ ] 0 %/ [============= ] 65 %/boot/efi [==== ] 18%/home [=============== ] 77 %--------------06-2020" and "25-06-2020", the script will return "7". Similarly, if the target date is in the past, the script will return a negative number.-----------------------Mem [======== ] 40 %Swap [= ] 3 %</b></code>
In addition, if the user enters one date only, then the number returned should you will be the number of days between today's date and the specified dateexpected to build on this capability with some relevant functions.
= Assignment Requirements =
== Permitted Modules ==<b><font color='blue'>Your python script is allowed to import only the <u>os, subprocess and sys</u> modules from the standard library and all the built-in functions.</font></b> == Required Functions ==You will need to complete the functions inside the provided file called <b>assignment1.py</b>. The provided <code>checkA1.py</code> will be used to test these functions. * <code>call_df()</code> should take no arguments return a list of strings returned by the shell command. * <code>call_free()</code> should take no arguments, and should return a list of strings from the shell.* <code>call_hostname()</code> and <code>call_uptime()</code> should take no arguments, and should return strings from the shell.* <code>percent_to_graph(percent)</code> 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.* <code>print_percent_line(name, percent)</code> 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 <code>call_df()</code> should be filtered to omit any lines that contain <b>loop</b> or <b>tmpfs</b>. These are not proper file systems and should not be displayed.* The output from <code>call_free()</code> should be used to calculate a percent of <b>memory used</b> divided by <b>total memory</b>. * 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. <b>Assignments that do not adhere to these requirements may not be accepted.</b>  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.  <b><u>GitHub is your backup and your proof of work.</b></u>  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: * [https://https://ostechnix.com/neofetch-display-linux-systems-information/ screenfetch/neofetch]* [https://htop.dev/ top/htop/Bashtop] 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.<b>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.</b> 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 <i>are permitted to use more modules</i> 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:* [https://www.python.org/dev/peps/pep-0008/ PEP-8 -- Style Guide for writing Python Code] === Documentation ===* 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. <b><u>It is expected that you will be able to explain how each part of your code works in detail.</u></b>* 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 <b>assignment1.py</b>. <u>Do not change the name of this file.</u> Please complete the declaration <b><u>as part of the docstring</u></b> in your Python source code file (replace "Student Name" with your own name). = Submission Guidelines = == The First Milestone (due June 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_[student_id].txt'''. This file should be plaintext. The document will contain two sections:
* A description of how the "after()" function works. The "after()" function is provided to you in a1_template.py. Open the file, and use clear English to describe what line of code does in such a way that a competent programmer could reproduce the code without seeing it firsthand.
* You should also do some research to find out when we started using the Calendar in the current form. (This will pose a limit on the validity of your algorithm.)
== The Assignment (due July November 3) ==
* As stated before, your code will be inside the file "a1_[studentid].py". The first step will be to clone the Assignment 1 repository. The invite link will be provided to you by your professor. Once you clone the repository, run this command: "cp a1_template.py a1_[studentid].py". (Replace studentid with your myseneca username). Begin writing the content that is required. Additional requirements are outlined below.
== The Debrief (due July 10November 12) ==
This document, like the algorithm document, will be submitted to Blackboard one week after the assignment. Answer the following questions:
* Research Python modules that you could have used to accomplish the same goals as the today() and leap_year() functions.
* Additionally, your professor may have questions specific to your submission. You should answer these questions as well.
== Assignment Requirements ==
=== Required Modules and Functions ===
<b><font color='blue'>Your python script is allowed to import only the <u>os, subprocess and sys</u> modules from the standard library and all the built-in functions.</font></b>
 
Based on the algorithm you have designed for this assignment, you should at least have the following four functions defined in your python script (see later section on the purpose of each function) in order to get a passing grade for this assignment:
* dbda()
* after()
* before()
* today()
You should also create additional functions to improved the re-usability of your python code by adding the following functions to earn the maximum possible mark for this assignment:
* days_in_mon()
* leap_year()
* valid_date()
* usage()
=== Coding Standard ===
Your python script must follow the following coding guide:
* [https://www.python.org/dev/peps/pep-0008/ PEP-8 -- Style Guide for writing Python Code]
 
=== Command Line Argument to be supported ===
* You will provided with a file called a1_template.py.
* Rename this python script as a1_[student_id].py, where [student_id] is your Seneca email user name.
* Your python script must support one or two command line arguments only: both should be valid dates in DD-MM-YYYY format.
* If there are no arguments, more than two arguments, or an invalid date, your script should display the correct usage message and exit.
 
=== Documentation ===
* 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.
* 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 a <font color='red'><b><u>single source python file</u></b></font>. Please complete the declaration <b><u>as part of the docstring</u></b> in your Python source code file (replace "Student Name" with your own name).
 
=== Github Commits ===
You will be graded partly on the quality of your Github commits. 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.
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!
== Tests and Test results ==

Navigation menu