本文整理汇总了Python中utils.run_shell函数的典型用法代码示例。如果您正苦于以下问题:Python run_shell函数的具体用法?Python run_shell怎么用?Python run_shell使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_shell函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _sign_app
def _sign_app(self, build, provisioning_profile, certificate, entitlements_file):
app_folder_name = self._locate_ios_app(error_message="Couldn't find iOS app in order to sign it")
path_to_app = path.abspath(path.join(self.path_to_ios_build, 'ios', app_folder_name))
codesign = self._check_for_codesign()
embedded_profile = 'embedded.mobileprovision'
path_to_embedded_profile = path.abspath(path.join(path_to_app, embedded_profile))
resource_rules = path.abspath(path.join(path_to_app, 'ResourceRules.plist'))
path_to_pp = path.join(build.orig_wd, provisioning_profile)
if not path.isfile(path_to_pp):
raise IOSError("{path} is not a provisioning_profile: "
"use the --ios.profile.provisioning_profile option".format(
path=path_to_pp)
)
try:
os.remove(path_to_embedded_profile)
except Exception:
LOG.warning("Couldn't remove {profile}".format(profile=path_to_embedded_profile))
_copy(path_to_pp, path_to_embedded_profile)
run_shell(codesign, '--force', '--preserve-metadata',
'--entitlements', entitlements_file,
'--sign', certificate,
'--resource-rules={0}'.format(resource_rules),
path_to_app)
开发者ID:fnava621,项目名称:trigger-weather,代码行数:26,代码来源:ios_tasks.py
示例2: run_iphone_simulator
def run_iphone_simulator(self):
possible_app_location = '{0}/ios/simulator-*/'.format(self.path_to_ios_build)
LOG.debug('Looking for apps at {0}'.format(possible_app_location))
possible_apps = glob(possible_app_location)
if not possible_apps:
raise IOSError("Couldn't find iOS app to run it in the simulator")
path_to_app = possible_apps[0]
LOG.debug('trying to run app %s' % path_to_app)
if path.exists(SIMULATOR_IN_42):
LOG.debug("detected XCode version 4.2 or older")
ios_sim_binary = "ios-sim-xc4.2"
elif path.exists(SIMULATOR_IN_43):
LOG.debug("detected XCode version 4.3 or newer")
ios_sim_binary = "ios-sim-xc4.3"
else:
raise IOSError("Couldn't find iOS simulator in {old} or {new}".format(
old=SIMULATOR_IN_42,
new=SIMULATOR_IN_43,
))
logfile = tempfile.mkstemp()[1]
subprocess.Popen([path.join(self._lib_path(), ios_sim_binary), "launch", path_to_app, '--stderr', logfile])
LOG.info('Showing log output:')
try:
run_shell("tail", "-f", logfile, fail_silently=False, command_log_level=logging.INFO)
finally:
os.remove(logfile)
开发者ID:fnava621,项目名称:trigger-weather,代码行数:29,代码来源:ios_tasks.py
示例3: run_idevice
def run_idevice(self, build, device, provisioning_profile, certificate):
possible_app_location = '{0}/ios/device-*/'.format(self.path_to_ios_build)
LOG.debug('Looking for apps at {0}'.format(possible_app_location))
possible_apps = glob(possible_app_location)
if not possible_apps:
raise IOSError("Couldn't find iOS app to run on a device")
path_to_app = possible_apps[0]
LOG.debug("signing {app}".format(app=path_to_app))
plist_str = self._grab_plist_from_binary_mess(provisioning_profile)
plist_dict = self._parse_plist(plist_str)
self.check_plist_dict(plist_dict, self.path_to_ios_build)
LOG.info("Plist OK.")
self._create_entitlements_file(build, plist_dict, path_to_app)
self._sign_app(build=build,
provisioning_profile=provisioning_profile,
certificate=certificate,
entitlements_file=path.join(path_to_app, 'template.entitlements'),
)
fruitstrap = [path.join(self._lib_path(), 'fruitstrap'), path_to_app]
if device and device.lower() != 'device':
# pacific device given
fruitstrap.append(device)
LOG.info('installing app on device {device}: is it connected?'.format(device=device))
else:
LOG.info('installing app on device: is it connected?')
run_shell(*fruitstrap, fail_silently=False, command_log_level=logging.INFO)
LOG.info("We can't show log output from your device here: please see the 'Console' section"
" in the XCode Organiser view")
开发者ID:fnava621,项目名称:trigger-weather,代码行数:34,代码来源:ios_tasks.py
示例4: run_iphone_simulator
def run_iphone_simulator(self):
if not sys.platform.startswith('darwin'):
raise IOSError("iOS Simulator is only available on OS X, please change the iOS run settings in your local config.")
possible_app_location = '{0}/ios/simulator-*/'.format(self.path_to_ios_build)
LOG.debug('Looking for apps at {0}'.format(possible_app_location))
possible_apps = glob(possible_app_location)
if not possible_apps:
raise IOSError("Couldn't find iOS app to run it in the simulator")
path_to_app = possible_apps[0]
LOG.debug('trying to run app %s' % path_to_app)
if path.exists(SIMULATOR_IN_42):
LOG.debug("Detected XCode version 4.2 or older")
ios_sim_binary = "ios-sim-xc4.2"
elif path.exists(SIMULATOR_IN_43):
LOG.debug("Detected XCode version 4.3 or newer")
ios_sim_binary = "ios-sim-xc4.3"
else:
raise IOSError("Couldn't find iOS simulator in {old} or {new}".format(
old=SIMULATOR_IN_42,
new=SIMULATOR_IN_43,
))
logfile = tempfile.mkstemp()[1]
ios_sim_proc = subprocess.Popen([path.join(self._lib_path(), ios_sim_binary), "launch", path_to_app, '--stderr', logfile])
LOG.info('Showing log output:')
try:
run_shell("tail", "-f", logfile, fail_silently=False, command_log_level=logging.INFO, check_for_interrupt=True)
finally:
lib.progressive_kill(ios_sim_proc.pid)
os.remove(logfile)
开发者ID:nadu,项目名称:Creo,代码行数:33,代码来源:ios_tasks.py
示例5: _node
def _node(build, *args, **kw):
node = "node"
if not utils.which(node):
raise WebError("couldn't find {tool} on your PATH or in likely "
"locations - is it installed?".format(tool=node))
kw['check_for_interrupt'] = True
run_shell(node, *args, **kw)
开发者ID:Lewiswight,项目名称:MeshifyMobile,代码行数:8,代码来源:web_tasks.py
示例6: _follow_log
def _follow_log(path_info, chosen_device):
LOG.info('Clearing android log')
args = [path_info.adb, '-s', chosen_device, 'logcat', '-c']
run_shell(*args, command_log_level=logging.INFO)
LOG.info('Showing android log')
run_shell(path_info.adb, '-s', chosen_device, 'logcat', 'WebCore:D', 'Forge:D', '*:s', command_log_level=logging.INFO, check_for_interrupt=True)
开发者ID:JordanHamel,项目名称:clother,代码行数:9,代码来源:android_tasks.py
示例7: run_idevice
def run_idevice(self, build, device, provisioning_profile, certificate=None, certificate_path=None, certificate_password=None):
possible_app_location = '{0}/ios/device-*/'.format(self.path_to_ios_build)
LOG.debug('Looking for apps at {0}'.format(possible_app_location))
possible_apps = glob(possible_app_location)
if not possible_apps:
raise IOSError("Couldn't find iOS app to run on a device")
path_to_app = possible_apps[0]
LOG.debug("Signing {app}".format(app=path_to_app))
plist_str = self._grab_plist_from_binary_mess(build, provisioning_profile)
plist_dict = self._parse_plist(plist_str)
self.check_plist_dict(plist_dict, self.path_to_ios_build)
LOG.info("Plist OK")
if sys.platform.startswith('darwin'):
with temp_file() as temp_file_path:
self._create_entitlements_file(build, plist_dict, temp_file_path)
self._sign_app(build=build,
provisioning_profile=provisioning_profile,
certificate=certificate,
entitlements_file=temp_file_path,
)
fruitstrap = [ensure_lib_available(build, 'fruitstrap'), '-d', '-g', ensure_lib_available(build, 'gdb-arm-apple-darwin'), '-t', '10', '-b', path_to_app]
if device and device.lower() != 'device':
# pacific device given
fruitstrap.append('-i')
fruitstrap.append(device)
LOG.info('Installing app on device {device}: is it connected?'.format(device=device))
else:
LOG.info('Installing app on device: is it connected?')
run_shell(*fruitstrap, fail_silently=False, command_log_level=logging.INFO, filter=lambda x: not x.startswith("warning"), check_for_interrupt=True)
elif sys.platform.startswith('win'):
with temp_file() as ipa_path:
self.create_ipa_from_app(
build=build,
provisioning_profile=provisioning_profile,
output_path_for_ipa=ipa_path,
certificate_path=certificate_path,
certificate_password=certificate_password,
)
win_ios_install = [ensure_lib_available(build, 'win-ios-install.exe')]
if device and device.lower() != 'device':
# pacific device given
win_ios_install.append(device)
LOG.info('Installing app on device {device}: is it connected?'.format(device=device))
else:
LOG.info('Installing app on device: is it connected?')
win_ios_install.append(ipa_path)
win_ios_install.append(_generate_package_name(build))
run_shell(*win_ios_install, fail_silently=False, command_log_level=logging.INFO, check_for_interrupt=True)
开发者ID:mfine15,项目名称:just-the-best,代码行数:57,代码来源:ios_tasks.py
示例8: run_firefox
def run_firefox(build, build_type_dir):
python = sys.executable
lib_path = path.abspath(
path.join(__file__, path.pardir, path.pardir, 'lib')
)
try:
run_shell(python, path.join(lib_path, 'run-firefox.zip'), command_log_level=logging.INFO)
finally:
_clean_firefox(build_type_dir)
开发者ID:mhuebert,项目名称:Forge-Bootstrap,代码行数:9,代码来源:firefox_tasks.py
示例9: ln
def ln(src, dst):
src = gen_src(src)
dstTrue = path.join(dst, path.basename(src))
if path.exists(dstTrue):
if path.samefile(src, dstTrue):
return
else:
raise ConflictException(dstTrue)
run_shell("mkdir -p {}", dst)
run_shell("ln -s {} {}", src, dst)
开发者ID:codewdy,项目名称:gen-env,代码行数:10,代码来源:ln.py
示例10: _open_url
def _open_url(url):
'''Attempt to open the provided URL in the default browser'''
if sys.platform.startswith('darwin'):
run_shell('open', url, fail_silently=True)
elif sys.platform.startswith('win'):
# 'start' seems to need shell=True to be found (probably a builtin)
cmd = subprocess.list2cmdline(['start', url])
subprocess.call(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
elif sys.platform.startswith('linux'):
run_shell('xdg-open', url, fail_silently=True)
开发者ID:Lewiswight,项目名称:MeshifyMobile,代码行数:10,代码来源:web_tasks.py
示例11: _open_url
def _open_url(url):
"""Attempt to open the provided URL in the default browser"""
if sys.platform.startswith("darwin"):
run_shell("open", url, fail_silently=True)
elif sys.platform.startswith("win"):
# 'start' seems to need shell=True to be found (probably a builtin)
cmd = subprocess.list2cmdline(["start", url])
subprocess.call(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
elif sys.platform.startswith("linux"):
run_shell("xdg-open", url, fail_silently=True)
开发者ID:JordanHamel,项目名称:clother,代码行数:10,代码来源:web_tasks.py
示例12: _npm
def _npm(*args, **kw):
if sys.platform.startswith("win"):
npm = "npm.cmd"
else:
npm = "npm"
try:
run_shell(npm, *args, **kw)
except OSError as e:
if e.errno == errno.ENOENT:
raise WebError("failed to run npm: do you have Node.js installed and on your path?")
开发者ID:tegument,项目名称:WRENCH_IO_MOBILE,代码行数:11,代码来源:web_tasks.py
示例13: _follow_log
def _follow_log(path_info, chosen_device):
LOG.info('Clearing android log')
args = [path_info.adb, '-s', chosen_device, 'logcat', '-c']
proc = Popen(args, stdout=sys.stdout, stderr=sys.stderr)
proc.wait()
LOG.info('Showing android log')
# XXX: need to ensure we're out of the development folder before running
# logcat, otherwise Trigger Toolkit seems to inherit some kind of lock on
# the android folder :(
os.chdir(path.abspath('/'))
run_shell(path_info.adb, '-s', chosen_device, 'logcat', 'WebCore:D', 'Forge:D', '*:s', command_log_level=logging.INFO)
开发者ID:tegument,项目名称:WRENCH_IO_MOBILE,代码行数:13,代码来源:android_tasks.py
示例14: _npm
def _npm(build, *args, **kw):
if sys.platform.startswith("win"):
npm = "npm.cmd"
else:
npm = "npm"
if not utils.which(npm):
raise WebError("""Couldn't find {tool} on your PATH or in likely locations - is it installed?
You can use the 'node_path' setting in your local configuration to set a custom install directory"""
.format(tool=npm))
kw['check_for_interrupt'] = True
run_shell(npm, *args, **kw)
开发者ID:Lewiswight,项目名称:MeshifyMobile,代码行数:13,代码来源:web_tasks.py
示例15: _create_apk_with_aapt
def _create_apk_with_aapt(path_info):
LOG.info('Creating APK with aapt')
lib_path = path.join(
os.getcwd(), path.pardir, path.pardir,
".template", "lib",
)
apk_name = 'app.apk'
run_shell(path_info.aapt, 'p', '-F', apk_name, '-S', 'res', '-M', 'AndroidManifest.xml', '-I', path.join(lib_path, 'android-platform.apk'), '-A', 'assets', '-f', 'output', command_log_level=logging.DEBUG)
return apk_name
开发者ID:tegument,项目名称:WRENCH_IO_MOBILE,代码行数:13,代码来源:android_tasks.py
示例16: _kill_adb
def _kill_adb():
if sys.platform.startswith("win"):
run_shell("taskkill", "/T", "/IM", "adb.exe", fail_silently=True)
run_shell("taskkill", "/T", "/F", "/IM", "adb.exe", fail_silently=True)
else:
run_shell("killall", "adb", fail_silently=True)
run_shell("killall", "-9", "adb", fail_silently=True)
开发者ID:nadu,项目名称:Creo,代码行数:7,代码来源:android_tasks.py
示例17: _kill_adb
def _kill_adb():
if sys.platform.startswith('win'):
run_shell('taskkill', '/T', '/IM', 'adb.exe', fail_silently=True)
run_shell('taskkill', '/T', '/F', '/IM', 'adb.exe', fail_silently=True)
else:
run_shell('killall', 'adb', fail_silently=True)
run_shell('killall', '-9', 'adb', fail_silently=True)
开发者ID:JordanHamel,项目名称:clother,代码行数:7,代码来源:android_tasks.py
示例18: _create_apk_with_aapt
def _create_apk_with_aapt(build, out_apk_name, path_info, package_name, lib_path, dev_dir):
LOG.info('Creating APK with aapt')
run_shell(path_info.aapt,
'p', # create APK package
'-F', out_apk_name, # output name
'-S', path.join(dev_dir, 'res'), # uncompressed resources folder
'-M', path.join(dev_dir, 'AndroidManifest.xml'), # uncompressed xml manifest
'-I', ensure_lib_available(build, 'android-platform.apk'), # Android platform to "compile" resources against
'-A', path.join(dev_dir, 'assets'), # Assets folder to include
'-0', '', # Don't compress any assets - Important for content provider access to assets
'--rename-manifest-package', package_name, # Package name
'-f', # Force overwrite
path.join(dev_dir, 'bin'), # Location of raw files (app binary)
command_log_level=logging.DEBUG)
开发者ID:JordanHamel,项目名称:clother,代码行数:15,代码来源:android_tasks.py
示例19: __find
def __find(self, title):
self.pattern = messages.Entry(title, 'Type search string', '', True, False).run()
if self.pattern is None or self.pattern == '':
return -1
filename = os.path.abspath(self.fc.filename)
mode = (self.mode==MODE_TEXT) and 'n' or 'b'
try:
cmd = '%s -i%c \"%s\" \"%s\"' % (sysprogs['grep'], mode,
self.pattern, filename)
st, buf = run_shell(encode(cmd), path=u'.', return_output=True)
except OSError:
self.show()
messages.error('Find error: Can\'t open file')
return -1
if st == -1:
self.show()
messages.error('Find error\n' + buf)
self.matches = []
return -1
else:
try:
self.matches = [int(l.split(':')[0]) for l in buf.split('\n') if l]
except (ValueError, TypeError):
self.matches = []
return 0
开发者ID:langner,项目名称:lfm,代码行数:25,代码来源:pyview.py
示例20: _git
def _git(cmd, *args, **kwargs):
"""Runs a git command and scrapes the output for common problems, so that we can try
to advise the user about them
e.g. _git('push', '--all')
"""
try:
output = run_shell('git', cmd, *args, **kwargs)
except OSError as e:
if e.errno == errno.ENOENT:
# TODO: download portable copy of git/locate git?
raise WebError("Can't run git commands - you need to install git and make sure it's in your PATH")
except ShellError as e:
def _key_problem(output):
lines = output.split('\n')
if len(lines) > 0:
first = lines[0]
return first.startswith('Permission denied (publickey)')
if _key_problem(e.output):
# TODO: prompt user with choice to use existing .pub in ~/.ssh
# or create new keypair and submit to heroku
raise WebError('Failed to access remote git repo, you need to set up key based access')
raise WebError('Problem running git {cmd}:\n {output}'.format(cmd=cmd, output=e.output))
return output
开发者ID:Lewiswight,项目名称:MeshifyMobile,代码行数:27,代码来源:web_tasks.py
注:本文中的utils.run_shell函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论