384
edits
Changes
→Second Milestone (due February 21)
* <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>.
* <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 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 = == Clone Your Repo (ASAP) ==
The first step will be to clone the Assignment 1 repository. The invite link will be provided to you by your professor. The repo will contain a check script, a README file, and the file where you will enter your code.
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 l <target_directory></b>.
* <code>percent_to_graph</code> will take two arguments and return 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. Test your functions with the Python interpreter. Use <code>import duimpython3</code>, then call functions : import duim duim.percent_to_graph(50, 10) To test with test argumentsthe check script, run the following: <code>python3 checkA1.py -f -v TestPercent</code>
== Second Milestone (due February 21) ==
For the second milestone you will have two one more functions function 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 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>python checkA1.py -f -v TestDirDict</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>get_totalif __name__ == '__main__'</code> block, you will take two have to check command line arguments: . ** If the user has entered no command line argument, use the current directory.** If the user has entered more than one argument, or their argument isn't a valid directory, print an error message.** Otherwise, the argument will be your list from target directory.* Call <code>call_du_sub</code> and with the target directory. It will * Pass the return an integer value from that is function to <code>create_dir_dict</code>* You may wish to create one or more functions to do the following:** Use the total size of the target directoryto 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. == Additional Features == After completing the above, you are expected to add some additional features. Some improvements you could make are: * Format the output in a way that is easy to read.* Add colour to the output.* Add more error checking, print a usage message to the user.* Convert bytes to a human-readable format. NOTE: This doesn't have to be 100% accurate to get marks.* 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 March 7, 11:59pm) ==
* As stated before, Be sure to make your code will be inside the file "assignment1.py". Begin by completing the required functions, committing your changes as you go. Complete and test each function final commit before moving to the nextdeadline. * When you have completed Then, copy the task, make sure that all contents of your changes have been committed and pushed to GitHub<b>duim. py</b>In additionfile into a Word document, you will and submit <code>assignment1it to Blackboard.py</codei> I will use GitHub to evaluate your deadline, but submitting to Blackboardtells me that you wish to be evaluated.</bi>
= Rubric =
| Program Authorship Declaration || 5 ||
|-
| Check script passed required functions design || 20 5 |||-| required functions readability || 5 ||
|-
| given functions main loop design || 5 10 ||
|-
| df/free filtering functions design main loop readability || 10 ||
|-
| additional features appropriate output function design || 10 5 ||
|-
| additional features implemented output function readability || 10 5 ||
|-
| docstrings additional features implemented || 5 20 ||
|-
| in-line docstrings and comments || 5 ||
|-
| First Milestone ||10||
|-
| Debrief Second Milestone || 10 ||
|-
| github.com repository: Commit messages and use || 10 ||
Please submit the following files by the due date: