From c2e10d066c1daa121d616560d3cd830381a2a9be Mon Sep 17 00:00:00 2001 From: Rustam Zaitov Date: Mon, 30 Sep 2013 21:46:44 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=20=D0=BF=D1=83=D0=B1=D0=BB=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8E=20=D0=B2=20tf=20=D1=81=20=D0=BF=D0=BE=D0=BC?= =?UTF-8?q?=D0=BE=D1=89=D1=8C=D1=8E=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=20Python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/post_build.py | 16 ++++------------ scripts/testflight.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/scripts/post_build.py b/scripts/post_build.py index c225782..057ba01 100644 --- a/scripts/post_build.py +++ b/scripts/post_build.py @@ -1,20 +1,12 @@ -from subprocess import call -import os -import testflight +import testflight as tf def PublishToTestFlight(config): - sln_path = config['sln_path'] - sln_dir = os.path.dirname(sln_path) - - cmd_text_pattern = "curl http://testflightapp.com/api/builds.json -F file=@'{0}' -F api_token='{1}' -F team_token='{2}' -F notes='This build was uploaded via the upload API'" - ipa_rel_path = 'BuildSample/bin/iPhone/Release/BuildSample-{0}.ipa'.format(config['version']) - ipa_abs_path = os.path.join(sln_dir, ipa_rel_path) - api_token = config['api_token'] team_token = config['team_token'] - cmd_text = cmd_text_pattern.format(ipa_abs_path, api_token, team_token) - ret_code = call(cmd_text, shell=True) + publisher = tf.TestFlightPublisher(api_token, team_token) + publisher.Publish(config) + def PrintToConsole(config): print 'Sample post build action!' \ No newline at end of file diff --git a/scripts/testflight.py b/scripts/testflight.py index 8b13789..94611ff 100644 --- a/scripts/testflight.py +++ b/scripts/testflight.py @@ -1 +1,30 @@ +from subprocess import call +import os +class TestFlightPublisherBase: + DefaultNotes = 'This build was uploaded via the upload API' + + def __init__(self, api_token, team_token, notes=DefaultNotes): + self._api_token = api_token + self._team_token = team_token + self._notes = notes + + def Publish(self, pathToFile): + cmd_text_pattern = "curl http://testflightapp.com/api/builds.json -F file=@'{0}' -F api_token='{1}' -F team_token='{2}' -F notes='{3}'" + cmd_text = cmd_text_pattern.format(pathToFile, self._api_token, self._team_token, self._notes) + + ret_code = call(cmd_text, shell=True) + return ret_code + +class TestFlightPublisher(TestFlightPublisherBase): + def __init__(self, api_token, team_token, notes=TestFlightPublisherBase.DefaultNotes): + TestFlightPublisherBase.__init__(self, api_token, team_token, notes) + + def Publish(self, config): + sln_path = config['sln_path'] + sln_dir = os.path.dirname(sln_path) + + ipa_rel_path = 'BuildSample/bin/iPhone/Release/BuildSample-{0}.ipa'.format(config['version']) + ipa_abs_path = os.path.join(sln_dir, ipa_rel_path) + + return TestFlightPublisherBase.Publish(self, ipa_abs_path) \ No newline at end of file