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

Python stdout.strip函数代码示例

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

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



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

示例1: test_ParsInsert_supported_version

    def test_ParsInsert_supported_version(self):
        """ParsInsert is in path and version is supported """
        acceptable_version = ["1.04"]
        self.assertTrue(
            which("ParsInsert"),
            "ParsInsert not found. This may or may not be a problem depending on "
            + "which components of QIIME you plan to use.",
        )
        command = "ParsInsert -v | grep App | awk '{print $3}'"
        proc = Popen(command, shell=True, universal_newlines=True, stdout=PIPE, stderr=STDOUT)
        stdout = proc.stdout.read()

        # remove log file generated
        remove_files(["ParsInsert.log"], error_on_missing=False)

        version_string = stdout.strip()
        try:
            pass_test = version_string in acceptable_version
        except ValueError:
            pass_test = False
            version_string = stdout
        self.assertTrue(
            pass_test,
            "Unsupported ParsInsert version. %s is required, but running %s."
            % (".".join(map(str, acceptable_version)), version_string),
        )
开发者ID:TheSchwa,项目名称:qiime,代码行数:26,代码来源:print_qiime_config.py


示例2: test_R_supported_version

 def test_R_supported_version(self):
     """R is in path and version is supported """
     minimum_version = (2, 12, 0)
     self.assertTrue(which('R'),
                     "R not found. This may or may not be a problem depending on " +
                     "which components of QIIME you plan to use.")
     command = "R --version | grep 'R version' | awk '{print $3}'"
     proc = Popen(command, shell=True, universal_newlines=True,
                  stdout=PIPE, stderr=STDOUT)
     stdout = proc.stdout.read()
     version_string = stdout.strip()
     try:
         version = tuple(map(int, version_string.split('.')))
         pass_test = False
         if version[0] == minimum_version[0]:
             if version[1] == minimum_version[1]:
                 if version[2] >= minimum_version[2]:
                     pass_test = True
             elif version[1] > minimum_version[1]:
                 pass_test = True
         elif version[0] > minimum_version[0]:
             pass_test = True
     except ValueError:
         pass_test = False
         version_string = stdout
     self.assertTrue(pass_test,
                     "Unsupported R version. %s or greater is required, but running %s."
                     % ('.'.join(map(str, minimum_version)), version_string))
开发者ID:Bonder-MJ,项目名称:qiime,代码行数:28,代码来源:print_qiime_config.py


示例3: test_python_supported_version

    def test_python_supported_version(self):
        """python is in path and version is supported """
        min_acceptable_version = (2, 7, 0)
        min_unacceptable_version = (3, 0, 0)

        command = 'python --version'
        proc = Popen(command, shell=True, universal_newlines=True,
                     stdout=PIPE, stderr=STDOUT)
        stdout = proc.stdout.read()

        version_str_matches = re.findall('Python\s+(\S+)\s*', stdout.strip())
        self.assertEqual(len(version_str_matches), 1,
                         "Could not determine the Python version in '%s'." %
                         stdout)
        version_string = version_str_matches[0]

        try:
            if version_string[-1] == '+':
                version_string = version_string[:-1]
            version = tuple(map(int, version_string.split('.')))
            if len(version) == 2:
                version = (version[0], version[1], 0)
            pass_test = (version >= min_acceptable_version and
                         version < min_unacceptable_version)
        except ValueError:
            pass_test = False
            version_string = stdout
        self.assertTrue(pass_test,
                        "Unsupported Python version. Must be >= %s and < %s, "
                        "but running %s."
                        % ('.'.join(map(str, min_acceptable_version)),
                           '.'.join(map(str, min_unacceptable_version)),
                           version_string))
开发者ID:Bonder-MJ,项目名称:qiime,代码行数:33,代码来源:print_qiime_config.py


