Python sh.cp() Examples
The following are 5
code examples of sh.cp().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sh
, or try the search function
.
Example #1
Source File: creator.py From pyWinUSB with MIT License | 6 votes |
def copy_files(self): # Pliki do skopiowania files_to_copy = [] for root, dirnames, filenames in os.walk(self.source_mount): for file in filenames: files_to_copy.append(root + '/' + file) # Modyfikacja ścieżki oraz kopiowanie plików for index, file in enumerate(files_to_copy): match = re.search("pyWinUSB\/\w{40}\/source\/(.*\/)", file) dest_file = "/".join([ self.destination_mount , match.group(1) if match else "" ]) # Tworzenie i kopiowanie self.event_handler.on_progress(len(files_to_copy), index, file) sh.mkdir(dest_file, "-p") sh.cp(file, dest_file)
Example #2
Source File: helpers.py From rpl-attacks with GNU Affero General Public License v3.0 | 6 votes |
def copy_files(src_path, dst_path, *files): """ This helper function is aimed to copy files from a source path to a destination path. :param src_path: absolute or relative source path :param dst_path: absolute or relative destination path :param files: tuples with the following format (source_filename, destination_filename) """ src_path, dst_path = __expand_folders(src_path, dst_path) for file in files: if isinstance(file, tuple): src, dst = file elif isinstance(file, string_types): src, dst = 2 * [file] else: continue src, dst = join(src_path, src), join(dst_path, dst) if src != dst: sh.cp(src, dst)
Example #3
Source File: helpers.py From rpl-attacks with GNU Affero General Public License v3.0 | 6 votes |
def copy_folder(src_path, dst_path, includes=None): """ This helper function is aimed to copy an entire folder from a source path to a destination path. :param src_path: absolute or relative source path :param dst_path: absolute or relative destination path :param includes: list of sub-folders and files to be included from the src_path and to be copied into dst_path """ src_path, dst_path = __expand_folders(src_path, dst_path) if src_path != dst_path: if includes is not None: dst_path = join(dst_path, split(src_path)[-1]) if not exists(dst_path): makedirs(dst_path) for include in includes: head, tail = split(include) sub_dst_path = join(dst_path, head) if not exists(sub_dst_path): makedirs(sub_dst_path) sh.cp('-R', join(src_path, include), sub_dst_path) else: sh.cp('-R', src_path, dst_path)
Example #4
Source File: build.py From declaracad with GNU General Public License v3.0 | 5 votes |
def make_installer(cfg): """ """ print("Building installer...") build_dir = 'build/{name}-{version}'.format(**cfg) cfg.update({'build_dir': build_dir}) install_dir = '{build_dir}/usr/share/{name}'.format(**cfg) desktop_dir = '{build_dir}/usr/share/applications/'.format(**cfg) cfg.update({'install_dir': install_dir, 'desktop_dir': desktop_dir}) os.makedirs(build_dir) with cd(build_dir): os.makedirs('DEBIAN') #: Write control with open('DEBIAN/control', 'w') as f: f.write(CONTROL_TEMPLATE.format(**cfg)) #: Write os.makedirs(install_dir) print(sh.cp('-R', glob('build/exe.linux-x86_64-3.5/*'), install_dir)) #: Make a simlink to /usr/local/bin #print(sh.ln('-sf', '{install_dir}/{name}'.format(**cfg), # '{install_dir}/usr/local/bin/{name}'.format(**cfg))) #: Make a desktop icon /usr/share/applications os.makedirs(desktop_dir) print(sh.cp('{name}/res/declaracad.desktop'.format(**cfg), desktop_dir)) #: Prepare try: print(sh.chown('-R', 'root:root', build_dir)) except: pass #: Build it deb = sh.Command('dpkg-deb') print(deb('--build', build_dir))
Example #5
Source File: package_app.py From kivy-sdk-packager with MIT License | 5 votes |
def bootstrap(source_app, appname): # remove mypackage.app if it already exists print('Copy Kivy.app/source.app if it exists') if exists(appname): print('{} already exists removing it...'.format(appname)) sh.rm('-rf', appname) # check if Kivy.app exists and copy it if not exists(source_app): error("source app {} doesn't exist") print('copying {} to {}'.format(source_app, appname)) sh.cp('-a', source_app, appname)