• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sh.cat函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sh.cat函数的典型用法代码示例。如果您正苦于以下问题:Python cat函数的具体用法?Python cat怎么用?Python cat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cat函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: plot

def plot(input_file, output_file, nr_of_lines, options = None, label = 'transfer rate [MB per s]'):
    '''Plot input file with uneven column number n being x axis value, 
    and n+1 being the corresponding y axis values for column n.'''
    if options is None:
        options = []
    with tempfile.NamedTemporaryFile() as plot_file:
        print >>plot_file, 'set xlabel "time [min]";'
        print >>plot_file, 'set xtic auto;'
        print >>plot_file, 'set ylabel "%s";' % label
        #print >>plot_file, 'set timefmt '%Y-%m-%d %H:%M:%S''
        if MONOCHROME in options:
            print >>plot_file, 'set terminal pdf linewidth 3 monochrome solid font "Helvetica,14" size 16cm,12cm'
        else:
            print >>plot_file, 'set terminal pdf linewidth 3 solid font "Helvetica,14" size 16cm,12cm'
        print >>plot_file, 'set output "%s"' % output_file 
        plot_file.write('plot ')
        print nr_of_lines
        for i in range(nr_of_lines):
            print "line:"+str(i)
            x_axis_col = i*2 + 1
            y_axis_col = i*2 + 2
            plot_file.write('"%s" using %s:%s title column(%s)  w lines ' % (input_file, x_axis_col, y_axis_col, y_axis_col))
            if i+1 != nr_of_lines:
                plot_file.write(',')
        plot_file.flush()
        print "plot file:"
        #print plot_file.name
        print sh.cat(plot_file.name)
        #raw_input("raw_input")
        sh.gnuplot(plot_file.name)
开发者ID:joe42,项目名称:fusetests,代码行数:30,代码来源:vis_streaming_files_simple_multiple_mountpoints.py


示例2: test_internal_bufsize

 def test_internal_bufsize(self):
     from sh import cat
     
     output = cat(_in="a"*1000, _internal_bufsize=100, _out_bufsize=0)
     self.assertEqual(len(output), 100)
     
     output = cat(_in="a"*1000, _internal_bufsize=50, _out_bufsize=2)
     self.assertEqual(len(output), 100)
开发者ID:ahhentz,项目名称:sh,代码行数:8,代码来源:test.py


示例3: runCommand

 def runCommand(input_path, output_path, *extra_arguments, error_path=None):
   # See createNativeCommand for why I'm using cat
   if not error_path:
     return command(
               snapshots(sh.cat(input_path, _piped="direct"), _piped="direct"), 
               *extra_arguments, _out=output_path, _iter="err")
   else:
     return command(
               snapshots(sh.cat(input_path, _piped="direct"), _piped="direct"), 
               *extra_arguments, _out=output_path, _err=error_path, _bg=True)
开发者ID:AdamGleave,项目名称:PartIIProject,代码行数:10,代码来源:benchmark.py


示例4: test_stdin_processing

def test_stdin_processing():
    """
    You’re also not limited to using just strings. You may use a file object,
    a Queue, or any iterable (list, set, dictionary, etc):
    :return:
    """
    from sh import cat, tr
    # print "test"
    print cat(_in='test')
    print tr('[:lower:]', '[:upper:]', _in='sh is awesome')
开发者ID:vhnuuh,项目名称:pyutil,代码行数:10,代码来源:sample.py


示例5: main

def main(argv=None):
    if argv:
        post = ' '.join(argv[1:])
    else:
        post = ''
    cap = int(cat('/sys/class/power_supply/BAT0/energy_full'))
    now = int(cat('/sys/class/power_supply/BAT0/energy_now'))
    per = (now/cap)*100

    return output(per, post)
开发者ID:xolan,项目名称:dotfiles,代码行数:10,代码来源:battery.py


示例6: report_benchmark_results

def report_benchmark_results(file_a, file_b, description):
  """Wrapper around report_benchmark_result.py."""
  result = "{0}/perf_results/latest/performance_result.txt".format(IMPALA_HOME)
  with open(result, "w") as f:
    subprocess.check_call(
      ["{0}/tests/benchmark/report_benchmark_results.py".format(IMPALA_HOME),
       "--reference_result_file={0}".format(file_a),
       "--input_result_file={0}".format(file_b),
       '--report_description="{0}"'.format(description)],
      stdout=f)
  sh.cat(result, _out=sys.stdout)
开发者ID:jbapple-cloudera,项目名称:incubator-impala,代码行数:11,代码来源:single_node_perf_run.py


