Skip to content

Instantly share code, notes, and snippets.

@satoruhiga
Created July 7, 2011 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satoruhiga/1069456 to your computer and use it in GitHub Desktop.
Save satoruhiga/1069456 to your computer and use it in GitHub Desktop.
run_titanium.py
#!/usr/bin/env python
'''
dependent to ios-sim command (https://github.com/Fingertips/ios-sim)
brew install ios-sim
'''
import os
def search_parent(path, target, count):
if target in os.listdir(path):
return path
else:
if count < 0: return None
path = os.path.abspath(os.path.join(path, '..'))
return search_parent(path, target, count - 1)
ti_app_base_path = search_parent('.', 'tiapp.xml', 10)
for i in ['Release', 'Debug']:
p = os.path.join(ti_app_base_path, 'build/iphone/build', i + '-iphonesimulator')
if os.path.exists(p):
l = [x for x in os.listdir(p) if x.endswith('.app')]
if len(l) > 0:
app_path = os.path.join(p, l[0])
else:
app_path = None
if app_path:
os.system('echo "" > /tmp/ios-sim.log')
cmd = 'ios-sim launch %s --stdout /tmp/ios-sim.log --stderr /tmp/ios-sim.log &>/dev/null &' % (app_path)
os.system(cmd)
os.system('tail -f /tmp/ios-sim.log')
else:
print 'app not found'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment