本文整理汇总了Python中sh.cp函数的典型用法代码示例。如果您正苦于以下问题:Python cp函数的具体用法?Python cp怎么用?Python cp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: compile
def compile( self, source_dir, build_dir, install_dir ):
package_source_dir = os.path.join( source_dir, self.dirname )
assert( os.path.exists( package_source_dir ) )
package_build_dir = os.path.join( build_dir, self.dirname )
sh.cd( os.path.join( package_source_dir, 'scripts/Resources' ) )
sh.sh( './copyresources.sh' )
# the install target doesn't copy the stuff that copyresources.sh puts in place
sh.cp( '-v', os.path.join( package_source_dir, 'bin/Release/Readme.txt' ), os.path.join( install_dir, 'Readme.meshy.txt' ) )
sh.cp( '-v', '-r', os.path.join( package_source_dir, 'bin/Release_Linux/Resources/' ), install_dir )
sh.mkdir( '-p', package_build_dir )
sh.cd( package_build_dir )
if ( platform.system() == 'Darwin' ):
sh.cmake(
'-G', 'Xcode',
'-D', 'CMAKE_INSTALL_PREFIX=%s' % install_dir,
'-D', 'CMAKE_MODULE_PATH=%s' % os.path.join( install_dir, 'CMake' ),
package_source_dir,
_out = sys.stdout )
sh.xcodebuild( '-configuration', 'Release', _out = sys.stdout )
else:
sh.cmake(
'-D', 'CMAKE_INSTALL_PREFIX=%s' % install_dir,
'-D', 'CMAKE_MODULE_PATH=%s' % os.path.join( install_dir, 'lib/OGRE/cmake' ),
package_source_dir,
_out = sys.stdout )
sh.make( '-j4', 'VERBOSE=1', _out = sys.stdout )
sh.make.install( _out = sys.stdout )
开发者ID:TTimo,项目名称:es_build,代码行数:29,代码来源:20_ogremeshy.py
示例2: copy_assets
def copy_assets():
"""copy assets for static serving"""
proj()
print(". copying assets ...")
copy_patterns = {
"dist": ["./static/lib/jquery-1.8.3.min.js"] +
sh.glob("./static/config/*.json") +
sh.glob("./static/fragile-min.*"),
"dist/font": sh.glob("./static/lib/awesome/font/*"),
"dist/svg": sh.glob("./static/svg/*.svg"),
"dist/img": sh.glob("./static/img/*.*") or [],
"dist/docs/assets": sh.glob("./docs/assets/*.*") or [],
}
for dst, copy_files in copy_patterns.items():
if not os.path.exists(dst):
sh.mkdir("-p", dst)
for c_file in copy_files:
print "... copying", c_file, dst
sh.cp("-r", c_file, dst)
wa_cache = "./dist/.webassets-cache"
if os.path.exists(wa_cache):
sh.rm("-r", wa_cache)
开发者ID:bollwyvl,项目名称:fragile,代码行数:30,代码来源:fabfile.py
示例3: handle_task
def handle_task(task, dotfiles_dir):
click.echo('handling task: {}'.format(task))
if 'src' not in task:
click.echo("you must define at least a 'src' in each task")
raise click.Abort
source = os.path.expanduser(task['src'])
if not os.path.exists(source):
click.echo('file not found: {}'.format(source))
raise click.Abort
_, filename = os.path.split(source)
subdir = task['subdir'].rstrip('/') if 'subdir' in task else '.'
target = os.path.abspath(os.path.join(dotfiles_dir, subdir, filename))
# make sure the target directory exists, e.g. .dotfiles/bash/
target_path, _ = os.path.split(target)
mkdir('-p', target_path)
# copy the files
msg_fmt = 'copying {}: from [{}] to [{}]'
if os.path.isdir(source):
click.echo(msg_fmt.format('dir', source, target))
cp("-r", os.path.join(source, "."), target)
else:
click.echo(msg_fmt.format('file', source, target))
cp(source, target)
开发者ID:isms,项目名称:dotfiles-copier,代码行数:28,代码来源:dotfiles.py
示例4: setup
def setup(self, portno=8000):
self.load_port()
# print self.port_used
some_no = portno
conf_file = self.real_proj_d + '.conf'
while 1:
if some_no in self.port_used:
some_no += 1
else:
print 'the port allocated is: ', some_no
break
conf = open(conf_file, 'w')
conf.write('server {\n')
conf.write(' listen' + ' ' + unicode(some_no) + ';\n')
conf.write(' access_log /var/log/nginx/access.log;\n')
conf.write(' error_log /var/log/nginx/error.log;\n')
conf.write(' location / {\n')
conf.write(' uwsgi_pass unix:' + self.load_sock() + ';\n')
conf.write(' include uwsgi_params;\n')
conf.write(' }\n')
conf.write(' location ~ ^/static/ {\n')
conf.write(' root ' + self.load_static() + ';\n')
conf.write(' }\n')
conf.write('}')
conf.close()
cp(conf_file, '/etc/nginx/conf.d')
rm(conf_file)
system("service nginx restart")
return
开发者ID:yangwe1,项目名称:web-app-jiajiale,代码行数:33,代码来源:nginx_autoset.py
示例5: gen_private_key
def gen_private_key(domain, dirname, private_key_name):
''' Generate an openssl private key for the domain. '''
log('starting to generate private key')
# remove the following DEBUG lines by 2016-09-30
OPENSSL_CNF_FILENAME = os.path.join(dirname, 'openssl.cnf') #DEBUG
log('openssl.cnf exists: {}'.format(os.path.exists(OPENSSL_CNF_FILENAME))) #DEBUG
if os.path.exists(OPENSSL_CNF_FILENAME): #DEBUG
log('openssl.cnf filesize: {}'.format(os.stat(OPENSSL_CNF_FILENAME).st_size)) #DEBUG
private_key = os.path.join(dirname, 'private', private_key_name)
temp_private_key = '{}.tmp'.format(private_key)
kwargs = dict(_clilog=sh_out, _env=minimal_env(), _err=sh_err)
responses = [
('Enter pass phrase for {}:'.format(private_key), 'secret'),
('Verifying - Enter pass phrase for {}:'.format(private_key), 'secret'),
]
args = ['genrsa', '-aes256', '-out', private_key, '4096']
#args = ['genpkey', '-out', private_key, '-outform', 'PEM', '-aes256', '-algorithm', 'rsa', '-pkeyopt', 'rsa_keygen_bits:4096']
Responder(responses, 'openssl', *args, **kwargs)
assert os.path.exists(private_key), 'could not generate {}'.format(private_key)
sh.cp(private_key, temp_private_key)
responses = [('Enter pass phrase for {}:'.format(temp_private_key), 'secret')]
args = ['rsa', '-in', temp_private_key, '-out', private_key]
Responder(responses, 'openssl', *args, **kwargs)
os.remove(temp_private_key)
开发者ID:goodcrypto,项目名称:goodcrypto-libs,代码行数:30,代码来源:openssl.py
示例6: main
def main():
filename = 'my_config'
include_path = 'inc'
test_path = '/home/leha/personal/configen/configen/test/data'
test_files = glob(os.path.join(test_path, '*.json'))
#test_files = [os.path.join(test_path, 'test_schema.json')]
# copy header with helper test functions
sh.cp(os.path.join(test_path, 'serialization_tests.h'), '.')
# iterate over all files in test directory
for test_filename in test_files:
test_name = os.path.basename(test_filename).split('.')[0]
print('Test file: ' + test_name)
string_of_json = open(test_filename, 'r').read()
code = cg.convert_json(string_of_json, language='c++',
namespace=['config'], filename=filename,
include_path=include_path);
# write header, source and main
with open(os.path.join(include_path, filename + '.h'), 'w') as header:
header.write(code['header'])
with open(os.path.join(filename + '.cc'), 'w') as src:
src.write(code['source'])
main_filename = os.path.join(test_path, test_name + '.cc')
if os.path.exists(main_filename):
sh.cp(main_filename, 'main.cc')
else:
print('Default main')
with open('main.cc', 'w') as main_:
main_.write('\n'.join(DEFAULT_MAIN))
sh.make()
# check c code
run_main = sh.Command('./configen_test')
check_output(run_main())
开发者ID:alexey-naydenov,项目名称:configen,代码行数:32,代码来源:hand_test.py
示例7: prepare_file
def prepare_file(file_path, build_dir):
""" Move file into build folder before launching actual command (also compile coffeescript) """
logger.info("Preparing file {0}".format(file_path))
if file_path.endswith(".coffee"):
logger.info("Compiling coffee script")
f = open(file_path, 'r')
js_content = ""
coffee_content = ""
for line in f:
content_to_add = "{0}\n".format(line)
if line.strip().startswith("#import"):
js_content += content_to_add
else:
coffee_content += content_to_add
compiled_content = coffeescript.compile(coffee_content).split('\n')
js_content += '\n'.join(compiled_content[1:-2])
logger.debug(js_content)
file_name = path.splitext(path.basename(file_path))[0] + ".js"
build_path = path.join(build_dir, file_name)
f = open(build_path, 'w')
f.write(js_content)
return build_path
else:
logger.info("Copy JS file to build dir")
build_path = path.join(build_dir, path.basename(file_path))
sh.cp(file_path, build_path)
return build_path
开发者ID:Stupeflix,项目名称:fixxd,代码行数:31,代码来源:prepare.py
示例8: install_theme
def install_theme(name, profile=None, toolbar=False, jupyter=True):
""" copy given theme to theme.css and import css in custom.css """
from sh import cp # @UnresolvedImport (annotation for pydev)
source_path = glob('%s/%s.css' % (THEMES_PATH, name))[0]
paths = install_path(profile, jupyter)
for i, target_path in enumerate(paths):
# -- install theme
themecss_path = '%s/theme.css' % target_path
customcss_path = '%s/custom.css' % target_path
cp(source_path, themecss_path)
cp(source_path, customcss_path)
print "Installing %s at %s" % (name, target_path)
# -- check if theme import is already there, otherwise add it
with open(customcss_path, 'r+a') as customcss:
if not 'theme.css' in ' '.join(customcss.readlines()):
customcss.seek(0, os.SEEK_END)
customcss.write("\[email protected] url('theme.css');")
# -- enable toolbar if requested
if toolbar:
print "Enabling toolbar"
with open(themecss_path, 'rs+w') as themefile:
# TODO do some proper css rewrite
lines = (line.replace('div#maintoolbar', 'div#maintoolbar_active')
for line in themefile.readlines())
themefile.seek(0)
themefile.writelines(lines)
themefile.truncate()
else:
print "Toolbar is disabled. Set -T to enable"
开发者ID:flaxandteal,项目名称:jupyter-themes,代码行数:32,代码来源:__init__.py
示例9: gen_tmpfile
def gen_tmpfile(kb_size, query_size, query_class):
from sh import cp
from experiments_pl import convertToQuery
import re
queryfile = "./{0}-{1}-queries.txt".format(query_class, query_size)
tmpfile = make_tmpfile_name(kb_size, query_size, query_class)
cp(
"{0}.pl".format(kb_size),
tmpfile
)
r = []
with open(tmpfile, "a") as tmp:
with open(queryfile) as queries:
for i, query in enumerate(queries.readlines()):
rule = convertToQuery(query.strip())
args = ",".join([chr(65+n) for n,_ in enumerate(re.finditer('tweet',rule))])
pred_sig = make_pred_sig(args, i)
tmp.write("{0} :- {1}.\n".format(pred_sig, rule))
r.append({
'args': args,
'i': i,
'kb_size': kb_size,
'query_size': query_size,
'query_class': query_class,
'orig_query': query.strip()
})
return r
开发者ID:sana-malik,项目名称:dbproj,代码行数:31,代码来源:run_experiments.py
示例10: restore_file
def restore_file(filename):
''' Context manager restores a file to its previous state.
If the file exists on entry, it is backed up and restored.
If the file does not exist on entry and does exists on exit,
it is deleted.
'''
exists = os.path.exists(filename)
if exists:
# we just want the pathname, not the handle
# tiny chance of race if someone else gets the temp filename
handle, backup = tempfile.mkstemp()
os.close(handle)
sh.cp('--archive', filename, backup)
try:
yield
finally:
if os.path.exists(filename):
sh.rm(filename)
if exists:
# restore to original state
sh.mv(backup, filename)
开发者ID:goodcrypto,项目名称:goodcrypto-libs,代码行数:27,代码来源:fs.py
示例11: copy_statics
def copy_statics():
if path.isdir('output/static'):
sh.rm('-rf', 'output/static')
if not path.isdir(OUTPUT_DIR):
os.mkdir(OUTPUT_DIR)
sh.cp('-r', 'static', 'output/static')
开发者ID:event-able,项目名称:event-able,代码行数:8,代码来源:build.py
示例12: update_versions
def update_versions(config, dir_type, pkg_name, pkg_path, versions) :
pkg_dir = getattr(config,dir_type + "_dir")[pkg_name]
if pkg_dir.exists() :
for fname in os.listdir(+pkg_dir) :
fpath = pkg_dir[fname]
if fpath.isfile() :
cp(+fpath, +pkg_path)
versions[fname] = "md5={}".format(file_md5(+fpath))
开发者ID:dnene,项目名称:nestegg,代码行数:8,代码来源:main.py
示例13: copy
def copy(self, source, dest, dir=False):
s = self.mount_point + source
d = self.mount_point + dest
log.debug("Copying from '{0}' to '{1}'".format(s, d))
if dir:
cp('-r', s, d)
else:
cp(s, d)
time.sleep(1)
开发者ID:blueprintmrk,项目名称:usedav,代码行数:9,代码来源:test_dav.py
示例14: build_compiled_components
def build_compiled_components(self,arch):
super(CppCompiledComponentsPythonRecipe, self).build_compiled_components(arch)
# Copy libgnustl_shared.so
with current_directory(self.get_build_dir(arch.arch)):
sh.cp(
"{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/libgnustl_shared.so".format(ctx=self.ctx,arch=arch),
self.ctx.get_libs_dir(arch.arch)
)
开发者ID:llfkj,项目名称:python-for-android,代码行数:9,代码来源:recipe.py
示例15: copy_files
def copy_files(self):
""" Copy the LICENSE and CONTRIBUTING files to each folder repo """
files = ['LICENSE.md', 'CONTRIBUTING.md']
this_dir = sh.pwd().strip()
for _file in files:
sh.cp(
'{0}/templates/{1}'.format(this_dir, _file),
'{0}/'.format(self.book.textdir)
)
开发者ID:prpole,项目名称:git-lit,代码行数:9,代码来源:local.py
示例16: setup
def setup(self, git_repo_dir):
sh.mkdir("-p", join(self.btd, "var/log", self.pkg_name))
lib_base = join(self.btd, "usr/lib/api")
sh.mkdir("-p", lib_base)
for subdir in ["api", "models"]:
merge = lib_base.endswith(subdir)
sh.cp("-r", join(git_repo_dir, "src", subdir), lib_base, T=merge)
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:9,代码来源:make.py
示例17: copy_files
def copy_files(self):
""" Copy the LICENSE and CONTRIBUTING files to each folder repo """
# TODO: Add .gitattributes for line endings (and .gitignore?)
FILES = ['LICENSE.md', 'CONTRIBUTING.md']
this_dir = sh.pwd().strip()
for _file in FILES:
sh.cp(
'{0}/templates/{1}'.format(this_dir, _file),
'{0}/'.format(self.directory)
)
开发者ID:JohannGillium,项目名称:git-lit,代码行数:10,代码来源:local.py
示例18: backup_workloads
def backup_workloads():
"""Copy the workload folder to a temporary directory and returns its name.
Used to keep workloads from being clobbered by git checkout.
"""
temp_dir = mkdtemp()
sh.cp(os.path.join(IMPALA_HOME, "testdata", "workloads"),
temp_dir, R=True, _out=sys.stdout, _err=sys.stderr)
print "Backed up workloads to {0}".format(temp_dir)
return temp_dir
开发者ID:jbapple-cloudera,项目名称:incubator-impala,代码行数:10,代码来源:single_node_perf_run.py
示例19: pagesBranch
def pagesBranch():
try:
git.checkout("--orphan", "gh-pages")
git.rm("-r", "-f", "--ignore-unmatch", ".")
except: print("No files exist in the gh-pages branch")
try: sh.cp("-R", os.path.dirname(os.path.realpath(__file__)) + "/www/coming-soon/*", "./")
except: print("Template not found")
pushAll("Creating the first instance of the coming-soon site")
try: git.checkout("dev")
except: git.checkout("-b", "dev")
开发者ID:Alpha59,项目名称:GitHub,代码行数:10,代码来源:gitCommands.py
示例20: copy_to
def copy_to(self, src, dest, quiet=False):
"""
Copy from a location `src` on the local machine to a location
`dest` on the remote machine.
"""
if quiet:
return sh.cp('-r', src, dest)
else:
return sh.cp('-r', src, dest,
_out=pse, _err=pse, _tee=True)
开发者ID:reem,项目名称:pyvzutil,代码行数:10,代码来源:runners.py
注:本文中的sh.cp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论