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

Python platform.is_linux函数代码示例

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

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



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

示例1: decode

def decode(path):
    if isinstance(path, bytes_cls):
        try:
            path = path.decode(fs_encoding, 'strict')
        except UnicodeDecodeError:
            if not platform.is_linux():
                raise
            path = path.decode(fs_fallback_encoding, 'strict')
    return path
开发者ID:Amber-Creative,项目名称:ambererpnext,代码行数:9,代码来源:unicode_paths.py


示例2: encode

def encode(path):
    if isinstance(path, str_cls):
        try:
            path = path.encode(fs_encoding, 'strict')
        except (UnicodeEncodeError) as e:
            if not platform.is_linux():
                raise
            path = path.encode(fs_fallback_encoding, 'strict')
    return path
开发者ID:MerchantAtlas,项目名称:watchdog,代码行数:9,代码来源:unicode_paths.py


示例3: start_watching

def start_watching(path=None, use_full_emitter=False):
    path = p('') if path is None else path
    global emitter
    if platform.is_linux() and use_full_emitter:
        emitter = InotifyFullEmitter(event_queue, ObservedWatch(path, recursive=True))
    else:
        emitter = Emitter(event_queue, ObservedWatch(path, recursive=True))

    if platform.is_darwin():
        # FSEvents will report old evens (like create for mkdtemp in test
        # setup. Waiting for a considerable time seems to 'flush' the events.
        time.sleep(10)
    emitter.start()
开发者ID:DonyorM,项目名称:watchdog,代码行数:13,代码来源:test_emitter.py


示例4: _is_remote_filesystem

def _is_remote_filesystem(path):
    from utils import log
    from watchdog.utils import platform
    if not platform.is_linux():
        return False

    remote_fs_types = ['cifs', 'smbfs', 'nfs', 'nfs4']
    escaped_path = encode_path(path.rstrip('/').replace(' ', '\\040'))
    try:
        with open('/proc/mounts', 'r') as f:
            for line in f:
                _, mount_point, fstype = line.split()[:3]
                if mount_point == escaped_path:
                    log("[fstype] type is \"%s\" '%s' " % (fstype, path.decode('utf-8')))
                    return fstype in remote_fs_types
        log("[fstype] path not in /proc/mounts '%s' " % escaped_path.decode('utf-8'))
        return False

    except (IOError, ValueError) as e:
        log("[fstype] failed to read /proc/mounts. %s, %s" % (type(e), e))
        return False
开发者ID:lidormalicb,项目名称:xbmc-addon-watchdog,代码行数:21,代码来源:emitters.py


示例5: _get_native_observer

    def _get_native_observer():
        """
        Return native observer... or fail.
        """
        from watchdog.utils import platform

        if platform.is_linux():
            from watchdog.observers.inotify import InotifyObserver
            return InotifyObserver

        if platform.is_windows():
            # TODO: find a reliable way of checking Windows version and import
            # polling explicitly for Windows XP
            try:
                from watchdog.observers.read_directory_changes import (
                    WindowsApiObserver)
                return WindowsApiObserver
            except:
                raise AssertionError('Native observer not supported.')

        raise AssertionError('Native observer not supported.')
开发者ID:chevah,项目名称:watchdog,代码行数:21,代码来源:pavement.py


示例6:

        subdirectories under a directory, additional watches must be created.

    This emitter implementation therefore automatically adds watches for
    sub-directories if running in recursive mode.

Some extremely useful articles and documentation:

.. _inotify FAQ: http://inotify.aiken.cz/?section=inotify&page=faq&lang=en
.. _intro to inotify: http://www.linuxjournal.com/article/8478