示例4: test_mothur_supported_version

    def test_mothur_supported_version(self):
        """mothur is in path and version is supported """
        acceptable_version = (1, 25, 0)
        self.assertTrue(
            which("mothur"),
            "mothur not found. This may or may not be a problem depending on "
            + "which components of QIIME you plan to use.",
        )
        # mothur creates a log file in cwd, so create a tmp and cd there first
        log_file = join(get_qiime_temp_dir(), "mothur.log")
        command = "mothur \"#set.logfile(name=%s)\" | grep '^mothur v'" % log_file
        stdout, stderr, exit_Status = qiime_system_call(command)

        # remove log file
        remove_files([log_file], error_on_missing=False)

        version_string = stdout.strip().split(" ")[1].strip("v.")
        try:
            version = tuple(map(int, version_string.split(".")))
            pass_test = version == acceptable_version
        except ValueError:
            pass_test = False
            version_string = stdout
        self.assertTrue(
            pass_test,
            "Unsupported mothur version. %s is required, but running %s."
            % (".".join(map(str, acceptable_version)), version_string),
        )
开发者ID:TheSchwa,项目名称:qiime,代码行数:28,代码来源:print_qiime_config.py


示例5: testClose

 def testClose(self):
     sequentialStorage = SequentialStorage(self.tempdir)
     sequentialStorage.add(identifier='abc', data="1")
     lockFile = join(self.tempdir, 'write.lock')
     self.assertTrue(isfile(lockFile))
     sequentialStorage.close()
     stdout, stderr = Popen("lsof -n %s" % lockFile, stdout=PIPE, stderr=PIPE, shell=True).communicate()
     self.assertEquals('', stdout.strip())
     self.assertRaises(AttributeError, lambda: sequentialStorage.add('def', data='2'))
开发者ID:seecr,项目名称:meresco-sequentialstore,代码行数:9,代码来源:sequentialstoragetest.py


示例6: run_subprocess

def run_subprocess(command, *args, **kwargs):
    """Run command using subprocess.Popen

    Run command and wait for command to complete. If the return code was zero
    then return, otherwise raise CalledProcessError.
    By default, this will also add stdout= and stderr=subproces.PIPE
    to the call to Popen to suppress printing to the terminal.

    Parameters
    ----------
    command : list of str
        Command to run as subprocess (see subprocess.Popen documentation).
    *args, **kwargs : arguments
        Arguments to pass to subprocess.Popen.

    Returns
    -------
    stdout : str
        Stdout returned by the process.
    stderr : str
        Stderr returned by the process.
    """
    if 'stderr' not in kwargs:
        kwargs['stderr'] = subprocess.PIPE
    if 'stdout' not in kwargs:
        kwargs['stdout'] = subprocess.PIPE

    # Check the PATH environment variable. If run_subprocess() is to be called
    # frequently this should be refactored so as to only check the path once.
    env = kwargs.get('env', os.environ)
    if any(p.startswith('~') for p in env['PATH'].split(os.pathsep)):
        msg = ("Your PATH environment variable contains at least one path "
               "starting with a tilde ('~') character. Such paths are not "
               "interpreted correctly from within Python. It is recommended "
               "that you use '$HOME' instead of '~'.")
        warnings.warn(msg)

    logger.info("Running subprocess: %s" % str(command))
    p = subprocess.Popen(command, *args, **kwargs)
    stdout, stderr = p.communicate()

    if stdout.strip():
        logger.info("stdout:\n%s" % stdout)
    if stderr.strip():
        logger.info("stderr:\n%s" % stderr)

    output = (stdout, stderr)
    if p.returncode:
        print output
        raise subprocess.CalledProcessError(p.returncode, command, output)

    return output
开发者ID:dichaelen,项目名称:mne-python,代码行数:52,代码来源:utils.py


示例7: test_rtax_supported_version

 def test_rtax_supported_version(self):
     """rtax is in path and version is supported """
     acceptable_version = [(0, 984)]
     self.assertTrue(which('rtax'),
                     "rtax not found. This may or may not be a problem depending on " +
                     "which components of QIIME you plan to use.")
     command = "rtax 2>&1 > %s | grep Version | awk '{print $2}'" % devnull
     proc = Popen(command, shell=True, universal_newlines=True,
                  stdout=PIPE, stderr=STDOUT)
     stdout = proc.stdout.read()
     version_string = stdout.strip()
     try:
         version = tuple(map(int, version_string.split('.')))
         pass_test = version in acceptable_version
     except ValueError:
         pass_test = False
         version_string = stdout
     self.assertTrue(pass_test,
                     "Unsupported rtax version. %s is required, but running %s."
                     % ('.'.join(map(str, acceptable_version)), version_string))
