本文整理汇总了Python中twisted.python.runtime.platform.isMacOSX方法的典型用法代码示例。如果您正苦于以下问题:Python platform.isMacOSX方法的具体用法?Python platform.isMacOSX怎么用?Python platform.isMacOSX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.python.runtime.platform
的用法示例。
在下文中一共展示了platform.isMacOSX方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_reactor
# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isMacOSX [as 别名]
def _get_reactor(platform):
try:
if platform.isLinux():
try:
from twisted.internet import epollreactor
cls = epollreactor.EPollReactor
except ImportError:
from twisted.internet import pollreactor
cls = pollreactor.PollReactor
elif platform.isMacOSX():
from twisted.internet import kqreactor
cls = kqreactor.KQueueReactor
elif platform.getType() == 'posix' and not platform.isMacOSX():
from twisted.internet import pollreactor
cls = pollreactor.PollReactor
else:
from twisted.internet import selectreactor
cls = selectreactor.SelectReactor
except ImportError:
from twisted.internet import selectreactor
cls = selectreactor.SelectReactor
return cls()
示例2: _getInstallFunction
# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isMacOSX [as 别名]
def _getInstallFunction(platform):
"""
Return a function to install the reactor most suited for the given platform.
@param platform: The platform for which to select a reactor.
@type platform: L{twisted.python.runtime.Platform}
@return: A zero-argument callable which will install the selected
reactor.
"""
# Linux: epoll(7) is the default, since it scales well.
#
# OS X: poll(2) is not exposed by Python because it doesn't support all
# file descriptors (in particular, lack of PTY support is a problem) --
# see <http://bugs.python.org/issue5154>. kqueue has the same restrictions
# as poll(2) as far PTY support goes.
#
# Windows: IOCP should eventually be default, but still has some serious
# bugs, e.g. <http://twistedmatrix.com/trac/ticket/4667>.
#
# We therefore choose epoll(7) on Linux, poll(2) on other non-OS X POSIX
# platforms, and select(2) everywhere else.
try:
if platform.isLinux():
try:
from twisted.internet.epollreactor import install
except ImportError:
from twisted.internet.pollreactor import install
elif platform.getType() == 'posix' and not platform.isMacOSX():
from twisted.internet.pollreactor import install
else:
from twisted.internet.selectreactor import install
except ImportError:
from twisted.internet.selectreactor import install
return install
示例3: _getInstallFunction
# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isMacOSX [as 别名]
def _getInstallFunction(platform):
"""
Return a function to install the reactor most suited for the given platform.
@param platform: The platform for which to select a reactor.
@type platform: L{twisted.python.runtime.Platform}
@return: A zero-argument callable which will install the selected
reactor.
"""
# Linux: epoll(7) is the default, since it scales well.
#
# macOS: poll(2) is not exposed by Python because it doesn't support all
# file descriptors (in particular, lack of PTY support is a problem) --
# see <http://bugs.python.org/issue5154>. kqueue has the same restrictions
# as poll(2) as far PTY support goes.
#
# Windows: IOCP should eventually be default, but still has some serious
# bugs, e.g. <http://twistedmatrix.com/trac/ticket/4667>.
#
# We therefore choose epoll(7) on Linux, poll(2) on other non-macOS POSIX
# platforms, and select(2) everywhere else.
try:
if platform.isLinux():
try:
from twisted.internet.epollreactor import install
except ImportError:
from twisted.internet.pollreactor import install
elif platform.getType() == 'posix' and not platform.isMacOSX():
from twisted.internet.pollreactor import install
else:
from twisted.internet.selectreactor import install
except ImportError:
from twisted.internet.selectreactor import install
return install
示例4: fileStoreFromPath
# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isMacOSX [as 别名]
def fileStoreFromPath(cls, path):
"""
@param path: a path pointing at the document root, where the file-based
data-store is located.
@type path: L{CachingFilePath}
"""
# Legacy: old file store only ever used these two top-level paths
for homeType in ("calendars", "addressbooks"):
if path.child(homeType).exists():
if platform.isMacOSX():
appropriateStoreClass = XattrPropertyStore
else:
attrs = xattr.xattr(path.path)
try:
attrs.get('user.should-not-be-set')
except IOError, ioe:
if ioe.errno == errno.ENODATA:
# xattrs are supported and enabled on the filesystem
# where the calendar data lives. this takes some
# doing (you have to edit fstab), so this means
# we're trying to migrate some 2.x data from a
# previous linux installation.
appropriateStoreClass = XattrPropertyStore
elif ioe.errno == errno.EOPNOTSUPP:
# The operation wasn't supported. This is what will
# usually happen on a naively configured filesystem,
# so this means we're most likely trying to migrate
# some data from an untarred archive created on an
# OS X installation using xattrs.
appropriateStoreClass = AppleDoubleStore
else:
# No need to check for ENOENT and the like; we just
# checked above to make sure the parent exists.
# Other errors are not anticipated here, so fail
# fast.
raise
appropriateStoreClass = AppleDoubleStore
from txdav.common.datastore.file import CommonDataStore as FileStore
return FileStore(
path, None, None, True, True,
propertyStoreClass=appropriateStoreClass)