本文整理汇总了Python中shell.shell函数的典型用法代码示例。如果您正苦于以下问题:Python shell函数的具体用法?Python shell怎么用?Python shell使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shell函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: link_file_in_dir_as
def link_file_in_dir_as(hook_name, dir_path, link_name):
hook_path = BROC_HOOKS_PATHS[hook_name]
link_path = dir_path + '/' + link_name
ln = shell('ln -s {0} {1}'.format(hook_path, link_path))
chmod = shell('chmod +x {0}'.format(hook_path))
return ln.code
开发者ID:channikhabra,项目名称:broc,代码行数:7,代码来源:__init__.py
示例2: bundle
def bundle(cmd):
""" Runs bundle
Usage:
bundle('install')
bundle('exec rails s')
bundle('rake db:create RAILS_ENV=production')
Arguments:
cmd: Command to run can be string or list
Returns:
Will halt on error
"""
sh = shell('which bundler')
if sh.code > 0:
gem('install -N bundler')
hookenv.status_set('maintenance', 'Running Bundler')
os.chdir(ruby_dist_dir())
if not isinstance(cmd, str):
hookenv.log('{} must be a string'.format(cmd), 'error')
sys.exit(1)
shell_cmd = set_proxy("bundle {} -j{}".format(cmd, cpu_count()))
sh = shell(shell_cmd, record_output=False)
if sh.code > 0:
hookenv.status_set("blocked", "Ruby error: {}".format(sh.errors()))
hookenv.log("Ruby error: {}".format(sh.errors()))
sys.exit(1)
开发者ID:gnuoy,项目名称:juju-layer-ruby,代码行数:30,代码来源:rubylib.py
示例3: app_command
def app_command(options):
'''Execute all of the app specific apps'''
log('app command output %s' % options)
if options:
cmd = options[0]
args = options[1:]
if cmd=='edit':
shell('e %s' % app_path(APP_DIR+'/'+args[0]+'.py'))
elif cmd=='kill':
kill_server()
elif cmd=='list':
list_files()
elif cmd=='path':
print(app_path(args[0]))
elif cmd=='run':
run_server()
elif cmd=='search':
system('grep %s $p/*/*.py' % args[0])
elif cmd=='template':
shell('e %s' % app_path('templates/%s.html' % args[0]))
else:
print('No app command found, '+cmd)
app_help()
else:
print('No arguments given')
app_help()
开发者ID:Mark-Seaman,项目名称:Hammer,代码行数:34,代码来源:app.py
示例4: clean
def clean():
"""
"""
# TODO rewrite
shell.shell("rm ~/scr/*", shell=True)
return
开发者ID:jensengroup,项目名称:molcalc,代码行数:9,代码来源:gamess.py
示例5: write_pdf
def write_pdf(self, curdir, source, target, label, version):
print("Building PDF: {} - v{}".format(label, version,))
command = 'wkhtmltopdf {} --user-style-sheet {} {}'.format(
source,
self.user_css_path,
target,
)
with cd(curdir):
shell(command)
开发者ID:brunobord,项目名称:the-black-hack,代码行数:9,代码来源:pdf.py
示例6: check_dependency_epubcheck
def check_dependency_epubcheck():
try:
shell('epubcheck')
except OSError:
print warning("Warning: missing epubcheck. You'll be able to run"
" md2ebook but you won't be able to check your EPUB "
" integrity.")
print
return False
return True
开发者ID:brunobord,项目名称:md2ebook,代码行数:10,代码来源:checkers.py
示例7: publish
def publish(args):
if not os.path.isfile(os.path.expanduser('~/.pypirc')):
print(unindent("""
Missing ~/.pypirc file. Should look like:
-----------------------------------------
[distutils]
index-servers =
pypi
[pypi]
username:your_username
password:your_password
"""))
sys.exit(-1)
### Upload everything to server
shell("""
cd {build_dir}/pyqtgraph
# Uploading documentation.. (disabled; now hosted by readthedocs.io)
#rsync -rv doc/build/* pyqtgraph.org:/www/code/pyqtgraph/pyqtgraph/documentation/build/
# Uploading release packages to website
rsync -v {pkg_dir} pyqtgraph.org:/www/code/pyqtgraph/downloads/
# Push master to github
git push https://github.com/pyqtgraph/pyqtgraph master:master
# Push tag to github
git push https://github.com/pyqtgraph/pyqtgraph pyqtgraph-{version}
# Upload to pypi..
python setup.py sdist upload
""".format(**args.__dict__))
print(unindent("""
======== Upload complete. =========
Next steps to publish:
- update website
- mailing list announcement
- new conda recipe (http://conda.pydata.org/docs/build.html)
- contact deb maintainer (gianfranco costamagna)
- other package maintainers?
""").format(**args.__dict__))
开发者ID:grg2rsr,项目名称:ILTIS,代码行数:52,代码来源:pg-release.py
示例8: install_composer
def install_composer():
""" Installs composer
"""
hookenv.status_set('maintenance', 'Installing composer')
sh = shell("wget -q -O /usr/local/bin/composer "
"https://getcomposer.org/composer.phar")
if sh.code > 0:
hookenv.status_set(
'blocked',
'Unable to download composer: {}'.format(sh.errors()))
sys.exit(0)
shell("chmod +x /usr/local/bin/composer")
hookenv.status_set('active', 'ready')
开发者ID:battlemidget,项目名称:juju-layer-hhvm,代码行数:13,代码来源:hhvmlib.py
示例9: opusConvert
def opusConvert(self,infile,outfile,logq):
# As the new versions of opus support flac natively, I think that the best option is to
# use >0.1.7 by default, but support earlier ones without tagging.
startTime = time()
if self.version == None:
print "ERROR! Could not discover opus version, assuming version >= 0.1.7. THIS MAY NOT WORK!"
version = (9,9,9)
else: version=self.version
#If we are a release prior to 0.1.7, use non-tagging type conversion, with warning
if (version[0] == 0) and (version[1] <= 1) and (version[2] <= 6):
print "WARNING: Opus version prior to 0.1.7 detected, NO TAGGING SUPPORT"
decoder = flacdecode(infile)()
encoder = sp.Popen("%sopusenc %s - %s.opus 2> /tmp/opusLog" % (
opusencpath,
self.opts,
shell().parseEscapechars(outfile),
) ,
shell=True,
bufsize=8192,
stdin=sp.PIPE
).stdin
for line in decoder.readlines(): #while data exists in the decoders buffer
encoder.write(line) #write it to the encoders buffer
decoder.flush() #if there is any data left in the buffer, clear it
decoder.close() #somewhat self explanetory
encoder.flush() #as above
encoder.close()
logq.put([infile,outfile,"opus","SUCCESS_NOTAGGING",0, time() - startTime])
else:
#Later versions support direct conversion from flac->opus, so no need for the above.
rc = os.system("%sopusenc %s --quiet %s %s.opus" %
(
opusencpath,
self.opts,
shell().parseEscapechars(infile),
shell().parseEscapechars(outfile)
)
)
if ( rc != 0 ):
logq.put([infile,outfile,"opus","ERROR: error executing opusenc. Could not convert",rc, time() - startTime])
else:
logq.put([infile,outfile,"opus","SUCCESS",rc, time() - startTime])
开发者ID:Feadurn,项目名称:flac2all,代码行数:48,代码来源:opus.py
示例10: mp3convert
def mp3convert(self,infile,outfile,logq):
startTime = time()
inmetadata = flac().getflacmeta(infile)
try:
metastring = self.generateLameMeta(inmetadata)
except(UnboundLocalError):
metastring = "" #If we do not get meta information. leave blank
#rb stands for read-binary, which is what we are doing, with a 1024 byte buffer
decoder = flacdecode(infile)()
if decoder == None:
logq.put([infile,outfile,"mp3","ERROR: Could not open flac file for decoding.",-1, time() - startTime])
return None
#wb stands for write-binary
encoder = os.popen("%slame --silent %s - -o %s.mp3 %s" % (
lamepath,
self.opts,
shell().parseEscapechars(outfile),
metastring
) ,'wb',8192)
for line in decoder.readlines(): #while data exists in the decoders buffer
encoder.write(line) #write it to the encoders buffer
decoder.flush() #if there is any data left in the buffer, clear it
decoder.close() #somewhat self explanetory
encoder.flush() #as above
encoder.close()
logq.put([infile,outfile,"mp3","SUCCESS",0, time() - startTime])
开发者ID:DarrenRainey,项目名称:flac2all,代码行数:32,代码来源:mp3.py
示例11: mix
def mix(cmd):
""" Runs Mix
Usage:
mix('compile')
mix('test')
mix('run')
Arguments:
cmd: Command to run can be string or list
Returns:
Will halt on error
"""
status_set(
'maintenance',
'Running Mix build tool')
if not os.path.exists(elixir_dist_dir()):
os.makedirs(elixir_dist_dir())
os.chdir(elixir_dist_dir())
if not isinstance(cmd, str):
status_set('blocked', '{}: should be a string'.format(cmd))
sys.exit(0)
cmd = ("yes | mix {}".format(cmd))
sh = shell(cmd)
if sh.code > 0:
status_set("blocked", "Mix error: {}".format(sh.errors()))
sys.exit(0)
开发者ID:battlemidget,项目名称:juju-layer-elixir,代码行数:29,代码来源:elixir.py
示例12: composer
def composer(cmd):
""" Runs composer
Usage:
composer('install')
Arguments:
cmd: command to run with composer
Returns:
Halts on error
"""
hookenv.status_set(
'maintenance',
'Installing PHP dependencies in {}'.format(app_path()))
if not os.path.isdir(app_path()):
os.makedirs(app_path())
os.chdir(app_path())
if not isinstance(cmd, str):
hookenv.status_set('blocked', '{}: should be a string'.format(cmd))
sys.exit(0)
cmd = ("composer {}".format(cmd))
sh = shell(cmd)
if sh.code > 0:
hookenv.status_set("blocked", "Composer error: {}".format(sh.errors()))
sys.exit(0)
hookenv.status_set('active', 'ready')
开发者ID:battlemidget,项目名称:juju-layer-hhvm,代码行数:28,代码来源:hhvmlib.py
示例13: shell_command
def shell_command(testname, argv, must_fail=False, need_stdout=None, need_stderr=None, verbose=True):
errors = []
cmd = os.path.basename(argv[0])
command = shell(argv, verbose=True)
if must_fail:
if command.code == 0:
errors.append("%s: %s succeeded but should have failed?" % (testname, cmd))
else:
if command.code != 0:
errors.append("%s: %s failed (%d)?" % (testname, cmd, command.code))
if need_stdout:
command_stdout = command.output(raw=True)
if need_stdout not in command_stdout:
errors.append("%s: %s stdout does not contain %s" % (testname, cmd, need_stdout))
if need_stderr:
command_stderr = command.errors(raw=True)
if need_stderr not in command_stderr:
errors.append("%s: %s stderr does not contain %s" % (testname, cmd, need_stderr))
if errors:
print("---- ERRORS")
print("%s" % "\n".join(errors))
assert not errors, ("failing, errors: %d" % len(errors))
开发者ID:deo986,项目名称:ambassador,代码行数:30,代码来源:corner_case_test.py
示例14: AACPconvert
def AACPconvert(self,infile,outfile,logq):
inmetadata = flac().getflacmeta("\"" + infile + "\"")
tagcmd = "%sneroAacTag " % neroaacpath
try:
metastring = self.generateNeroTags(inmetadata)
except(UnboundLocalError):
metastring = ""
decoder = flacdecode(infile)()
#wb stands for write-binary
encoder = os.popen("%sneroAacEnc %s -if - -of %s.mp4 > /tmp/aacplusLog" % (
neroaacpath,
self.opts,
shell().parseEscapechars(outfile),
) ,'wb',8192)
for line in decoder.readlines(): #while data exists in the decoders buffer
encoder.write(line) #write it to the encoders buffer
decoder.flush() #if there is any data left in the buffer, clear it
decoder.close() #somewhat self explanetory
encoder.flush() #as above
encoder.close()
#Now as the final event, load up the tags
rc = os.system("%s \"%s.mp4\" %s" % (tagcmd, outfile, metastring))
# print "%s %s.mp4 %s" % (tagcmd, outfile, metastring)
if rc != 0:
logq.put([infile,outfile,"aacNero","WARNING: Could not tag AAC file",rc, time() - startTime])
else:
logq.put([infile,outfile,"aacNero","SUCCESS",0, time() - startTime])
开发者ID:Feadurn,项目名称:flac2all,代码行数:34,代码来源:aac.py
示例15: test_set_wp
def test_set_wp(self):
winner = self.col.draw()
self.backend.set_wallpaper(winner)
picture_uri = shell(
"/usr/bin/env gsettings get org.gnome.desktop.background \
picture-uri").output()[0]
self.assertEqual("'file://"+winner+"'", picture_uri)
开发者ID:phowat,项目名称:uowm,代码行数:7,代码来源:t.py
示例16: test_chaining
def test_chaining(self):
sh = Shell(has_input=True)
output = sh.run('cat -u').write('Hello, world!').output()
self.assertEqual(output, ['Hello, world!'])
output = shell('cat -u', has_input=True).write('Hello, world!').output()
self.assertEqual(output, ['Hello, world!'])
开发者ID:GiorgosPa,项目名称:shell,代码行数:7,代码来源:tests.py
示例17: npm
def npm(cmd):
""" Runs npm
This layer relies on the use of npm scripts defined in `package.json`,
see here https://docs.npmjs.com/misc/scripts for more information.
Usage:
npm('install')
npm('run build')
Arguments:
cmd: Command to run can be string or list
Returns:
Will halt on error
"""
status_set(
'maintenance',
'installing NPM dependencies for {}'.format(node_dist_dir()))
os.chdir(node_dist_dir())
if not isinstance(cmd, str):
status_set('blocked', '{}: should be a string'.format(cmd))
sys.exit(0)
cmd = ("npm {}".format(cmd))
sh = shell(cmd)
if sh.code > 0:
status_set("blocked", "NPM error: {}".format(sh.errors()))
sys.exit(0)
开发者ID:1stvamp,项目名称:juju-layer-node,代码行数:29,代码来源:nodejs.py
示例18: doc_send_text
def doc_send_text(args):
if args:
path = doc_path('send/me')
text = open(doc_path(args[0])).read()
open(path,'w').write(text+'\n')
print(shell('x send dispatch'))
else:
print('usage: doc send doc-path')
开发者ID:Mark-Seaman,项目名称:Hammer,代码行数:8,代码来源:doc.py
示例19: validate
def validate(url):
# curl -A "() { foo;};echo;/bin/cat /etc/passwd"
cmd = 'curl --connect-timeout 30 --max-time 60 -A "() { foo;};echo;/bin/cat /etc/passwd" %s' % (url)
oldcmd = 'curl --connect-timeout 30 --max-time 60 %s' % (url)
# print cmd
old_cont = shell(oldcmd).output(raw=True)
new_cont = shell(cmd).output(raw=True)
p = re.compile(r'.*?:.*?:\d*?:\d*?:.*?:.*?:.*')
'''
match only report from start 0, please use search
'''
m = p.search(new_cont)
if old_cont != new_cont and m:
return True
return False
开发者ID:vonnyfly,项目名称:shellshock_crawler,代码行数:17,代码来源:shellshock.py
示例20: install_app
def install_app():
""" Performs application installation
"""
hookenv.log('Installing Huginn', 'info')
# Configure NGINX vhost
nginxlib.configure_site('default', 'vhost.conf')
# Update application
huginnlib.download_archive()
shell("mkdir -p {}/{log,tmp/pids,tmp/sockets}".format(ruby_dist_dir()))
shell("cp {}/config/unicorn.rb.example "
"{}/config/unicorn.rb".format(ruby_dist_dir()))
bundle("install --deployment --without development test")
host.service_restart('nginx')
hookenv.status_set('active', 'Huginn is installed!')
开发者ID:cmars,项目名称:juju-charm-huginn,代码行数:18,代码来源:huginn.py
注:本文中的shell.shell函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论