开发者ID:Bonder-MJ,项目名称:qiime,代码行数:20,代码来源:print_qiime_config.py


示例8: test_clearcut_supported_version

 def test_clearcut_supported_version(self):
     """clearcut is in path and version is supported """
     acceptable_version = (1, 0, 9)
     self.assertTrue(which('clearcut'),
                     "clearcut not found. This may or may not be a problem depending on " +
                     "which components of QIIME you plan to use.")
     command = "clearcut -V"
     proc = Popen(command, shell=True, universal_newlines=True,
                  stdout=PIPE, stderr=STDOUT)
     stdout = proc.stdout.read()
     version_string = stdout.strip().split(' ')[2].strip()
     try:
         version = tuple(map(int, version_string.split('.')))
         pass_test = version == acceptable_version
     except ValueError:
         pass_test = False
         version_string = stdout
     self.assertTrue(pass_test,
                     "Unsupported clearcut version. %s is required, but running %s."
                     % ('.'.join(map(str, acceptable_version)), version_string))
开发者ID:Bonder-MJ,项目名称:qiime,代码行数:20,代码来源:print_qiime_config.py


示例9: test_raxmlHPC_supported_version

 def test_raxmlHPC_supported_version(self):
     """raxmlHPC is in path and version is supported """
     acceptable_version = [(7, 3, 0), (7, 3, 0)]
     self.assertTrue(which('raxmlHPC'),
                     "raxmlHPC not found. This may or may not be a problem depending on " +
                     "which components of QIIME you plan to use.")
     command = "raxmlHPC -v | grep version"
     proc = Popen(command, shell=True, universal_newlines=True,
                  stdout=PIPE, stderr=STDOUT)
     stdout = proc.stdout.read()
     version_string = stdout.strip().split(' ')[4].strip()
     try:
         version = tuple(map(int, version_string.split('.')))
         pass_test = version in acceptable_version
     except ValueError:
         pass_test = False
         version_string = stdout
     self.assertTrue(pass_test,
                     "Unsupported raxmlHPC version. %s is required, but running %s."
                     % ('.'.join(map(str, acceptable_version)), version_string))
开发者ID:Bonder-MJ,项目名称:qiime,代码行数:20,代码来源:print_qiime_config.py


示例10: test_pplacer_supported_version

 def test_pplacer_supported_version(self):
     """pplacer is in path and version is supported """
     acceptable_version = [(1, 1), (1, 1)]
     self.assertTrue(app_path('pplacer'),
                     "pplacer not found. This may or may not be a problem depending on " +
                     "which components of QIIME you plan to use.")
     command = "pplacer --version"
     proc = Popen(command, shell=True, universal_newlines=True,
                  stdout=PIPE, stderr=STDOUT)
     stdout = proc.stdout.read()
     version_string = stdout.strip()[1:4]
     try:
         version = tuple(map(int, version_string.split('.')))
         pass_test = version in acceptable_version
     except ValueError:
         pass_test = False
         version_string = stdout
     self.assertTrue(pass_test,
                     "Unsupported pplacer version. %s is required, but running %s."
                     % ('.'.join(map(str, acceptable_version)), version_string))
开发者ID:lkursell,项目名称:qiime,代码行数:20,代码来源:print_qiime_config.py


示例11: test_FastTree_supported_version

 def test_FastTree_supported_version(self):
     """FastTree is in path and version is supported """
     acceptable_version = (2, 1, 3)
     self.assertTrue(app_path('FastTree'),
                     "FastTree not found. This may or may not be a problem depending on " +
                     "which components of QIIME you plan to use.")
     command = "FastTree 2>&1 > %s | grep version" % devnull
     proc = Popen(command, shell=True, universal_newlines=True,
                  stdout=PIPE, stderr=STDOUT)
     stdout = proc.stdout.read()
     version_string = stdout.strip().split(' ')[4].strip()
     try:
         version = tuple(map(int, version_string.split('.')))
         pass_test = version == acceptable_version
     except ValueError:
         pass_test = False
         version_string = stdout
     self.assertTrue(pass_test,
                     "Unsupported FastTree version. %s is required, but running %s."
                     % ('.'.join(map(str, acceptable_version)), version_string))
