Open main menu

CDOT Wiki β

Changes

OPS445 Online Assignment 2

195 bytes added, 10:04, 16 November 2022
m
Due Date and Final Submission requirement
Notice that total size of the target directory (/usr/local/lib) is around 260 Megabytes. Of that 260 Megabytes, 160 Megabytes can be found in the heroku subdirectory.
160 MB represents 61% of the total 160 261 MB. The percentages don't have to add up to 100%, since with these arguments we are excluding files in the target directory. You may choose to add an option to your script to print files as well.
The bar chart in this example is 20 characters long, but this must be dynamic. The 20 characters does <i>not</i> include the square brackets. The resolution of the bar chart must become more accurate as you increase the total size. For example, if the user specifies a length of 100 total characters, in this example 61 of those characters would be equal signs and 39 would be spaces.
The output of each subdirectory should include percentage, size in bytes (or Human readable if the user uses the -H option), the bar chart and the name of the subdirectory.
** Your list should <u>NOT</u> contain newline characters.
* <code>percent_to_graph()</code> should take two arguments: percent and the total chars. It should return a 'bar graph' as a string.
** Your function should check that a percent argument is a valid number between 0 and 100. It should fail if it isn't. You can <code>raise ValueError</code> 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>=</code> or any other character that makes sense, but the empty space <b>must be composed of spaces</b>, at least until you have passed the first milestone.
** The string returned by this function should only be composed of these two characters. For example, calling <code>percent_to_graph(50, 10)</code> should return:
The repo will contain a check script, a README file, and the file where you will enter your code.
== The First Milestone (due March 30November 25) ==
For the first milestone, you will have two functions to complete.
* <code>call_du_sub</code> will take one argument and return a list. The argument is a target directory. The function will use <code>subprocess.Popen</code> to run the command <b>du -d 1 <target_directory></b>.
<code>python3 CheckA2.py -f -v TestDuSub</code>
== Second Milestone (due April 3December 2) ==
For the second milestone you will have two more functions to complete.
* <code>create_dir_dict</code> will take your list from <code>call_du_sub</code> and return a dictionary.
** Every item in your list should create a key in your dictionary.
** Your dictionary values should be integers, representing the number of bytes.
For example: <code>{'/usr/lib/local': 33400}</code>
* In your <code>if __name__ == '__main__'</code> block, you will have to call the parse_command_args function. Experiment with print statements so that you understand how each option and argument are stored.
** If the user has entered more than one argument, or their argument isn't a valid directory, print an error message.
** If the user doesn't specify any target, use the current directory.
* Call <code>call_du_sub</code> with the target directory.
* Pass the return value from that function to <code>create_dir_dict</code>
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 packages to work. (ie: I shouldn't have to run pip to make your assignment work).
== The Assignment (due April 10December 9, 11:59pm) ==
* Be sure to make your final commit before the deadline. Don't forget to also use <code>git push</code> to push your code into the online repository!
* Then, copy the contents of your <b>duim.py</b> file into a2_yoursenecauser.py, and submit it to Blackboard along with a2_output.txt generated from '''CheckA2.py -f -v''' script. <i>I will use GitHub to evaluate your deadline, but submitting to Blackboard tells me that you wish to be evaluated.</i>
= Rubric =
Please submit the following files by the due date:
* [ ] your Your python script, named as 'duim.py', in your repository, and also '''submitted to Blackboard''' as a2_yoursenecauser.py, by April 10 December 9 at 11:59pm.* Submit it to Blackboard along with a2_output.txt generated from '''CheckA2.py -f -v''' script. <i>I will use GitHub to evaluate your deadline, but submitting to Blackboard tells me that you wish to be evaluated.</i>
572
edits