"""

from __future__ import with_statement
from watchdog.utils import platform
import errno
if platform.is_linux():
  import os
  import struct
  import threading
  import ctypes
  from ctypes import\
    c_int,\
    c_char_p,\
    c_uint32

  from pathtools.path import absolute_path

  from watchdog.utils import\
    has_attribute,\
    ctypes_find_library
  from watchdog.observers.api import\
开发者ID:edevil,项目名称:watchdog,代码行数:31,代码来源:inotify.py


示例7: wait_for_move_event

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import unicode_literals
import os
import random
import pytest
from tests import tmpdir, p  # pytest magic
from .shell import mkdir, touch, mv
from watchdog.observers.api import ObservedWatch
from watchdog.utils import platform

pytestmark = pytest.mark.skipif(not platform.is_linux(), reason="")
if platform.is_linux():
    from watchdog.observers.inotify import InotifyEmitter
    from watchdog.observers.inotify_buffer import InotifyBuffer


def wait_for_move_event(read_event):
    while True:
        event = read_event()
        if isinstance(event, tuple) or event.is_move:
            return event


@pytest.mark.timeout(5)
def test_move_from(p):
    mkdir(p('dir1'))
开发者ID:StephenHesperus,项目名称:watchdog,代码行数:31,代码来源:test_inotify_buffer.py


示例8: setup_function

from __future__ import unicode_literals
import os
import pytest
import logging
import contextlib
from tests import Queue
from functools import partial
from .shell import rm, mkdtemp
from watchdog.utils import platform
from watchdog.events import DirCreatedEvent, DirDeletedEvent, DirModifiedEvent
from watchdog.observers.api import ObservedWatch

if platform.is_linux():
    from watchdog.observers.inotify import InotifyFullEmitter, InotifyEmitter


logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)


def setup_function(function):
    global p, event_queue
    tmpdir = os.path.realpath(mkdtemp())
    p = partial(os.path.join, tmpdir)
    event_queue = Queue()


@contextlib.contextmanager
def watching(path=None, use_full_emitter=False):
    path = p('') if path is None else path
    global emitter
开发者ID:DonyorM,项目名称:watchdog,代码行数:31,代码来源:test_inotify_c.py


示例9: wait_for_move_event

# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import unicode_literals

import pytest
from watchdog.utils import platform

if not platform.is_linux():
    pytest.skip("GNU/Linux only.", allow_module_level=True)

import os
import random

from watchdog.observers.inotify_buffer import InotifyBuffer

from .shell import mkdir, touch, mv, rm


def wait_for_move_event(read_event):
    while True:
        event = read_event()
        if isinstance(event, tuple) or event.is_move:
            return event
开发者ID:gorakhargosh,项目名称:watchdog,代码行数:31,代码来源:test_inotify_buffer.py


示例10: setup_function

# limitations under the License.

from __future__ import unicode_literals
import os
import time
import pytest
import logging
from tests import Queue
from functools import partial
from .shell import mkdir, touch, mv, rm, mkdtemp
from watchdog.utils import platform
from watchdog.utils.unicode_paths import str_cls
from watchdog.events import *
from watchdog.observers.api import ObservedWatch

pytestmark = pytest.mark.skipif(not platform.is_linux() and not platform.is_darwin(), reason="")
if platform.is_linux():
    from watchdog.observers.inotify import InotifyEmitter as Emitter
elif platform.is_darwin():
    from watchdog.observers.fsevents2 import FSEventsEmitter as Emitter

logging.basicConfig(level=logging.DEBUG)


def setup_function(function):
    global p, event_queue
    tmpdir = os.path.realpath(mkdtemp())
    p = partial(os.path.join, tmpdir)
    event_queue = Queue()

开发者ID:StephenHesperus,项目名称:watchdog,代码行数:29,代码来源:test_emitter.py


示例11: setup_function

import os
import threading
import time
import pytest
import logging
from tests import Queue
from functools import partial
from .shell import mkdir, touch, mv, rm, mkdtemp
from watchdog.utils import platform
from watchdog.utils.unicode_paths import str_cls
from watchdog.events import *
from watchdog.observers.api import ObservedWatch

# pytestmark = pytest.mark.skipif(not platform.is_linux() and not platform.is_darwin(),
# reason="")
if platform.is_linux():
    from watchdog.observers.inotify import InotifyEmitter as Emitter
    from watchdog.observers.inotify import InotifyFullEmitter
elif platform.is_darwin():
    from watchdog.observers.fsevents2 import FSEventsEmitter as Emitter
elif platform.is_windows():
    from watchdog.observers.read_directory_changes import WindowsApiEmitter as Emitter

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)

def setup_function(function):
    global p, event_queue
    tmpdir = os.path.realpath(mkdtemp())
    p = partial(os.path.join, tmpdir)
开发者ID:cross-cloud,项目名称:watchdog,代码行数:31,代码来源:test_emitter.py


示例12: list

    from keyring.backend import _load_backend
    "ensure that all keyring backends are loaded"
    backends = ('file', 'Gnome', 'Google', 'keyczar', 'multi', 'OS_X', 'pyfs', 'SecretService', 'Windows')
    list(map(_load_backend, backends))

import keyring.backend
keyring.backend._load_backends = _load_backends

if getattr(sys, 'frozen', False):
    def _certs_where():
        return str((Path(sys._MEIPASS)) / 'res' / 'cacert.pem')
    requests.certs.where = _certs_where
    os.environ['REQUESTS_CA_BUNDLE'] = requests.certs.where()
    logging.info("Setting certificate path to " + requests.certs.where())

fs_encoding = sys.getfilesystemencoding()

if not fs_encoding and platform.is_linux():
    def _watchdog_encode(path):
        if isinstance(path, unicode):
            path = path.encode('utf-8', 'strict')
        return path

    def _watchdog_decode(path):
        if isinstance(path, str):
            path = path.decode('utf-8', 'strict')
        return path

    import watchdog.utils.unicode_paths
    watchdog.utils.unicode_paths.encode = _watchdog_encode
    watchdog.utils.unicode_paths.decode = _watchdog_decode
开发者ID:nguyentamvinhlong,项目名称:pydio-sync,代码行数:31,代码来源:monkeypatch.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python _i18n._函数代码示例发布时间:2022-05-26
下一篇:
Python utils.has_attribute函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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