From 17d89f3dbbf1742e18aab26142b30a812dd1ec5f Mon Sep 17 00:00:00 2001 From: Ian Fischer Date: Mon, 31 Aug 2015 10:41:52 -0700 Subject: [PATCH] =?UTF-8?q?Avoid=20crashing=20when=20an=20iOS=20device=20i?= =?UTF-8?q?sn=E2=80=99t=20connected.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/flutter/lib/sky_tool | 75 ++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/packages/flutter/lib/sky_tool b/packages/flutter/lib/sky_tool index e8bb3df2c7..d85739da35 100755 --- a/packages/flutter/lib/sky_tool +++ b/packages/flutter/lib/sky_tool @@ -465,50 +465,59 @@ class IOSDevice(object): return False if cls._is_connected: return True - cmd = [ - 'ios-deploy', - '--detect', - '--timeout', - '1' - ] - logging.info(' '.join(cmd)) - out = subprocess.check_output(cmd) - match = re.search(r'\[\.\.\.\.\] Found [^\)]*\) connected', out) - cls._is_connected = match is not None + try: + cmd = [ + 'ios-deploy', + '--detect', + '--timeout', + '1' + ] + logging.info(' '.join(cmd)) + out = subprocess.check_output(cmd) + match = re.search(r'\[\.\.\.\.\] Found [^\)]*\) connected', out) + cls._is_connected = match is not None + except subprocess.CalledProcessError: + cls._is_connected = False return cls._is_connected @classmethod def install_app(cls, ios_app_path): if not cls.has_ios_deploy(): return - cmd = [ - 'ios-deploy', - '--justlaunch', - '--timeout', - '10', # Smaller timeouts cause it to exit before having launched the app - '--bundle', - ios_app_path - ] - logging.info(' '.join(cmd)) - subprocess.check_call(cmd) + try: + cmd = [ + 'ios-deploy', + '--justlaunch', + '--timeout', + '10', # Smaller timeouts cause it to exit before having launched the app + '--bundle', + ios_app_path + ] + logging.info(' '.join(cmd)) + subprocess.check_call(cmd) + except subprocess.CalledProcessError: + pass @classmethod def copy_file(cls, bundle_id, local_path, device_path): if not cls.has_ios_deploy(): return - cmd = [ - 'ios-deploy', - '-t', - '1', - '--bundle_id', - bundle_id, - '--upload', - local_path, - '--to', - device_path - ] - logging.info(' '.join(cmd)) - subprocess.check_call(cmd) + try: + cmd = [ + 'ios-deploy', + '-t', + '1', + '--bundle_id', + bundle_id, + '--upload', + local_path, + '--to', + device_path + ] + logging.info(' '.join(cmd)) + subprocess.check_call(cmd) + except subprocess.CalledProcessError: + pass class IOSSimulator(object):