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

Python _compat.u函数代码示例

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

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



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

示例1: _cleanup_files

def _cleanup_files():
    DEVNULL.close()
    for name in os.listdir(u('.')):
        if name.startswith(u(TESTFILE_PREFIX)):
            try:
                safe_rmpath(name)
            except Exception:
                traceback.print_exc()
    for path in _testfiles_created:
        try:
            safe_rmpath(path)
        except Exception:
            traceback.print_exc()
开发者ID:mabuaita,项目名称:ops,代码行数:13,代码来源:__init__.py


示例2: test_proc_cmdline_mocked

 def test_proc_cmdline_mocked(self):
     # see: https://github.com/giampaolo/psutil/issues/639
     p = psutil.Process()
     fake_file = io.StringIO(u('foo\x00bar\x00'))
     with mock.patch('psutil._pslinux.open',
                     return_value=fake_file, create=True) as m:
         p.cmdline() == ['foo', 'bar']
         assert m.called
     fake_file = io.StringIO(u('foo\x00bar\x00\x00'))
     with mock.patch('psutil._pslinux.open',
                     return_value=fake_file, create=True) as m:
         p.cmdline() == ['foo', 'bar', '']
         assert m.called
开发者ID:dpavlenkov,项目名称:psutil,代码行数:13,代码来源:_linux.py


示例3: _cleanup_files

def _cleanup_files():
    DEVNULL.close()
    for name in os.listdir(u('.')):
        if isinstance(name, unicode):
            prefix = u(TESTFILE_PREFIX)
        else:
            prefix = TESTFILE_PREFIX
        if name.startswith(prefix):
            try:
                safe_rmpath(name)
            except Exception:
                traceback.print_exc()
    for path in _testfiles_created:
        try:
            safe_rmpath(path)
        except Exception:
            traceback.print_exc()
开发者ID:jomann09,项目名称:psutil,代码行数:17,代码来源:__init__.py


示例4: expect_exact_path_match

 def expect_exact_path_match(cls):
     # Do not expect psutil to correctly handle unicode paths on
     # Python 2 if os.listdir() is not able either.
     if PY3:
         return True
     else:
         here = '.' if isinstance(cls.funky_name, str) else u('.')
         with warnings.catch_warnings():
             warnings.simplefilter("ignore")
             return cls.funky_name in os.listdir(here)
开发者ID:marcinkuzminski,项目名称:psutil,代码行数:10,代码来源:test_unicode.py


示例5: cleanup_test_files

def cleanup_test_files():
    logstderr("executing cleanup_test_files() atexit function")
    DEVNULL.close()
    for name in os.listdir(u('.')):
        if isinstance(name, unicode):
            prefix = u(TESTFILE_PREFIX)
        else:
            prefix = TESTFILE_PREFIX
        if name.startswith(prefix):
            logstderr("removing temporary test file %r" % name)
            try:
                safe_rmpath(name)
            except Exception:
                traceback.print_exc()
    for path in _testfiles_created:
        logstderr("removing temporary test file %r" % path)
        try:
            safe_rmpath(path)
        except Exception:
            traceback.print_exc()
开发者ID:eomsoft,项目名称:teleport,代码行数:20,代码来源:__init__.py


示例6: open_mock

        def open_mock(name, *args, **kwargs):
            if name == '/proc/partitions':
                return io.StringIO(textwrap.dedent(u"""\
                    major minor  #blocks  name

                       8        0  488386584 hda
                    """))
            elif name == '/proc/diskstats':
                return io.StringIO(
                    u("   3    1   hda 1 2 3 4"))
            else:
                return orig_open(name, *args, **kwargs)
            return orig_open(name, *args)
开发者ID:Alren-huang,项目名称:psutil,代码行数:13,代码来源:test_linux.py


示例7: test_disk_partitions_mocked

 def test_disk_partitions_mocked(self):
     # Test that ZFS partitions are returned.
     with open("/proc/filesystems", "r") as f:
         data = f.read()
     if 'zfs' in data:
         for part in psutil.disk_partitions():
             if part.fstype == 'zfs':
                 break
         else:
             self.fail("couldn't find any ZFS partition")
     else:
         # No ZFS partitions on this system. Let's fake one.
         fake_file = io.StringIO(u("nodev\tzfs\n"))
         with mock.patch('psutil._pslinux.open',
                         return_value=fake_file, create=True) as m1:
             with mock.patch(
                     'psutil._pslinux.cext.disk_partitions',
                     return_value=[('/dev/sdb3', '/', 'zfs', 'rw')]) as m2:
                 ret = psutil.disk_partitions()
                 assert m1.called
                 assert m2.called
                 assert ret
                 self.assertEqual(ret[0].fstype, 'zfs')
开发者ID:dpavlenkov,项目名称:psutil,代码行数:23,代码来源:_linux.py


示例8: u

# the timeout used in functions which have to wait
GLOBAL_TIMEOUT = 3
# test output verbosity
VERBOSITY = 1 if os.getenv('SILENT') or TOX else 2
# be more tolerant if we're on travis / appveyor in order to avoid
# false positives
if TRAVIS or APPVEYOR:
    NO_RETRIES *= 3
    GLOBAL_TIMEOUT *= 3

# --- files

TESTFILE_PREFIX = '$testfn'
TESTFN = os.path.join(os.path.realpath(os.getcwd()), TESTFILE_PREFIX)
_TESTFN = TESTFN + '-internal'
TESTFN_UNICODE = TESTFN + u("-ƒőő")
ASCII_FS = sys.getfilesystemencoding().lower() in ('ascii', 'us-ascii')

# --- paths

ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
SCRIPTS_DIR = os.path.join(ROOT_DIR, 'scripts')
HERE = os.path.abspath(os.path.dirname(__file__))

# --- support

HAS_CPU_AFFINITY = hasattr(psutil.Process, "cpu_affinity")
HAS_CPU_FREQ = hasattr(psutil, "cpu_freq")
HAS_CONNECTIONS_UNIX = POSIX and not SUNOS
HAS_ENVIRON = hasattr(psutil.Process, "environ")
HAS_PROC_IO_COUNTERS = hasattr(psutil.Process, "io_counters")
开发者ID:mabuaita,项目名称:ops,代码行数:31,代码来源:__init__.py


示例9: open_mock

 def open_mock(name, *args, **kwargs):
     if name == ('/proc/partitions'):
         return orig_open(name, *args, **kwargs)
     else:
         return io.StringIO(u("8       1 sda1 2 2 2 2\n"))
     return orig_open(name, *args)
开发者ID:a-d-j-i,项目名称:psutil,代码行数:6,代码来源:test_linux.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python tests.get_test_subprocess函数代码示例发布时间:2022-05-25
下一篇:
Python _compat.print_函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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