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,50 +465,59 @@ class IOSDevice(object): ...@@ -465,50 +465,59 @@ class IOSDevice(object):
return False return False
if cls._is_connected: if cls._is_connected:
return True return True
cmd = [ try:
'ios-deploy', cmd = [
'--detect', 'ios-deploy',
'--timeout', '--detect',
'1' '--timeout',
] '1'
logging.info(' '.join(cmd)) ]
out = subprocess.check_output(cmd) logging.info(' '.join(cmd))
match = re.search(r'\[\.\.\.\.\] Found [^\)]*\) connected', out) out = subprocess.check_output(cmd)
cls._is_connected = match is not None 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 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
cmd = [ try:
'ios-deploy', cmd = [
'--justlaunch', 'ios-deploy',
'--timeout', '--justlaunch',
'10', # Smaller timeouts cause it to exit before having launched the app '--timeout',
'--bundle', '10', # Smaller timeouts cause it to exit before having launched the app
ios_app_path '--bundle',
] ios_app_path
logging.info(' '.join(cmd)) ]
subprocess.check_call(cmd) logging.info(' '.join(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
cmd = [ try:
'ios-deploy', cmd = [
'-t', 'ios-deploy',
'1', '-t',
'--bundle_id', '1',
bundle_id, '--bundle_id',
'--upload', bundle_id,
local_path, '--upload',
'--to', local_path,
device_path '--to',
] device_path
logging.info(' '.join(cmd)) ]
subprocess.check_call(cmd) logging.info(' '.join(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