示例7: parse_rdf

    def parse_rdf(self):
        """ cat|grep's the rdf file for minimum metadata
        """
        # FIXME: make this an rdf parser if I can
        _title = sh.grep(sh.cat(self.rdf_path), 'dcterms:title', _tty_out=False)
        try:
            _author = sh.grep(sh.cat(self.rdf_path), 'name', _tty_out=False)
            self.author = self._clean_properties(_author)
        except sh.ErrorReturnCode_1:
            self.author = "Various"

        self.title = self._clean_properties(_title)
开发者ID:laegrim,项目名称:gitberg,代码行数:12,代码来源:catalog.py


示例8: restore_config

def restore_config(config_file):
    output.itemize(
        'Restoring firewall configuration from \'{}\''.format(config_file)
    )

    sh.iptables_restore(sh.cat(config_file))
    files.remove(os.path.dirname(config_file), _output_level=1)
开发者ID:0x64746b,项目名称:mullvad_bootstrap,代码行数:7,代码来源:firewall.py


示例9: email_sh_error

def email_sh_error(
    sh_error, email_dir, sender_email,
    recipient_emails, subject
):
    """
    Takes an sh.ErrorReturnCode error
    and sends an email (using sendmail) with its contents
    """

    epoch_time = datetime.now().strftime('%s')

    email_filepath = '{0}/{1}.email'.format(email_dir, epoch_time)

    with open(email_filepath, 'w') as email_file:
        email_file.write('from: {0}\n'.format(sender_email))
        email_file.write('subject: {0}\n'.format(subject))
        email_file.write('\n')
        email_file.write('{0}\n'.format(sh_error.message))
        email_file.write('\n')
        email_file.write('Exception properties\n')
        email_file.write('===\n')
        email_file.write('full_cmd: {0}\n'.format(sh_error.full_cmd))
        email_file.write('exit_code: {0}\n'.format(str(sh_error.exit_code)))
        email_file.write('stdout: {0}\n'.format(sh_error.stdout))
        email_file.write('stderr: {0}\n'.format(sh_error.stderr))

    sh.sendmail(sh.cat(email_filepath), recipient_emails)
开发者ID:ubuntudesign,项目名称:bzr-sync,代码行数:27,代码来源:error_handlers.py


示例10: test_console_script

def test_console_script(cli):
    TEST_COMBINATIONS = (
        # quote_mode, var_name, var_value, expected_result
        ("always", "HELLO", "WORLD", 'HELLO="WORLD"\n'),
        ("never", "HELLO", "WORLD", 'HELLO=WORLD\n'),
        ("auto", "HELLO", "WORLD", 'HELLO=WORLD\n'),
        ("auto", "HELLO", "HELLO WORLD", 'HELLO="HELLO WORLD"\n'),
    )
    with cli.isolated_filesystem():
        for quote_mode, variable, value, expected_result in TEST_COMBINATIONS:
            sh.touch(dotenv_path)
            sh.dotenv('-f', dotenv_path, '-q', quote_mode, 'set', variable, value)
            output = sh.cat(dotenv_path)
            assert output == expected_result
            sh.rm(dotenv_path)

    # should fail for not existing file
    result = cli.invoke(dotenv.cli.set, ['my_key', 'my_value'])
    assert result.exit_code != 0

    # should fail for not existing file
    result = cli.invoke(dotenv.cli.get, ['my_key'])
    assert result.exit_code != 0

    # should fail for not existing file
    result = cli.invoke(dotenv.cli.list, [])
    assert result.exit_code != 0
开发者ID:Gwill,项目名称:python-dotenv,代码行数:27,代码来源:test_cli.py


示例11: postClone

  def postClone(self, cloned_files, target_dir, version):
    """
    .. versionadded:: 0.3.0
    """
    # Start by extracting all the files
    for f in cloned_files:
      # GunZIP the file (and remove the archive)
      sh.gunzip(f)

    # Then let's concat them
    target_path = "{}/NCBI.Homo_sapiens.fa".format(target_dir)
    # Remove ".gz" ending to point to extracted files
    cat_args = [f[:-3] for f in cloned_files]

    # Execute the concatenation in the background and write to the target path
    sh.cat(*cat_args, _out=target_path, _bg=True)
开发者ID:alneberg,项目名称:cosmid,代码行数:16,代码来源:ncbi_assembly.py


示例12: test_filter_pipe_config

