diff --git a/scripts/TouchinBuild/CommandBuilders/ShCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/ShCommandBuilder.py index b555582..bbe4cfd 100644 --- a/scripts/TouchinBuild/CommandBuilders/ShCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/ShCommandBuilder.py @@ -1,4 +1,4 @@ -from commands.ShCommand import ShCommand +from commands.ShTextCommand import ShTextCommand from parsers.ShParser import ShParser @@ -19,5 +19,5 @@ class ShCommandBuilder: cmdText = parser.parseLine(line) - command = ShCommand(cmdText) + command = ShTextCommand(cmdText) return command diff --git a/scripts/TouchinBuild/Core/LineConveyor/PreprocessorBase.py b/scripts/TouchinBuild/Core/LineConveyor/PreprocessorBase.py index 2a18eda..d07e2fb 100644 --- a/scripts/TouchinBuild/Core/LineConveyor/PreprocessorBase.py +++ b/scripts/TouchinBuild/Core/LineConveyor/PreprocessorBase.py @@ -1,7 +1,7 @@ import abc -class PreprocessorBase: +class PreprocessorBase(object): __metaclass__ = abc.ABCMeta def __init__(self): diff --git a/scripts/TouchinBuild/Tests/ManualTests/run_sh_command.py b/scripts/TouchinBuild/Tests/ManualTests/run_sh_command.py index 8b633ff..d32bc5a 100644 --- a/scripts/TouchinBuild/Tests/ManualTests/run_sh_command.py +++ b/scripts/TouchinBuild/Tests/ManualTests/run_sh_command.py @@ -1,7 +1,7 @@ -from commands.ShCommand import ShCommand +from commands.ShCommand import ShTextCommand -calendarCommand = ShCommand('cal 12 2013') +calendarCommand = ShTextCommand('cal 12 2013') calendarCommand.execute() -touchCommand = ShCommand('touch ../tmp.txt') +touchCommand = ShTextCommand('touch ../tmp.txt') touchCommand.execute() diff --git a/scripts/TouchinBuild/commands/BaseBackupCommand/BaseBackupCommand.py b/scripts/TouchinBuild/commands/BaseBackupCommand/BaseBackupCommand.py index 95a4eb7..aba3acc 100644 --- a/scripts/TouchinBuild/commands/BaseBackupCommand/BaseBackupCommand.py +++ b/scripts/TouchinBuild/commands/BaseBackupCommand/BaseBackupCommand.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- - import os +from commands.CommandBase import CommandBase -class BaseBackupCommand: +class BaseBackupCommand(CommandBase): def __init__(self): + CommandBase.__init__(self) self.folderPath = '.' # вычислять абсолютные пути надо на этапе создания комманды diff --git a/scripts/TouchinBuild/commands/CleanBuildCommands/CleanBuildCommandBase.py b/scripts/TouchinBuild/commands/CleanBuildCommands/CleanBuildCommandBase.py index 8bed240..38dd455 100644 --- a/scripts/TouchinBuild/commands/CleanBuildCommands/CleanBuildCommandBase.py +++ b/scripts/TouchinBuild/commands/CleanBuildCommands/CleanBuildCommandBase.py @@ -1,8 +1,10 @@ -from subprocess import call +from commands.ShellCommandBase import ShellCommandBase -class CleanBuildCommandBase: +class CleanBuildCommandBase(ShellCommandBase): def __init__(self, commandPattern, pathToBuildUtil, slnPath, slnConfig): + ShellCommandBase.__init__(self) + assert commandPattern is not None assert pathToBuildUtil is not None assert slnPath is not None @@ -15,4 +17,5 @@ class CleanBuildCommandBase: def execute(self): cmdText = self.__commandPattern.format(self.__pathToBuildUtil, self.__slnConfig, self.__slnPath) - call(cmdText, shell=True) + + self.executeShell(cmdText) diff --git a/scripts/TouchinBuild/commands/CommandBase.py b/scripts/TouchinBuild/commands/CommandBase.py new file mode 100644 index 0000000..6411593 --- /dev/null +++ b/scripts/TouchinBuild/commands/CommandBase.py @@ -0,0 +1,12 @@ +import abc + + +class CommandBase(object): + __metaclass__ = abc.ABCMeta + + def __init__(self): + pass + + @abc.abstractmethod + def execute(self): + pass diff --git a/scripts/TouchinBuild/commands/CopyCommand.py b/scripts/TouchinBuild/commands/CopyCommand.py index dc8dd94..dd9d032 100644 --- a/scripts/TouchinBuild/commands/CopyCommand.py +++ b/scripts/TouchinBuild/commands/CopyCommand.py @@ -1,8 +1,12 @@ import shutil import os +from commands.CommandBase import CommandBase -class CopyCommand: + +class CopyCommand(CommandBase): def __init__(self, copyArguments): + CommandBase.__init__(self) + assert copyArguments is not None self.__copyArguments = copyArguments diff --git a/scripts/TouchinBuild/commands/MakeDirsCommand.py b/scripts/TouchinBuild/commands/MakeDirsCommand.py index 7ba3c22..1fece89 100644 --- a/scripts/TouchinBuild/commands/MakeDirsCommand.py +++ b/scripts/TouchinBuild/commands/MakeDirsCommand.py @@ -1,13 +1,10 @@ -from commands.ShCommand import ShCommand +from commands.ShTextCommand import ShTextCommand -class MakeDirsCommand: +class MakeDirsCommand(ShTextCommand): def __init__(self, path): assert path is not None + self.path = path - self.__path = path - - def execute(self): - cmdText = "mkdir -p '{0}'".format(self.__path) - innerCommand = ShCommand(cmdText) - innerCommand.execute() + cmdText = "mkdir -p '{0}'".format(self.path) + ShTextCommand.__init__(self, cmdText) \ No newline at end of file diff --git a/scripts/TouchinBuild/commands/PatchCsprojCommand.py b/scripts/TouchinBuild/commands/PatchCsprojCommand.py index 68007eb..00036e3 100644 --- a/scripts/TouchinBuild/commands/PatchCsprojCommand.py +++ b/scripts/TouchinBuild/commands/PatchCsprojCommand.py @@ -1,7 +1,10 @@ +from commands.CommandBase import CommandBase import utils.CsprojPatcher as csproj -class PatchCsprojCommand(): +class PatchCsprojCommand(CommandBase): def __init__(self, csprojAbsPath, key, value, slnConfig): + CommandBase.__init__(self) + assert csprojAbsPath is not None assert key is not None assert value is not None diff --git a/scripts/TouchinBuild/commands/PatchInfoPlistCommand.py b/scripts/TouchinBuild/commands/PatchInfoPlistCommand.py index c16987b..a9654df 100644 --- a/scripts/TouchinBuild/commands/PatchInfoPlistCommand.py +++ b/scripts/TouchinBuild/commands/PatchInfoPlistCommand.py @@ -1,8 +1,11 @@ +from commands.CommandBase import CommandBase from utils.InfoPlistPatcher import InfoPlistPatcher -class PatchInfoPlistCommand(): +class PatchInfoPlistCommand(CommandBase): def __init__(self, pathToPlist, key, value): + CommandBase.__init__(self) + assert pathToPlist is not None assert key is not None assert value is not None diff --git a/scripts/TouchinBuild/commands/RemoveProjectCommand.py b/scripts/TouchinBuild/commands/RemoveProjectCommand.py index 858d205..61ae1df 100644 --- a/scripts/TouchinBuild/commands/RemoveProjectCommand.py +++ b/scripts/TouchinBuild/commands/RemoveProjectCommand.py @@ -1,8 +1,11 @@ +from commands.CommandBase import CommandBase from utils.SlnPatcher import SlnPatcher -class RemoveProjectCommand: +class RemoveProjectCommand(CommandBase): def __init__(self, slnPath, projectName): + CommandBase.__init__(self) + assert slnPath is not None assert projectName is not None diff --git a/scripts/TouchinBuild/commands/ShCommand.py b/scripts/TouchinBuild/commands/ShCommand.py deleted file mode 100644 index 54f02f8..0000000 --- a/scripts/TouchinBuild/commands/ShCommand.py +++ /dev/null @@ -1,11 +0,0 @@ -from subprocess import call - - -class ShCommand: - def __init__(self, commandText): - assert commandText is not None - - self.__commandText = commandText - - def execute(self): - call(self.__commandText, shell=True) diff --git a/scripts/TouchinBuild/commands/ShTextCommand.py b/scripts/TouchinBuild/commands/ShTextCommand.py new file mode 100644 index 0000000..839a1af --- /dev/null +++ b/scripts/TouchinBuild/commands/ShTextCommand.py @@ -0,0 +1,12 @@ +from commands.ShellCommandBase import ShellCommandBase + + +class ShTextCommand(ShellCommandBase): + def __init__(self, commandText): + ShellCommandBase.__init__(self) + assert commandText is not None + + self.commandText = commandText + + def execute(self): + self.executeShell(self.commandText) \ No newline at end of file diff --git a/scripts/TouchinBuild/commands/ShellCommandBase.py b/scripts/TouchinBuild/commands/ShellCommandBase.py new file mode 100644 index 0000000..79807cc --- /dev/null +++ b/scripts/TouchinBuild/commands/ShellCommandBase.py @@ -0,0 +1,16 @@ +from commands.CommandBase import CommandBase +from subprocess import call + + +class ShellCommandBase(CommandBase): + def __init__(self): + CommandBase.__init__(self) + + def executeShell(self, commandText): + assert commandText is not None + + retCode = call(commandText, shell=True) + + if retCode != 0: + msg = 'problem with shell command: {0}'.format(commandText) + raise Exception(msg) \ No newline at end of file diff --git a/scripts/TouchinBuild/commands/TestflightCommand.py b/scripts/TouchinBuild/commands/TestflightCommand.py index f0b73f0..1cc9878 100644 --- a/scripts/TouchinBuild/commands/TestflightCommand.py +++ b/scripts/TouchinBuild/commands/TestflightCommand.py @@ -1,8 +1,11 @@ +from commands.CommandBase import CommandBase from utils.TestflightPublisher import TestFlightPublisher -class TestflightCommand: +class TestflightCommand(CommandBase): def __init__(self, pathToFile, api_token, team_token, notes): + CommandBase.__init__(self) + assert pathToFile is not None self.__pathToFile = pathToFile