Добавил команду востановления из бэкапа

This commit is contained in:
rzaitov 2013-11-01 15:08:44 +04:00
parent 939a9e2270
commit ba869e6016
5 changed files with 10 additions and 15 deletions

View File

@ -3,10 +3,6 @@ from parser.BackupParser.RestoreBackupParser import RestoreBackupParser
class RestoreBackupCommandBuilder:
def __init__(self, pathProvider):
assert pathProvider is not None
self.__pathProvider = pathProvider
def isRestoreBackup(self, line):
assert line is not None
@ -21,5 +17,5 @@ class RestoreBackupCommandBuilder:
parser = RestoreBackupParser()
parser.parseLine(line)
command = RestoreBackupCommand(self.__pathProvider)
command = RestoreBackupCommand()
return command

View File

@ -15,6 +15,6 @@ create dirs 'Output/Appstore/Artifacts'
copy 'BuildSample/BuildSample/Output/BuildSample-1.2.3.ipa' to 'Output/Appstore/Artifacts'
sh cp -a BuildSample/BuildSample/Output/ Output/Appstore/
restore from backup
sh echo hello from Rustam

View File

@ -5,6 +5,7 @@ from CommandBuilders.MakeDirsCommandBuilder import MakeDirsCommandBuilder
from CommandBuilders.PatchCsprojCommandBuilder import PatchCsprojCommandBuilder
from CommandBuilders.PatchInfoplistCommandBuilder import PatchInfoplistCommandBuilder
from CommandBuilders.RemoveProjectCommandBuilder import RemoveProjectCommandBuilder
from CommandBuilders.RestoreBackupCommandBuilder import RestoreBackupCommandBuilder
from CommandBuilders.ShCommandBuilder import ShCommandBuilder
from commands.ValueProvider import ValueProvider
@ -18,6 +19,7 @@ class StepsRunner:
self.shCommandBuilder = ShCommandBuilder()
self.removeProjectBuilder = RemoveProjectCommandBuilder()
self.createBackupBuilder = CreateBackupCommandBuilder()
self.restoreFromBackupBuilder = RestoreBackupCommandBuilder()
self.createDirs = MakeDirsCommandBuilder()
self.patchCsproj = PatchCsprojCommandBuilder(config, self.valueProvider)
self.patchInfoPlist = PatchInfoplistCommandBuilder(self.valueProvider)
@ -69,6 +71,9 @@ class StepsRunner:
elif self.copyBuilder.isCopy(line):
cmd =self.copyBuilder.getCommandFor(line)
cmd.execute()
elif self.restoreFromBackupBuilder.isRestoreBackup(line):
cmd = self.restoreFromBackupBuilder.getCommandFor(line)
cmd.execute()
else:
msg = "unrecognised step. Line: '{0}'".format(line)
raise Exception(msg)

View File

@ -3,18 +3,11 @@ import shutil
class RestoreBackupCommand:
def __init__(self, pathProvider):
assert pathProvider is not None
self.__pathProvider = pathProvider
def execute(self):
baseDir = self.__pathProvider.resolveAbsPath('.')
dirPairs = [(name, "backup.{0}".format(name)) for name in os.listdir(baseDir) if os.path.isdir(self.__pathProvider.resolveAbsPath(name)) and not name.startswith('backup.')]
dirPairs = [(name, "backup.{0}".format(name)) for name in os.listdir('.') if os.path.isdir(name) and not name.startswith('backup.')]
for pair in dirPairs:
absPair = (self.__pathProvider.resolveAbsPath(pair[0]), self.__pathProvider.resolveAbsPath(pair[1]))
absPair = (pair[0], pair[1])
if not os.path.exists(absPair[1]):
continue

View File

@ -16,4 +16,5 @@ class RestoreBackupParser(LineParser):
assert line is not None
isValid = line.startswith('restore from backup')
return isValid