def test_filter_pipe_config():
    output = StringIO()
    python3(cat(program_output), path2main, config=config_file,
            use_config_section='TEST', _out=output)

    with open(program_output_filtered, 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
开发者ID:Jenselme,项目名称:unlog,代码行数:7,代码来源:test_unlog.py


示例13: test_two_images

def test_two_images():
    sh.docker(sh.cat('empty.tar'), 'import', '-', 'footest')
    sh.docker('build', '-t', 'bartest', '.')
    f = StringIO()
    Docktree(restrict='footest', file=f).draw_tree()
    assert re.match(
        u'└─ sha256:[a-f0-9]{5} footest:latest\n' +
        u'   └─ sha256:[a-f0-9]{5} bartest:latest\n', f.getvalue())
开发者ID:cmihai,项目名称:docktree,代码行数:8,代码来源:test_docktree.py


示例14: raxml_consensus

def raxml_consensus(gene_trees, model, outgroup, list_of_genes):
    '''Generates consensus trees from bootstraps and puts support values on
    best trees'''

    from sh import raxmlHPC as raxml
    os.chdir(gene_trees)
    for gene in list_of_genes:
        raxml("-m", model, "-p", "12345", "-f", "b", "-t", "RAxML_bestTree." +
            gene + '.' + model, "-z", "RAxML_bootstrap." + gene + '.boot', "-n",
            gene + ".cons.tre", "-o", outgroup)
    from sh import cat
    consensus_trees = glob('RAxML_bipartitions.*.cons.tre')
    cat(consensus_trees, _out='all_consensus_gene_trees.tre')
    # NEED TO ADD, ETE2 OR SOMETHING TO PUT NAMES ON TREES
    os.chdir('../../')
    print "# RAXML bootstrap search finished"
    return
开发者ID:saemi,项目名称:plast2phy,代码行数:17,代码来源:run_plast2phy.py


示例15: mounted

def mounted(dir=None):
    try:
        cwd = dir if dir else os.path.join(os.getcwd(), 'files')
        cwd = os.path.realpath(cwd)
        return any(cwd == path.strip() for path in 
                list(sh.awk(sh.cat("/proc/mounts"), "{print $2}")))
    except sh.ErrorReturnCode:
        return False
开发者ID:rrader,项目名称:pstor,代码行数:8,代码来源:pstor.py


示例16: test_basic_filter_pipe

def test_basic_filter_pipe():
    output = StringIO()
    python3(cat(program_output), path2main,
            start_pattern=start_pattern,
            error_pattern=error_pattern,
            _out=output)

    with open(program_output_filtered, 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
开发者ID:Jenselme,项目名称:unlog,代码行数:9,代码来源:test_unlog.py


示例17: cat_sys_info_cmd

def cat_sys_info_cmd(**kwargs):
    """
    Usage:
        cat sys info --cpu --memory --repeat <repeat>

    Options:
        -c,--cpu               Show CPU information
        -m,--memory            Show memory usage
        -r,--repeat <repeat>   Repeat time [default: 1]
    """
    result = ""

    if "--cpu" in kwargs and kwargs["--cpu"]:
        print "CPU:"
        print cat("/proc/cpuinfo")

    if "--memory" in kwargs and kwargs["--memory"]:
        print "Memory:"
        print cat("/proc/meminfo")
开发者ID:Swind,项目名称:clif,代码行数:19,代码来源:cat_cpu_info.py


示例18: get_cmd_from_ps

def get_cmd_from_ps(needle):
    result = sh.grep(sh.cat(sh.ps('-wwaeopid,cmd')), needle)
    if result.exit_code == 0:
        for line in result.stdout.split('\n'):
            line = line.strip()
            if not line:
                continue
            match = re.search(r'^(\d*)\s*(.*)', line)
            if match.group(2).startswith('grep'):
                continue
            return match.group(2)
    raise KeyError('Failed to find: %s' % needle)
开发者ID:Oliverlyn,项目名称:picostack,代码行数:12,代码来源:vm_manager.py


示例19: get_commit_files

def get_commit_files(file_type):
  system("git diff --cached --name-status > /tmp/git_hook")

  files = awk(
    grep(
     cat("/tmp/git_hook"), "-P", "A|M.*.%s$" % file_type,
     _ok_code = [0, 1]
    ), "{print $2}", _iter = True
  )

  exten = ".%s" % file_type
  return [path[:path.rindex(exten) + len(exten)] for path in files]
开发者ID:superbug,项目名称:git_code_sniffer_hooks,代码行数:12,代码来源:common.py


示例20: _wait_for_pid_file

    def _wait_for_pid_file(self, filename, wait_time):
        count = 0
        while not os.path.exists(filename):
            if count == wait_time:
                break
            time.sleep(1)
            count += 1

        if os.path.isfile(filename):
            self.twistd_pid = cat(filename)
            print 'self.twistd_pid: ', self.twistd_pid
        else:
            raise ValueError("%s isn't a file!" % filename)
开发者ID:awellock,项目名称:python-hpedockerplugin,代码行数:13,代码来源:test_hpe_plugin.py



注:本文中的sh.cat函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sh.cd函数代码示例发布时间:2022-05-27
下一篇:
Python sgtk.sgtk_from_path函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap