Skip to content

Instantly share code, notes, and snippets.

@abg
Created May 14, 2011 21:38
Show Gist options
  • Save abg/972666 to your computer and use it in GitHub Desktop.
Save abg/972666 to your computer and use it in GitHub Desktop.
holland divide-by-zero error
class CheckForSpaceHook(BackupHook):
"""Check for available space before starting a backup"""
job_info = None
def execute(self, job, event):
"""Estimate the available space from the plugin and abort if
there does not appear to be enought to successfully complete this
backup based on the estimate.
:raises: BackupError if estimated_space > available_space
"""
if event == 'after-backup':
LOG.info("+ Final backup size %s", format_bytes(job.store.size()))
LOG.info("+ %.2f%% of estimated size %s ",
100.0*job.store.size() /
parse_bytes(self.job_info['estimated-size']),
self.job_info['estimated-size'])
LOG.info("+ Suggested estimated-size-factor = %.2f",
float(job.store.size()) /
parse_bytes(self.job_info['estimated-size']))
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment