THIS IS VERY BASIC AND DOES NOT COVER ALL USE CASES. I will attempt to patch this with better logic tomorrow. I'm trying to determine if it's best to use 'du' (which can take a while, and is subject to permissions issues...) or maybe 'sar' (which might not be universally installed...). Any guidance on other potential tools and/or approaches is appreciated.
<br><br>#!/usr/bin/python -tt<br><br># This program is free software; you can redistribute it and/or modify<br># it under the terms of the GNU General Public License as published by<br># the Free Software Foundation; version 2 of the License.
<br>#<br># This program is distributed in the hope that it will be useful,<br># but WITHOUT ANY WARRANTY; without even the implied warranty of<br># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br># GNU Library General Public License for more details.
<br>#<br># You should have received a copy of the GNU General Public License<br># along with this program; if not, write to the Free Software<br># Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<br><br># A very basic (and potential partial patch to livecd-creator)<br># by Adam M. Dutko - (<a href="mailto:dutko.adam@gmail.com">dutko.adam@gmail.com</a>)<br><br># This code is valid for systems with an actual /var partition.
<br># In cases where we only have a root (/), /boot and swap on the system<br># it will fail. I need to write a patch for that case and append to<br># this code. Will try to do this week.<br>#<br>import os<br>import string
<br><br># Get a print out of disk space<br>the_disk = os.popen("df -P")<br><br># We have six columns when using the 'Posix Switch' (-P).<br># partition_details[0] = Filesystem <br># partition_details[1] = 1024-blocks
<br># partition_details[2] = Used <br># partition_details[3] = Available <br># partition_details[4] = Capacity <br># partition_details[5] = Mounted on<br><br>for the_partitions in the_disk.readlines():<br> # Cleanup b/c internal pointers are messy for some reason
<br> check_size = ""<br> check_var = ''<br><br> partition_details = the_partitions.split()<br><br> check_size = partition_details[3].strip() <br> check_var = partition_details[5].strip()
<br> if check_var == '/var' and check_size < "3000000": <br> print "You do not have enough free space to proceed with the installation. " \<br> " Please allocate at least 3 gigabytes of space to /var so the " \
<br> "livecd-creator tool can continue with the build under /var/tmp/livecd-creator."<br> exit <br><br><br>-Adam<br>