当前位置: 首页>>代码示例>>Python>>正文


Python os.fpathconf方法代码示例

本文整理汇总了Python中os.fpathconf方法的典型用法代码示例。如果您正苦于以下问题:Python os.fpathconf方法的具体用法?Python os.fpathconf怎么用?Python os.fpathconf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在os的用法示例。


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

示例1: test_communicate_pipe_buf

# 需要导入模块: import os [as 别名]
# 或者: from os import fpathconf [as 别名]
def test_communicate_pipe_buf(self):
        # communicate() with writes larger than pipe_buf
        # This test will probably deadlock rather than fail, if
        # communicate() does not work properly.
        x, y = os.pipe()
        if mswindows:
            pipe_buf = 512
        else:
            pipe_buf = os.fpathconf(x, "PC_PIPE_BUF")
        os.close(x)
        os.close(y)
        p = subprocess.Popen([sys.executable, "-c",
                          'import sys,os;'
                          'sys.stdout.write(sys.stdin.read(47));'
                          'sys.stderr.write("xyz"*%d);'
                          'sys.stdout.write(sys.stdin.read())' % pipe_buf],
                         stdin=subprocess.PIPE,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
        self.addCleanup(p.stdout.close)
        self.addCleanup(p.stderr.close)
        self.addCleanup(p.stdin.close)
        string_to_write = "abc"*pipe_buf
        (stdout, stderr) = p.communicate(string_to_write)
        self.assertEqual(stdout, string_to_write) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:test_subprocess.py

示例2: test_communicate_pipe_buf

# 需要导入模块: import os [as 别名]
# 或者: from os import fpathconf [as 别名]
def test_communicate_pipe_buf(self):
        # communicate() with writes larger than pipe_buf
        # This test will probably deadlock rather than fail, if
        # communicate() does not work properly.
        if mswindows or (jython and os._name == 'nt'):
            pipe_buf = 512
        elif jython:
            pipe_buf = 16384
        else:
            x, y = os.pipe()
            pipe_buf = os.fpathconf(x, "PC_PIPE_BUF")
            os.close(x)
            os.close(y)
        p = subprocess.Popen([sys.executable, "-c",
                          'import sys,os;'
                          'sys.stdout.write(sys.stdin.read(47));' \
                          'sys.stderr.write("xyz"*%d);' \
                          'sys.stdout.write(sys.stdin.read())' % pipe_buf],
                         stdin=subprocess.PIPE,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
        string_to_write = "abc"*pipe_buf
        (stdout, stderr) = p.communicate(string_to_write)
        self.assertEqual(stdout, string_to_write) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:26,代码来源:test_subprocess.py

示例3: main

# 需要导入模块: import os [as 别名]
# 或者: from os import fpathconf [as 别名]
def main():
    fd = sys.stdin.fileno()
    locale.setlocale(locale.LC_ALL, '')
    encoding = locale.getpreferredencoding()

    print('os.isatty({0}) => {1}'.format(fd, os.isatty(fd)))
    print('locale.getpreferredencoding() => {0}'.format(encoding))

    display_conf(kind='pathconf',
                 names=os.pathconf_names,
                 getter=lambda name: os.fpathconf(fd, name))

    try:
        (iflag, oflag, cflag, lflag, ispeed, ospeed, cc
         ) = termios.tcgetattr(fd)
    except termios.error as err:
        print('stdin is not a typewriter: {0}'.format(err))
    else:
        display_bitmask(kind='Input Mode',
                        bitmap=BITMAP_IFLAG,
                        value=iflag)
        display_bitmask(kind='Output Mode',
                        bitmap=BITMAP_OFLAG,
                        value=oflag)
        display_bitmask(kind='Control Mode',
                        bitmap=BITMAP_CFLAG,
                        value=cflag)
        display_bitmask(kind='Local Mode',
                        bitmap=BITMAP_LFLAG,
                        value=lflag)
        display_ctl_chars(index=CTLCHAR_INDEX,
                          cc=cc)
        print('os.ttyname({0}) => {1}'.format(fd, os.ttyname(fd)))
        print('os.ctermid() => {0}'.format(os.ttyname(fd))) 
开发者ID:HoussemCharf,项目名称:FunUtils,代码行数:36,代码来源:display-terminal-info.py

示例4: test_fpathconf

# 需要导入模块: import os [as 别名]
# 或者: from os import fpathconf [as 别名]
def test_fpathconf(self):
        self.check(os.fpathconf, "PC_NAME_MAX") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:test_os.py

示例5: test_fpathconf

# 需要导入模块: import os [as 别名]
# 或者: from os import fpathconf [as 别名]
def test_fpathconf(self):
        if hasattr(os, "fpathconf"):
            self.check(os.fpathconf, "PC_NAME_MAX") 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:5,代码来源:test_os.py

示例6: test_fpathconf

# 需要导入模块: import os [as 别名]
# 或者: from os import fpathconf [as 别名]
def test_fpathconf(self):
        self.check(os.pathconf, "PC_NAME_MAX")
        self.check(os.fpathconf, "PC_NAME_MAX") 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:5,代码来源:test_os.py

示例7: testLineReader

# 需要导入模块: import os [as 别名]
# 或者: from os import fpathconf [as 别名]
def testLineReader(self):
        p = os.pipe()
        pipeSize = os.fpathconf(p[0], os.pathconf_names['PC_PIPE_BUF'])

        rdr = util.LineReader(p[0])
        writeFd = p[1]

        os.write(writeFd, "hel")
        assert(rdr.readlines() == [ ])
        os.write(writeFd, "lo\n")
        assert(rdr.readlines() == [ "hello\n" ])

        os.write(writeFd, "hello\nworld\n")
        assert(rdr.readlines() == [ "hello\n", "world\n" ])

        os.write(writeFd, "hello\nthere")
        assert(rdr.readlines() == [ "hello\n" ])
        os.write(writeFd, "\nbig")
        assert(rdr.readlines() == [ "there\n" ])
        os.write(writeFd, "\nwide\nworld\n")
        assert(rdr.readlines() == [ "big\n", "wide\n", "world\n" ])

        os.close(writeFd)
        assert(rdr.readlines() == None )

        os.close(p[0]) 
开发者ID:sassoftware,项目名称:conary,代码行数:28,代码来源:utiltest.py


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