diff --git a/device.py b/device.py index 995cf90..8f2533c 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(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() + 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 = {