How to use the sh.mv function in sh

To help you get started, we’ve selected a few sh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zmap / zmap / test / test_sharding.py View on Github external
def _runTest(self, shards, max_threads):
        for threads in range(1, max_threads + 1):
            for shard in range(0, shards):
                with sh.sudo:
                    outfile = output_file_name(shards, shard, threads)
                    zmap(p=80, T=threads, shards=shards, shard=shard, _out="tempfile")
                    parse("tempfile", _out=outfile)
                    dup_lines = int(wc(uniq(cat(outfile), "-d"), "-l"))
                    self.assertEqual(dup_lines, 0)
                    shard_file = shard_file_name(shards, threads)
                    if shard == 0:
                        cat(outfile, _out=shard_file)
                    else:
                        cat(shard_file, outfile, _out="tempfile")
                        mv("tempfile", shard_file)

        for threads in range(1, max_threads + 1):
            shard_file = shard_file_name(shards, threads)
            num_lines = int(wc(cat(shard_file), "-l"))
            self.assertEqual(num_lines, TestSharding.NUM_IPS)
            dup_lines = int(wc(uniq(sh.sort(cat(shard_file), "-n"), "-d"), "-l"))
            self.assertEqual(dup_lines, 0)
github lab11 / powerblade / sql / plot / plot_data.py View on Github external
# if(os.path.exists('datfile.pdf')):
	# 	os.remove('datfile.pdf')

	# Generate plot and convert to PDF
	gnuplot('datfile.plt')
	epstopdf('datfile.eps')

	# Show plot file
	img = subprocess.Popen(['open', 'datfile.pdf'])
	img.wait()

	# Remove temporary file
	os.remove('datfile.eps')

	# Move data to saveDir
	mv('datfile.dat', qu_saveDir)
	mv('datfile.plt', qu_saveDir)
	cp('datfile.pdf', qu_saveDir)




####################################################################
#
# This section is for the energy option
#
####################################################################

elif(config['type'] == 'energy'):

	if(query_powerblade == False):
		print("Error: At least one PowerBlade required for energy printing")
github lab11 / powerblade / sql / plot / plot_data.py View on Github external
breakdown(energyTop, labelstr, 'results')

	# Generate plot and convert to PDF
	gnuplot('results.plt')
	epstopdf('results.eps')

	# Show plot file
	img = subprocess.Popen(['open', 'results.pdf'])
	img.wait()

	# Remove temporary file
	os.remove('results.eps')

	# Move data to saveDir
	mv('results_pb.dat', qu_saveDir)
	mv('results_li.dat', qu_saveDir)
	mv('results.plt', qu_saveDir)
	mv('results.pdf', qu_saveDir)








	# aws_c.execute('select t1.category, min(t1.catSum) as minCat, ' \
	# 	'(select avg(catSum) from mr_cat_breakdown t2 where t1.category=t2.category and t2.catSumavg(t1.catSum)) as q3, ' \
	# 	'max(t1.catSum) as maxCat ' \
	# 	'from mr_cat_breakdown t1 ' \
github tuna / tunasync / tunasync / loglimit.py View on Github external
def after_exec(self, status=None, ctx={}, *args, **kwargs):
        log_file = ctx.get('log_file', None)
        log_link = ctx.get('log_link', None)
        if log_file == "/dev/null":
            return
        if status == "fail":
            log_file_save = log_file + ".fail"
            try:
                sh.mv(log_file, log_file_save)
            except:
                pass
            self.create_link(log_link, log_file_save)
github kivy / python-for-android / pythonforandroid / recipes / pygame_bootstrap_components / __init__.py View on Github external
def prebuild_arch(self, arch):
        super(PygameJNIComponentsRecipe, self).postbuild_arch(arch)

        info('Unpacking pygame bootstrap JNI dir components')
        with current_directory(self.get_build_container_dir(arch)):
            if exists('sdl'):
                info('sdl dir exists, so it looks like the JNI components' +
                     'are already unpacked. Skipping.')
                return
            for dirn in glob.glob(join(self.get_build_dir(arch),
                                       'pygame_bootstrap_jni', '*')):
                shprint(sh.mv, dirn, './')
        info('Unpacking was successful, deleting original container dir')
        shprint(sh.rm, '-rf', self.get_build_dir(arch))

        info('Applying jpeg assembler patch')
        ndk_15_plus_patch = join(self.get_recipe_dir(), 'jpeg-ndk15-plus.patch')
        shprint(sh.patch, '-t', '-d',
                join(self.get_build_container_dir(arch), 'jpeg'), '-p1',
                '-i', ndk_15_plus_patch, _tail=10)
github XiaoMi / mace / tools / converter.py View on Github external
"%s/%s.data" % (model_codegen_dir, model_name),
                        model_config[YAMLKeyword.runtime],
                        model_codegen_dir,
                        bool(model_config.get(YAMLKeyword.obfuscate, 1)))

        if model_graph_format == ModelFormat.file:
            sh.mv("-f",
                  '%s/file/%s.pb' % (model_codegen_dir, model_name),
                  model_output_dir)
            sh.mv("-f",
                  '%s/file/%s.data' % (model_codegen_dir, model_name),
                  model_output_dir)
            sh.rm("-rf", '%s/code' % model_codegen_dir)
        else:
            if not embed_model_data:
                sh.mv("-f",
                      '%s/file/%s.data' % (model_codegen_dir, model_name),
                      model_output_dir)
                sh.rm('%s/code/tensor_data.cc' % model_codegen_dir)

            sh.cp("-f", glob.glob("mace/codegen/models/*/code/*.h"),
                  model_header_dir)

        MaceLogger.summary(
            StringFormatter.block("Model %s converted" % model_name))

    if model_graph_format == ModelFormat.code:
        build_model_lib(configs, flags.address_sanitizer, flags.debug_mode)

    print_library_summary(configs)
github codelv / enaml-native / python-for-ios / recipes / python / __init__.py View on Github external
sh.rm("-rf", "wsgiref", "bsddb", "curses", "idlelib", "hotshot")
            sh.rm("-rf", sh.glob("lib*"))

            # now create the zip.
            print("Create a python27.zip")

            sh.rm("config/libpython2.7.a")
            sh.rm("config/python.o")
            sh.rm("config/config.c.in")
            sh.rm("config/makesetup")
            sh.rm("config/install-sh")
            sh.mv("config", "..")
            sh.mv("site-packages", "..")
            sh.zip("-r", "../python27.zip", sh.glob("*"))
            sh.rm("-rf", sh.glob("*"))
            sh.mv("../config", ".")
            sh.mv("../site-packages", ".")
        finally:
            os.chdir(oldpwd)
github roryk / bipy / bipy / toolbox / macs.py View on Github external
def run(input_file, options, control_file=None, out_dir=None):
    out_files = (remove_suffix(input_file) + "_peaks.bed",
                 remove_suffix(input_file) + "_summits.bed")
    cmd = _build_command(input_file, options, control_file, out_dir)
    subprocess.check_call(cmd)
    if out_dir:
        for f in out_files:
			sh.mv(f, os.path.join(out_dir, os.path.basename(f)))
        out_files = [os.path.join(out_dir, os.path.basename(x)) for
                     x in out_files]
  
    return out_files
github Mati365 / pyWinUSB / pywinusb / creator.py View on Github external
def try_move(old_file, new_file):
            try: sh.mv(old_file, new_file)
            except:
                print("File {} already exists, nothing to move".format(new_file))