Open main menu

CDOT Wiki β

Changes

OPS445 Online Assignment 2

24 bytes added, 01:08, 22 March 2022
m
Required Functions
You will need to complete the functions inside the provided file called <code>duim.py</code>. The provided <code>CheckA2.py</code> will be used to test these functions.
* <code>call_du_sub()</code> should take the target directory as an argument and return a list of strings returned by the command <b>du -d 1<target directory></b>.** Use <code>subprocess.Popen</code>.
** '-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>notNOT</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.
** 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:
'===== '
<b>Please note that the '' single quote characters should <u>notNOT</u> be part of the output, they are here to indicate that this is a string!</b>
* <code>create_dir_dict</code> should take a list as the argument, and should return a dictionary.
** The list can be the list returned by <code>call_du_sub()</code>.
572
edits