def _delete_local_files(self, filename, config): try: keep_copies = getattr(config.retention_local, self.run_type) dir_backups = "{local_path}/{prefix}/{media_type}/{file}*".format( local_path=config.keep_local_path, prefix=self.get_prefix(), media_type=self._media_type, file=filename) delete_local_files(dir_backups, keep_copies) except configparser.NoOptionError: pass
def _delete_local_files(self, filename, config): try: keep_copies = config.getint('retention_local', '%s_copies' % self.run_type) keep_local_path = config.get('destination', 'keep_local_path') dir_backups = "{local_path}/{prefix}/{media_type}/{file}*".format( local_path=keep_local_path, prefix=self.get_prefix(), media_type=self._media_type, file=filename) delete_local_files(dir_backups, keep_copies) except ConfigParser.NoOptionError: pass
def _delete_local_files(self, filename, config): try: keep_copies = getattr(config.retention_local, self.run_type) dir_backups = "{local_path}/{prefix}/{media_type}/{file}*".format( local_path=config.keep_local_path, prefix=self.get_prefix(), media_type=self._media_type, file=filename ) delete_local_files(dir_backups, keep_copies) except ConfigParser.NoOptionError: pass
def test_delete_local_files(mock_glob, mock_os, keep, calls): mock_glob.glob.return_value = ['aaa', 'bbb', 'ccc'] delete_local_files('/foo', keep) mock_os.unlink.assert_has_calls(calls)