Changes

Jump to: navigation, search

OPS435 Python/assignment 1 fall2022

1,658 bytes removed, 14:48, 24 September 2022
Rubric
To test with the check script, run the following:
<code>python3 checkA2checkA1.py -f -v TestPercent</code>
<code>python3 checkA2checkA1.py -f -v TestDuSub</code>
== 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.argv.Refer to the argparse documentation to complete the <code>parse_command_args</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 to the sample output and ensure that 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 1M, 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* To run the check script, enter the following: target The directory to scan.
optional arguments: -h, --help show this help message and exit -H, --human-readable print sizes in human readable format (e<code>python3 checkA1.g. 1K 23M 2G) py -l LENGTH, f --length LENGTH Specify the length of the graph. Default is 20.v TestDirDict</code>
Copyright 20222. <code>get_total</precode>needs to accept your dictionary, and the target directory, and return the total size in bytes of the target directory.
* Use the following to test your code:
<code>python3 checkA2checkA1.py -f -v TestArgsTestTotal</code>
== Minimum Viable Product ==
Once you have achieved the Milestones, you will have to do the following to get a minimum viable product:
* In your <code>if __name__ == '__main__'</code> block, you will have to call accept a command line argument from the parse_command_args function. Experiment with print statements so that you understand how each option and argument are storeduser This will become your target directory.
** 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>.* You may wish Pass the dictionary into <code>get_total</code> to create one or more functions to do get the total size of the target.* For each item in your dictionary (excluding the followingtarget):
** Use the total size of the target directory to calculate percentage.
** For each subdirectory of target directory, you will need to calculate a percentage, using the total of the target directory.
** Once you've calculated percentage, call <code>percent_to_graph</code> with a max_size of your choice.
** For every subdirectory, print <i>at least</i> the percent, the bar graph, and the name of the subdirectory.
** The target directory <b>should not</b> have a bar graph.
* Finally, print the total size of the target directory.
== Additional Features ==
After completing the above, you are expected may choose to add some additional features. Some improvements you could make are:
* Format the output in a way that is easy to read.
* Convert bytes into a human readable format.
* Add colour to the output.
* Include files in the output.
* Accept more options from the user.
* Sort the output by percentage, or by filename.
 
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 November 4, 11:59pm) ==
| Program Authorship Declaration || 5 ||
|-
| required functions design First Milestone || 5 10 ||
|-
| required functions readability Second Milestone || 5 10 ||
|-
| main loop percent function design || 10 ||
|-
| main loop readability get total function design || 10 ||
|-
| output function other functions design || 5 ||
|-
| output function readability Error checking and exception handling || 5 10 ||
|-
| additional features implemented required functions readability/variable naming || 20 5 ||
|-
| docstrings and comments main loop design || 5 ||
|-
| First Milestone main loop readability || 10 5 ||
|-
| Second Milestone docstrings and comments || 10 15 ||
|-
| github.com repository: Commit messages and use || 10 ||
Please submit the following files by the due date:
* [ ] your python script, named as 'duim.py', in your repository, and also '''submitted to Blackboard''', by August 6 November 4 at 11:59pm.

Navigation menu