Commit 58e013c4 authored by Ian Fischer's avatar Ian Fischer

Merge pull request #960 from iansf/fix_ios_deploy_crashes

Avoid crashing when an iOS device isn't connected
parents 1e61314e 17d89f3d
...@@ -465,6 +465,7 @@ class IOSDevice(object): ...@@ -465,6 +465,7 @@ class IOSDevice(object):
return False return False
if cls._is_connected: if cls._is_connected:
return True return True
try:
cmd = [ cmd = [
'ios-deploy', 'ios-deploy',
'--detect', '--detect',
...@@ -475,12 +476,15 @@ class IOSDevice(object): ...@@ -475,12 +476,15 @@ class IOSDevice(object):
out = subprocess.check_output(cmd) out = subprocess.check_output(cmd)
match = re.search(r'\[\.\.\.\.\] Found [^\)]*\) connected', out) match = re.search(r'\[\.\.\.\.\] Found [^\)]*\) connected', out)
cls._is_connected = match is not None cls._is_connected = match is not None
except subprocess.CalledProcessError:
cls._is_connected = False
return cls._is_connected return cls._is_connected
@classmethod @classmethod
def install_app(cls, ios_app_path): def install_app(cls, ios_app_path):
if not cls.has_ios_deploy(): if not cls.has_ios_deploy():
return return
try:
cmd = [ cmd = [
'ios-deploy', 'ios-deploy',
'--justlaunch', '--justlaunch',
...@@ -491,11 +495,14 @@ class IOSDevice(object): ...@@ -491,11 +495,14 @@ class IOSDevice(object):
] ]
logging.info(' '.join(cmd)) logging.info(' '.join(cmd))
subprocess.check_call(cmd) subprocess.check_call(cmd)
except subprocess.CalledProcessError:
pass
@classmethod @classmethod
def copy_file(cls, bundle_id, local_path, device_path): def copy_file(cls, bundle_id, local_path, device_path):
if not cls.has_ios_deploy(): if not cls.has_ios_deploy():
return return
try:
cmd = [ cmd = [
'ios-deploy', 'ios-deploy',
'-t', '-t',
...@@ -509,6 +516,8 @@ class IOSDevice(object): ...@@ -509,6 +516,8 @@ class IOSDevice(object):
] ]
logging.info(' '.join(cmd)) logging.info(' '.join(cmd))
subprocess.check_call(cmd) subprocess.check_call(cmd)
except subprocess.CalledProcessError:
pass
class IOSSimulator(object): class IOSSimulator(object):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment