Changes

Jump to: navigation, search

OPS435 Python/assignment 1 fall2022

1,409 bytes removed, 14:24, 24 September 2022
Second Milestone (due October 21)
== Second Milestone (due October 21) ==
For the second milestone you will have two more functions to complete.
* 1. <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 a number of bytes.
For example: <code>{'/usr/lib/local': 33400}</code>
** Again, test using your Python interpreter or the check script.
* To run the check script, enter the following:
<code>python3 checkA2.py -f -v TestDirDict</code>
You will be using a module in the standard library called <b>Argparse</b>. This will help handle more complex sets of options and arguments than simply using sys.argv2.Refer to the argparse documentation to complete the <code>parse_command_argsget_total</code> function. At minimum, your assignment should handle the following options and arguments: * -h will print a usage message. This will automatically be created by argparse itself, you will not need to implement this. However, refer carefully needs to the sample output and ensure that accept your help message matches the required output.* -H will print file sizes in Human readable format. For example, 1024 bytes will be printed as 1K, 1024 kilobytes will be printed as 1Mdictionary, and so on. * -l <number> will set the maximum length of the bar graph. The default should be 20 character. This option will require an option argument that is an integer.* Your script will also require one positional argument which contains the target directory for scanning. Your assignment should be able to produce the following: <code><b>user@host ~ $ python3 duim.py -h</b></code><pre>usage: duim.py [-h] [-H] [-l LENGTH] [target] DU Improved -- See Disk Usage Report with bar charts positional arguments: target The directory to scan. optional arguments: -h, --help show this help message and exit -H, --human-readable print sizes return the total size in human readable format (e.g. 1K 23M 2G) -l LENGTH, --length LENGTH Specify the length bytes of the graphtarget directory. Default is 20. Copyright 2022</pre>
* Use the following to test your code:
<code>python3 checkA2.py -f -v TestArgsTestTotal</code>
== Minimum Viable Product ==

Navigation menu