本文整理汇总了Python中shutil.copy函数的典型用法代码示例。如果您正苦于以下问题:Python copy函数的具体用法?Python copy怎么用?Python copy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: prepareSession
def prepareSession(self):
"""Session test script is copied into the session directory
Test script is prepared as a python module to enable execution"""
shutil.copy(self.configFile, self.sessionDir)
#copy the test script into the session directory
shutil.copy(self.testScript, self.sessionDir)
#create an __init__ file here for us to import test script as <session_id>.script.<test_script>
session_init_file = os.path.join(self.sessionDir,'__init__.py')
utils.Utils.touch(session_init_file)
#Extract the name of the test script from input arguments
#first split the input into directory name and filename.extn
directoryName,fileName = os.path.split(self.testScript)
#now split filename and extension
moduleName = os.path.splitext(fileName)[0]
self.moduleName = moduleName
#the path would be <sessionDir>.script.testModule
script_import_path = "'"+str(self.sessionID)+'.script.'+moduleName+"'"
#make sure that the path is available in sys.path
sys.path.append(self.sessionDir)
_testModule = __import__(self.moduleName, globals(), locals(), [], -1)
self.testModule = _testModule.testData()
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:28,代码来源:executionCore.py
示例2: build_dist
def build_dist(self):
for sdir in self.staging_dirs:
if os.path.exists(sdir):
shutil.rmtree(sdir)
main_stage, ninja_stage = self.staging_dirs
modules = [os.path.splitext(os.path.split(x)[1])[0] for x in glob(os.path.join('mesonbuild/modules/*'))]
modules = ['mesonbuild.modules.' + x for x in modules if not x.startswith('_')]
modules += ['distutils.version']
modulestr = ','.join(modules)
python = shutil.which('python')
cxfreeze = os.path.join(os.path.dirname(python), "Scripts", "cxfreeze")
if not os.path.isfile(cxfreeze):
print("ERROR: This script requires cx_freeze module")
sys.exit(1)
subprocess.check_call([python,
cxfreeze,
'--target-dir',
main_stage,
'--include-modules',
modulestr,
'meson.py'])
if not os.path.exists(os.path.join(main_stage, 'meson.exe')):
sys.exit('Meson exe missing from staging dir.')
os.mkdir(ninja_stage)
shutil.copy(shutil.which('ninja'), ninja_stage)
if not os.path.exists(os.path.join(ninja_stage, 'ninja.exe')):
sys.exit('Ninja exe missing from staging dir.')
开发者ID:MathieuDuponchelle,项目名称:meson,代码行数:28,代码来源:createmsi.py
示例3: save_tmp_file
def save_tmp_file(fileobj, filename, ext):
if ext in IMAGES_EXT:
f = open("/tmp/" + filename + ext, 'wb')
shutil.copyfileobj(fileobj, f)
f.close()
helpers.resize_image(filename, ext)
if ext != '.jpg':
os.remove("/tmp/" + filename + ext)
return '.jpg'
if ext in ['.txt']:
f = open("/tmp/" + filename + ext, 'w')
shutil.copyfileobj(fileobj, f)
f.close()
return ext
if ext in ['.dcm', '.dicom']:
f = open("/tmp/" + filename + ext, 'w')
shutil.copyfileobj(fileobj, f)
f.close()
o = dir(main_helpers.dicom)
try:
main_helpers.dicom.saveDicomAsImage("/tmp/" + filename + ext,
"/tmp/" + filename + ext + ".thumbnail.jpg")
except:
shutil.copy(
os.path.join(settings.BASE_DIR, 'static/img/files/dicom.png'),
"/tmp/" + filename + ext + ".thumbnail.png"
)
return ext
f = open("/tmp/" + filename + ext, 'wb')
shutil.copyfileobj(fileobj, f)
f.close()
return ext
开发者ID:ganap,项目名称:so,代码行数:32,代码来源:google_cloud.py
示例4: gatk_realigner
def gatk_realigner(align_bam, ref_file, config, dbsnp=None, region=None,
out_file=None, deep_coverage=False):
"""Realign a BAM file around indels using GATK, returning sorted BAM.
"""
runner = broad.runner_from_config(config)
runner.run_fn("picard_index", align_bam)
runner.run_fn("picard_index_ref", ref_file)
if not os.path.exists("%s.fai" % ref_file):
pysam.faidx(ref_file)
if region:
align_bam = subset_bam_by_region(align_bam, region, out_file)
runner.run_fn("picard_index", align_bam)
if has_aligned_reads(align_bam, region):
variant_regions = config["algorithm"].get("variant_regions", None)
realign_target_file = gatk_realigner_targets(runner, align_bam,
ref_file, dbsnp, region,
out_file, deep_coverage,
variant_regions)
realign_bam = gatk_indel_realignment(runner, align_bam, ref_file,
realign_target_file, region,
out_file, deep_coverage)
# No longer required in recent GATK (> Feb 2011) -- now done on the fly
# realign_sort_bam = runner.run_fn("picard_fixmate", realign_bam)
return realign_bam
elif out_file:
shutil.copy(align_bam, out_file)
return out_file
else:
return align_bam
开发者ID:brentp,项目名称:bcbio-nextgen,代码行数:29,代码来源:realign.py
示例5: test_submit_with_images_report_and_thumbnail_matches_size
def test_submit_with_images_report_and_thumbnail_matches_size(self):
res = self.testapp.get("/")
form = res.forms["deform"]
form["serial"] = "ft789"
form["coefficient_0"] = "100"
form["coefficient_1"] = "101"
form["coefficient_2"] = "102"
form["coefficient_3"] = "103"
# Submitting via an actual browser strips the directory
# prefixes. Copy the files to temporary locations to exactly
# mimic this
image0_file = "resources/image0_defined.jpg"
image1_file = "resources/image1_defined.jpg"
shutil.copy(image0_file, "localimg0.jpg")
shutil.copy(image1_file, "localimg1.jpg")
# From: # http://stackoverflow.com/questions/3337736/\
# how-do-i-use-pylons-paste-webtest-with-multiple-\
# checkboxes-with-the-same-name
top_index = 0
bottom_index = 1
form.set("upload", Upload("localimg0.jpg"), top_index)
form.set("upload", Upload("localimg1.jpg"), bottom_index)
submit_res = form.submit("submit")
res = self.testapp.get("/view_pdf/ft789")
pdf_size = res.content_length
self.assertTrue(size_range(pdf_size, 106456, ok_range=40000))
res = self.testapp.get("/view_thumbnail/ft789")
png_size = res.content_length
self.assertTrue(size_range(png_size, 217477, ok_range=40000))
开发者ID:WasatchPhotonics,项目名称:CalibrationReport,代码行数:33,代码来源:tests.py
示例6: speak
def speak(voicedata, num):
print(str((newsnum+1) - num))
tts = gTTS(text=voicedata, lang='hi')
tts.save("E:\SandBox\Python\eradioJockey/temp/"+str(num+1)+".mp3")
shutil.copy('E:\SandBox\Python\eradioJockey\\assets\\alert.wav', 'temp')
newname = "ren E:\SandBox\Python\eradioJockey\\temp\\alert.wav"+' '+str(num)+'a'+'.wav'
os.system(newname)
开发者ID:SushantGautam,项目名称:eRadioJockey,代码行数:7,代码来源:eRadioJockey.py
示例7: upload_files
def upload_files(self, files):
"""
Upload files to Strava
"""
# connect to Strava API
client = Client(self.config.strava["access_token"])
for fn in files:
try:
upload = client.upload_activity(open(self.src_path + fn, "r"),
"fit")
activity = upload.wait(30, 10)
# if a file has been uploaded, copy it locally, as this ensures
# we don't attempt to re-upload the same activity in future
if activity:
shutil.copy(self.src_path + fn, self.dest_path + fn)
logging.debug("new file uploaded: {0}, {1} ({2})".format(
activity.name, activity.distance, fn))
except exc.ActivityUploadFailed as error:
print error
开发者ID:thegingerbloke,项目名称:pi-python-garmin-strava,代码行数:25,代码来源:uploader.py
示例8: symlink
def symlink(src, target):
""" symlink file if possible """
if 'win' in sys.platform:
shutil.copy(src, target)
os.chmod(target, stat.S_IRWXU)
else:
os.symlink(src, target)
开发者ID:dbarbier,项目名称:privot,代码行数:7,代码来源:core_dispatcher.py
示例9: build
def build(self):
"""Package up a nuget file based on the default build"""
if os.name != 'nt':
print("Skipping Native Nuget package build, as this needs to be run on Windows")
return
net45_build_dir = join(self.Build_NugetDir, 'build', 'net45')
os.makedirs(net45_build_dir, exist_ok=True)
print('Copying Files')
shutil.copy('./misc/GtkSharp.Native.targets', join(net45_build_dir, 'GtkSharp.' + self.arch + '.targets'))
# Copy dlls
dll_list = []
dll_list += self.Get_Dlls_Native_GTK()
dll_list += self.Get_Dlls_Native_GTK_Deps()
for item in dll_list:
src = join(self.MingwBinPath, item)
srclist = iglob(src)
for fname in srclist:
f_basename, f_extension = os.path.splitext(ntpath.basename(fname))
shutil.copy(fname, join(net45_build_dir, f_basename + '.dl_'))
开发者ID:openmedicus,项目名称:gtk-sharp,代码行数:25,代码来源:Gtk_Win32.py
示例10: run
def run(self):
dst = self.config.get_dst_folder()
cdv_dst = self.config.get_cordova_dst_folder(self.key)
if os.path.exists(cdv_dst):
names = os.listdir(cdv_dst)
for name in names:
if not name.startswith('.'):
name = os.path.join(cdv_dst, name)
if os.path.isfile(name):
os.remove(name)
else:
shutil.rmtree(name)
names = os.listdir(dst)
for name in names:
if not name.startswith('.'):
src = os.path.join(dst, name)
copy = os.path.join(cdv_dst, name)
if os.path.isfile(src):
shutil.copy(src, copy)
else:
shutil.copytree(src, copy, ignore=shutil.ignore_patterns('.*'))
for r, d, f in os.walk(cdv_dst):
for files in filter(lambda x: x.endswith('.html'), f):
p = os.path.join(r, files)
self.replace_cordova_tag(p)
self.copy_icons(dst)
self.copy_splash(dst)
开发者ID:abdelhai,项目名称:lavaca,代码行数:27,代码来源:build.py
示例11: copy_file
def copy_file(input_file, output_dir):
name, ext = os.path.basename(input_file).rsplit(".",1)
output_file = os.path.join(output_dir, os.path.basename(input_file))
shutil.copy(input_file, output_file)
return output_file
开发者ID:matteomenapace,项目名称:lesson_format,代码行数:7,代码来源:build.py
示例12: main
def main():
my_config = get_config()
new_synapse_config = generate_configuration(
my_config, get_zookeeper_topology(), get_all_namespaces()
)
with tempfile.NamedTemporaryFile() as tmp_file:
new_synapse_config_path = tmp_file.name
with open(new_synapse_config_path, 'w') as fp:
json.dump(new_synapse_config, fp, sort_keys=True, indent=4, separators=(',', ': '))
# Match permissions that puppet expects
os.chmod(new_synapse_config_path, 0644)
# Restart synapse if the config files differ
should_restart = not filecmp.cmp(new_synapse_config_path, my_config['config_file'])
# Always swap new config file into place. Our monitoring system
# checks the config['config_file'] file age to ensure that it is
# continually being updated.
shutil.copy(new_synapse_config_path, my_config['config_file'])
if should_restart:
subprocess.check_call(SYNAPSE_RESTART_COMMAND)
开发者ID:oholiab,项目名称:synapse-tools,代码行数:25,代码来源:configure_synapse.py
示例13: _add_vba_project
def _add_vba_project(self):
# Copy in a vbaProject.bin file.
vba_project = self.workbook.vba_project
vba_is_stream = self.workbook.vba_is_stream
if not vba_project:
return
xml_vba_name = 'xl/vbaProject.bin'
if not self.in_memory:
# In file mode we just write or copy the VBA file.
os_filename = self._filename(xml_vba_name)
if vba_is_stream:
# The data is in a byte stream. Write it to the target.
os_file = open(os_filename, mode='wb')
os_file.write(vba_project.getvalue())
os_file.close()
else:
copy(vba_project, os_filename)
else:
# For in-memory mode we read the vba into a stream.
if vba_is_stream:
# The data is already in a byte stream.
os_filename = vba_project
else:
vba_file = open(vba_project, mode='rb')
vba_data = vba_file.read()
os_filename = BytesIO(vba_data)
vba_file.close()
self.filenames.append((os_filename, xml_vba_name, True))
开发者ID:RudderlessK,项目名称:iOS-private-api-checker,代码行数:34,代码来源:packager.py
示例14: save_config_file
def save_config_file(self, ui_info):
dialog = FileDialog(action="save as", default_filename="config.ini")
dialog.open()
if dialog.return_code == OK:
save_config(self.pipeline, ui_info.ui.context["object"].project_info.config_file)
if dialog.path != ui_info.ui.context["object"].project_info.config_file:
shutil.copy(ui_info.ui.context["object"].project_info.config_file, dialog.path)
开发者ID:JohnGriffiths,项目名称:cmp_nipype,代码行数:7,代码来源:project.py
示例15: move_mat_file
def move_mat_file(self):
"""TODO
"""
output_dir = self._paths()[1]
source = os.path.join(os.getcwd(), 'Model_internal.mat')
destination = os.path.join(output_dir, 'result.mat')
copy(source, destination)
开发者ID:kdavies4,项目名称:ModelicaRes,代码行数:7,代码来源:simulators.py
示例16: load_config_file
def load_config_file(self, ui_info):
dialog = FileDialog(action="open", wildcard="*.ini")
dialog.open()
if dialog.return_code == OK:
if dialog.path != ui_info.ui.context["object"].project_info.config_file:
shutil.copy(dialog.path, ui_info.ui.context["object"].project_info.config_file)
load_config(self.pipeline, ui_info.ui.context["object"].project_info.config_file)
开发者ID:JohnGriffiths,项目名称:cmp_nipype,代码行数:7,代码来源:project.py
示例17: install
def install(self, force=False):
jujuresources.install(self.resources['oozie'],
destination=self.dist_config.path('oozie'),
skip_top_level=True)
self.dist_config.add_users()
self.dist_config.add_dirs()
self.dist_config.add_packages()
# ExtJS v2.2 should go under self.dist_config.path('ext22')
jujuresources.fetch('ext22')
src = jujuresources.resource_path('ext22')
dest = self.dist_config.path('ext22')
shutil.copy(src, dest)
# self.dist_config.path('ext22') should also contain all files under
# self.dist_config.path('oozie') / 'libtools'
src = self.dist_config.path('oozie') / 'libtools'
src_files = os.listdir(src)
for file_name in src_files:
full_file_name = os.path.join(src, file_name)
if (os.path.isfile(full_file_name)):
shutil.copy(full_file_name, dest)
self.setup_oozie_config()
self.configure_oozie_hdfs()
self.set_oozie_env()
self.build_oozie_sharelib()
self.build_oozie_war_file()
self.build_oozie_db()
开发者ID:ktsakalozos,项目名称:layer-apache-oozie,代码行数:29,代码来源:oozie.py
示例18: path_reference_copy
def path_reference_copy(copy_set, report=print):
"""
Execute copying files of path_reference
:arg copy_set: set of (from, to) pairs to copy.
:type copy_set: set
:arg report: function used for reporting warnings, takes a string argument.
:type report: function
"""
if not copy_set:
return
import os
import shutil
for file_src, file_dst in copy_set:
if not os.path.exists(file_src):
report("missing %r, not copying" % file_src)
elif os.path.exists(file_dst) and os.path.samefile(file_src, file_dst):
pass
else:
dir_to = os.path.dirname(file_dst)
if not os.path.isdir(dir_to):
os.makedirs(dir_to)
shutil.copy(file_src, file_dst)
开发者ID:danielmarg,项目名称:blender-main,代码行数:27,代码来源:io_utils.py
示例19: copy_merge_file_to_repo
def copy_merge_file_to_repo(a_target_file_path):
# Get check sum for new merged file
check_sum_name = check_sum("/".join(a_target_file_path))
# Variable for the name of the project tree.
project_tree_name = g_NAME_OF_PT_PATH.split("/")[-1]
# Array of the path for the repo split by a "/"
a_temp_repo_path = g_NAME_OF_REPO.split("/")
# variable to check for the project tree name.
pt_directory_check = False
# 0 ... length of the a_target_file_path
for i in range (len(a_target_file_path)):
# checks to see if the element for a_target_file_path at index i equals the project tree name.
if(a_target_file_path[i] == project_tree_name):
# Sets pt_directory_check to be true.
pt_directory_check = True
# checks to see if pt_directory_check has been set.
if(pt_directory_check):
# append the element for a_target_file_path at index i to the a_temp_repo_path
a_temp_repo_path.append(a_target_file_path[i])
# appends the check sum name to the a_temp_repo_path
a_temp_repo_path.append(check_sum_name)
# copies the merged file to our repo
shutil.copy("/".join(a_target_file_path), "/".join(a_temp_repo_path))
开发者ID:kuminin,项目名称:VCS-Project,代码行数:33,代码来源:merge.py
示例20: _handle_files
def _handle_files(src, dest, root, files, filter_fun, quiet):
""" Helper function used by install()
"""
installed = list()
rel_root = os.path.relpath(root, src)
if rel_root == ".":
rel_root = ""
new_root = os.path.join(dest, rel_root)
for f in files:
if not filter_fun(os.path.join(rel_root, f)):
continue
fsrc = os.path.join(root, f)
fdest = os.path.join(new_root, f)
if os.path.islink(fsrc):
mkdir(new_root, recursive=True)
_copy_link(fsrc, fdest, quiet)
rel_path = os.path.join(rel_root, f)
installed.append(rel_path)
else:
if os.path.lexists(fdest) and os.path.isdir(fdest):
raise Exception("Expecting a file but found a directory: %s" % fdest)
if sys.stdout.isatty() and not quiet:
print "-- Installing %s" % fdest
mkdir(new_root, recursive=True)
# We do not want to fail if dest exists but is read only
# (following what `install` does, but not what `cp` does)
rm(fdest)
shutil.copy(fsrc, fdest)
return installed
开发者ID:Giessen,项目名称:qibuild,代码行数:31,代码来源:sh.py
注:本文中的shutil.copy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论