Модифицировал комманду удаления бэкапа

This commit is contained in:
rzaitov 2013-11-12 16:04:14 +04:00
parent b736419957
commit 2cf1510af9
4 changed files with 8 additions and 5 deletions

View File

@ -18,7 +18,7 @@ class DeleteBackupCommandBuilder:
assert line is not None
parser = DeleteBackupParser()
folderPath = parser.parseLine(line)
parser.parseLine(line)
command = DeleteBackupCommand(folderPath)
command = DeleteBackupCommand()
return command

View File

@ -1,6 +1,6 @@
from CommandBuilders.DeleteBackupCommandBuilder import DeleteBackupCommandBuilder
line = "delete backup 'BuildSample'"
line = "delete backup"
cmdBuilder = DeleteBackupCommandBuilder()
command = cmdBuilder.getCommandFor(line)

View File

@ -1,3 +1,4 @@
import os
import shutil
from commands.BaseBackupCommand.BaseBackupCommand import BaseBackupCommand
@ -7,4 +8,7 @@ class DeleteBackupCommand(BaseBackupCommand):
BaseBackupCommand.__init__(self)
def execute(self):
if not os.path.exists(self.backupDirAbsPath):
raise Exception('backup folder: {0} not exists'.format(self.backupDirAbsPath))
shutil.rmtree(self.backupDirAbsPath, ignore_errors=True)

View File

@ -10,8 +10,7 @@ class DeleteBackupParser(ParserBackupBase):
def getMatchInfo(self, line):
assert line is not None
folderNameRegexp = r"'(?P<folder>[^']+)'$"
regexpSource = self.startsWith('delete') + self.than('backup') + folderNameRegexp
regexpSource = self.startsWith('delete') + self.endsWith('backup')
regexp = re.compile(regexpSource, re.UNICODE)
match = regexp.match(line)