开发者ID:lkursell,项目名称:qiime,代码行数:20,代码来源:print_qiime_config.py


示例12: test_muscle_supported_version

 def test_muscle_supported_version(self):
     """muscle is in path and version is supported """
     acceptable_version = (3,8,31)
     self.assertTrue(app_path('muscle'),
      "muscle not found. This may or may not be a problem depending on "+\
      "which components of QIIME you plan to use.")
     command = "muscle -version"
     proc = Popen(command,shell=True,universal_newlines=True,\
                      stdout=PIPE,stderr=STDOUT)
     stdout = proc.stdout.read()
     version_string = stdout.strip().split(' ')[1].strip('v')
     try:
         version = tuple(map(int,version_string.split('.')))
         pass_test = version == acceptable_version
     except ValueError:
         pass_test = False
         version_string = stdout
     self.assertTrue(pass_test,\
      "Unsupported muscle version. %s is required, but running %s." \
      % ('.'.join(map(str,acceptable_version)), version_string))
开发者ID:rob-knight,项目名称:qiime,代码行数:20,代码来源:print_qiime_config.py


示例13: test_INFERNAL_supported_version

 def test_INFERNAL_supported_version(self):
     """INFERNAL is in path and version is supported """
     acceptable_version = (1,0,2)
     self.assertTrue(app_path('cmbuild'),
      "Infernal not found. This may or may not be a problem depending on "+\
      "which components of QIIME you plan to use.")
     command = "cmbuild -h | grep INF"
     proc = Popen(command,shell=True,universal_newlines=True,\
                      stdout=PIPE,stderr=STDOUT)
     stdout = proc.stdout.read()
     version_string = stdout.strip().split(' ')[2].strip()
     try:
         version = tuple(map(int,version_string.split('.')))
         pass_test = version == acceptable_version
     except ValueError:
         pass_test = False
         version_string = stdout
     self.assertTrue(pass_test,\
      "Unsupported INFERNAL version. %s is required, but running %s." \
      % ('.'.join(map(str,acceptable_version)), version_string))
开发者ID:rob-knight,项目名称:qiime,代码行数:20,代码来源:print_qiime_config.py


示例14: test_python_supported_version

 def test_python_supported_version(self):
     """python is in path and version is supported """
     acceptable_version = (2, 7, 3)
     command = 'python --version'
     proc = Popen(command, shell=True, universal_newlines=True,
                  stdout=PIPE, stderr=STDOUT)
     stdout = proc.stdout.read()
     version_string = stdout.strip().split('Python')[-1].strip()
     try:
         if version_string[-1] == '+':
             version_string = version_string[:-1]
         version = tuple(map(int, version_string.split('.')))
         if len(version) == 2:
             version = (version[0], version[1], 0)
         pass_test = version == acceptable_version
     except ValueError:
         pass_test = False
         version_string = stdout
     self.assertTrue(pass_test,
                     "Unsupported python version. %s is required, but running %s."
                     % ('.'.join(map(str, acceptable_version)), version_string))
开发者ID:lkursell,项目名称:qiime,代码行数:21,代码来源:print_qiime_config.py


示例15: test_blast_supported_version

 def test_blast_supported_version(self):
     """blast is in path and version is supported """
     acceptable_version = (2, 2, 22)
     self.assertTrue(
         which("blastall"),
         "blast not found. This may or may not be a problem depending on "
         + "which components of QIIME you plan to use.",
     )
     command = "blastall | grep blastall"
     proc = Popen(command, shell=True, universal_newlines=True, stdout=PIPE, stderr=STDOUT)
     stdout = proc.stdout.read()
     version_string = stdout.strip().split(" ")[1].strip()
     try:
         version = tuple(map(int, version_string.split(".")))
         pass_test = version == acceptable_version
     except ValueError:
         pass_test = False
         version_string = stdout
     self.assertTrue(
         pass_test,
         "Unsupported blast version. %s is required, but running %s."
         % (".".join(map(str, acceptable_version)), version_string),
     )
开发者ID:TheSchwa,项目名称:qiime,代码行数:23,代码来源:print_qiime_config.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python stdout.write函数代码示例发布时间:2022-05-27
下一篇:
Python stdout.isatty函数代码示例发布时间: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