diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-07-18 22:55:18 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-07-18 22:55:18 +0100 |
commit | 798907adbd1a00ab1f327e7bf680794c219fec3c (patch) | |
tree | 91866d7aa9af64e8d503827e4f0da6a0b2e52d81 | |
parent | dcb9ca676aa0c4069dbb5a449fcd2cfbafa6de0e (diff) | |
download | seivot-798907adbd1a00ab1f327e7bf680794c219fec3c.tar.gz |
Implement --use-existing.
-rwxr-xr-x | seivot | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -380,8 +380,15 @@ class Seivot(cliapp.Application): self.report = Report(prog) - self.generate_live_data(self.live_data, self.settings['initial-data']) - self.measure(prog.backup, 0, self.settings['initial-data']) + if self.settings['use-existing']: + os.rmdir(self.live_data) + shutil.copytree(self.settings['use-existing'], self.live_data, + symlinks=True) + amount = self.file_sizes(self.live_data) + else: + amount = self.settings['initial-data'] + self.generate_live_data(self.live_data, amount) + self.measure(prog.backup, 0, amount) for i in range(1, generations): self.generate_live_data(self.live_data, @@ -411,6 +418,14 @@ class Seivot(cliapp.Application): runcmd(['genbackupdata', where, '--create', str(size), '--file-size', str(self.settings['file-size'])]) + def file_sizes(self, dirname): + bytes = 0 + for dirname, subdirs, basenames in os.walk(dirname): + for filename in [os.path.join(dirname, x) for x in basenames]: + if os.path.isfile(filename): + bytes += os.path.getsize(filename) + return bytes + def measure(self, func, nth_gen, new_data, **kwargs): logging.info('Measuring %s gen %d' % (func.__name__, nth_gen)) print 'Measuring %s generation %s' % (func.__name__, nth_gen) |