Permalink
Browse files

Resolved LP#782807 Uncaught exception "ZeroDivisionError: float divis…

…ion by zero"
  • Loading branch information...
1 parent 97a4ba8 commit 2f694862f537d18ed9273b354ad3516f7dfb72b2 BJ Dierkes committed May 14, 2011
@@ -123,14 +123,20 @@ def execute(self, job, event):
:raises: BackupError if estimated_space > available_space
"""
if event == 'after-backup':
+ percent_size = 0
+ suggested_size = 0
+ if parse_bytes(self.job_info['estimated-size']) > 0:
+ percent_size = (100.0*job.store.size() /
+ parse_bytes(self.job_info['estimated-size']))
+ suggested_size = (float(job.store.size()) /
+ parse_bytes(self.job_info['estimated-size']))
+
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']),
+ LOG.info("+ %.2f%% of estimated size %s ",
+ percent_size,
self.job_info['estimated-size'])
LOG.info("+ Suggested estimated-size-factor = %.2f",
- float(job.store.size()) /
- parse_bytes(self.job_info['estimated-size']))
+ suggested_size)
return
LOG.info("+ Estimating backup size")
@@ -42,8 +42,8 @@ def estimate(self):
LOG.info("----------------------")
if self.config['mysqldump']['estimate-method'].startswith('const:'):
return parse_size(self.config['mysqldump']['estimate-method'])
- return sum([db.size for db in self._schema.databases])
-
+ return ([db.size for db in self._schema.databases])
+
def _setup(self):
os.makedirs(os.path.join(self.path, 'backup_data'))
LOG.info("+ mkdir %s", os.path.join(self.path, 'backup_data'))

0 comments on commit 2f69486

Please sign in to comment.