384
edits
Changes
→Second Milestone (due February 21)
[[Category:OPS435-Python]][[Category:ebrauer]]
= Overview : du Improved =Programs such as screenfetch and top are used to generate <code>du</code> is a summary of tool for inspecting directories. It will return the computer's current state. These types contents of programs a directory along with how much drive space they are useful because they present a lot of information quicklyusing. However, and it can be parse its output quickly suggest a possible avenue of investigation for the systems administrator.For this assignment you will create , as it usually returns file sizes as a "System Information" type program. This program will briefly present important information about the state number of the computer system.bytes:
= 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 <code>assignment1duim.py</code>. The provided <code>checkA1.py</code> will be used to test these functions.
* <code>call_dfcall_du_sub()</code> should take no arguments the target directory as an argument and return a list of strings returned by the shell command<b>du -d 1<target directory></b>.** Use subprocess.Popen. ** '-d 1' specifies a <i>max depth</i> of 1. Your list shouldn't include files, just a list of subdirectories in the target directory.** Your list should <u>not</u> contain newline characters. * <code>call_freepercent_to_graph()</code> should take no two arguments, : percent and the total chars. It should return a list of strings from the shell'bar graph' as a string.* * Your function should check that the percent argument is a valid number between 0 and 100. It should fail if it isn't. You can <code>call_hostname()raise ValueError</code> and in this case.** <b>total chars</b> refers to the total number of characters that the bar graph will be composed of. You can use equal signs <code>call_uptime()=</code> should take no argumentsor any other character that makes sense, but the empty space <b>must be composed of spaces</b>, and should return strings from at least until you have passed the shellfirst milestone.* * The string returned by this function should only be composed of these two characters. For example, calling <code>percent_to_graph(percent50, 10)</code> will take an integer should return: 'percent===== ' and return * <code>create_dir_dict</code> should take a bar graph that represents this percentage. The bar graph should begin with '['list as the argument, and end with ']'. Then contents inside should be 20 characters longreturn a dictionary.* * The list can be the list returned by <code>print_percent_linecall_du_sub(name, percent)</code> is provided . ** The dictionary that you return should have the full directory name as a convenience for you. It will print a properly formatted line<i>key</i>, such and the number of bytes in the directory as the one in <i>value</i>. This value should be an integer. For example, using the example aboveof <b>/usr/local/lib</b>, the function would return: {'/usr/local/lib/heroku': 164028, '/usr/local/lib/python2.7': 11072, ...}
== Additional Functions ==
== Use of GitHub ==
You will be graded partly on the quality of your Github commits. You may make as many commits as you wish, it will have no impact on your grade. The only exception to this is <b>assignments with very few commits.</b> These will receive low marks for GitHub use and may be flagged for possible academic integrity violations. <b><font color='blue'>Assignments that do not adhere to these requirements may not be accepted.</font></b>
Professionals generally follow these guidelines:
* commit their code after every significant change,
* the code <i>should hopefully</i> run without errors after each commit, and
* every commit has a descriptive commit message.
<b><u>GitHub is your backup and your proof of work.</u></b>
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 ==
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 and Process = == 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_[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 will then apply the same principles to create an algorithm for "before()", and "dbda()". Inside the code, if you are calling another function like "leap_year", you may simply describe what the function will return, and not the operation of the function itself. * This file will be submitted to Blackboard a week after the assignment goes live, and should be your first priority. The object of the milestone is not to have a 100% perfect algorithm, but to plan ahead and anticipate challenges and issues with the assignment. The milestone will also give your professor an opportunity for feedback.* [https://simple.m.wikipedia.org/wiki/Algorithm Here is an basic introduction to Algorithm]* While you are working on the step-by-step instructions, note that there are different number of days in each month and some years have 365 days and some years have 366 days.* 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 Clone Your Repo (due November 3ASAP) == * 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 The repo will contain a check script, a README file, and the file where you clone the repository, run this command: "cp a1_template.py a1_[studentid].py". (Replace studentid with will enter your myseneca username). Begin writing the content that is required. Additional requirements are outlined belowcode.
== The Debrief First Milestone (due November 12February 14) ==This document, like For the algorithm document, first milestone you will be submitted have two functions to Blackboard one week after the assignmentcomplete. Answer the following questions:* Research Python modules that you could have used to accomplish the same goals as the today() <code>call_du_sub</code> will take one argument and leap_year() functionsreturn a list. * Which solution is preferable, in terms of performance? Which solution The argument is preferable, in terms of programmer hours? (which solution would take longer for a programmer target directory. The function will use <code>subprocess.Popen</code> to implement?)* Which approach would be preferable in run the "real world"? Why is it useful to try creating our own algorithm?command <b>du -d l <target_directory></b>. * What challenges did you encounter during the assignment, <code>percent_to_graph</code> will take two arguments and what resources did you use to solve your issues? (help from classmates, help from Stackoverflow, debuggers, etc.)* Additionally, your professor may have questions specific to your submission. You should answer these questions as wellreturn a string.
In order to complete <code>percent_to_graph()</code>, it's helpful to know the equation for converting a number from one scale to another.
[[File:Scaling-formula.png]]
In this equation, ``x`` refers to your input value percent and ``y`` will refer to the number of symbols to print. The max of percent is 100 and the min of percent is 0.
Be sure that you are rounding to an integer, and then print that number of symbols to represent the percentage. The number of spaces that you print will be the inverse.
= Rubric =
| Program Authorship Declaration || 5 ||
|-
| Check script passed required functions design || 30 5 ||
|-
| today() function design required functions readability || 2 5 ||
|-
| before() function main loop design || 5 10 ||
|-
| dbda() function design main loop readability || 10 ||
|-
| script level docstring output function design || 5 ||
|-
| leap_year() output function design readability || 2 5 ||
|-
| valid_date() function design additional features implemented || 5 20 ||
|-
| usage() function design docstrings and comments || 1 5 ||
|-
| First Milestone ||10||
|-
| Reflection Essay Second Milestone || 10 ||
|-
| github.com repository: Commit messages and use ||1510 ||
|-
|'''Total''' || 100 ||
= Due Date and Final Submission requirement =
Please submit the following files by the due date: