From d70ddbfe50e3243a6dd8c48eaff3cd871e4b362a Mon Sep 17 00:00:00 2001 From: = Date: Wed, 10 Apr 2019 18:59:12 +0200 Subject: [PATCH 1/3] Archive app with tweak --- device.py | 27 +++++++++++++++++++++++++++ job.py | 4 +++- pilot.py | 9 +++++++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/device.py b/device.py index 995cf90..113773c 100644 --- a/device.py +++ b/device.py @@ -30,6 +30,9 @@ def f(*popenargs, **kwargs): import deviceconnection +from paramiko import SSHClient +from scp import SCPClient + logger = logging.getLogger('worker.'+__name__) class iDevice(object): @@ -255,8 +258,32 @@ def archive(self, bundleId, app_archive_folder, app_only=True): if not os.path.exists(app_archive_folder): os.makedirs(app_archive_folder) + + if self.ios_version()[0] > 8: + logger.info("try archiving app %s with tweak" % (bundleId)) + + result = True + + pilot = Pilot(self.base_url()) + device_ipa = pilot.archive(bundleId) + + try: + ssh = SSHClient() + ssh.load_system_host_keys() + ssh.connect('localhost', port=2222, username='root') + scp = SCPCleint(ssh.get_transport()) + scp.get(device_ipa, local_path='%s/%s.ipa' % (app_archive_folder, bundleId)) + scp.close() + ssh.close() + except SCPException as e: + logger.error('archiving app %s failed with: %s', bundleId, e) + result=False + + return result + logger.debug('try archiving app %s with cmd: %s' % (bundleId, ' '.join(options))) result=True + try: output = subprocess.check_output(options) logger.debug('output: %s' % output) diff --git a/job.py b/job.py index 5924125..00ef2fd 100644 --- a/job.py +++ b/job.py @@ -246,7 +246,9 @@ def execute(self): bundleId = jobInfo['bundleId'] if self.device.ios_version()[0] > 8: - logger.debug("skipping app archiving since device is running iOS 9 or later") + logger.debug("try archiving app with tweak") + if not self.backend.has_app_archive(self.appId): + self._archive_app_binary(bundleId) else: logger.debug("check if backend already has an app ipa") if not self.backend.has_app_archive(self.appId): diff --git a/pilot.py b/pilot.py index dc742d4..1bf3708 100644 --- a/pilot.py +++ b/pilot.py @@ -118,8 +118,13 @@ def run_auto_execution(self, bundleId, taskInfo={}): logger.info('execution of %s finished', bundleId) return True - - + def archive(self, bundleId): + logger.info("archiving %s", bundleId) + r = requests.get("%s/archive/%s" % (self.baseUrl, bundleId)) + if (r.status_code != 200): + logger.error("Failed to archive! <%s> Response: %s" % (bundleId, r.text)) + return None + return r.json()['file'] def inject(self, process, command, taskInfo={}): data = { From 31eb3ed65823eebbb7b67ea55aee01c5833eac84 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 10 Apr 2019 19:02:43 +0200 Subject: [PATCH 2/3] Update README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 166ce01..18588fe 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,10 @@ apt-get install libimobiledevice-utils ideviceinstaller ``` ## Running the Worker +For archiving (iOS 9 or higher): +`iproxy 2222 22` +Start the worker: `./worker.py -b http://.local/` From 8133f8457608a81d15f97a63749d661a90279591 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 10 Apr 2019 19:07:01 +0200 Subject: [PATCH 3/3] Archiving without usb --- README.md | 3 --- device.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 18588fe..166ce01 100644 --- a/README.md +++ b/README.md @@ -41,10 +41,7 @@ apt-get install libimobiledevice-utils ideviceinstaller ``` ## Running the Worker -For archiving (iOS 9 or higher): -`iproxy 2222 22` -Start the worker: `./worker.py -b http://.local/` diff --git a/device.py b/device.py index 113773c..8f2533c 100644 --- a/device.py +++ b/device.py @@ -270,7 +270,7 @@ def archive(self, bundleId, app_archive_folder, app_only=True): try: ssh = SSHClient() ssh.load_system_host_keys() - ssh.connect('localhost', port=2222, username='root') + ssh.connect(device_handler.device_connection_info(self.udid)[0], username='root') scp = SCPCleint(ssh.get_transport()) scp.get(device_ipa, local_path='%s/%s.ipa' % (app_archive_folder, bundleId)) scp.close()