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

Python standarddir.runtime函数代码示例

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

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



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

示例1: test_runtimedir_empty_tempdir

 def test_runtimedir_empty_tempdir(self, monkeypatch, tmpdir):
     """With an empty tempdir on non-Linux, we should raise."""
     monkeypatch.setattr(standarddir.sys, 'platform', 'nt')
     monkeypatch.setattr(standarddir.QStandardPaths, 'writableLocation',
                         lambda typ: '')
     with pytest.raises(standarddir.EmptyValueError):
         standarddir.runtime()
开发者ID:michaelbeaumont,项目名称:qutebrowser,代码行数:7,代码来源:test_standarddir.py


示例2: test_runtimedir

 def test_runtimedir(self, tmpdir, monkeypatch):
     """Test runtime dir (which has no args)."""
     monkeypatch.setattr(
         'qutebrowser.utils.standarddir.QStandardPaths.writableLocation',
         lambda _typ: str(tmpdir))
     args = types.SimpleNamespace(confdir=None, cachedir=None, datadir=None)
     standarddir.init(args)
     assert standarddir.runtime() == str(tmpdir)
开发者ID:r8b7xy,项目名称:qutebrowser,代码行数:8,代码来源:test_standarddir.py


示例3: test_linux_invalid_runtimedir

    def test_linux_invalid_runtimedir(self, monkeypatch, tmpdir):
        """With invalid XDG_RUNTIME_DIR, fall back to TempLocation."""
        tmpdir_env = tmpdir / 'temp'
        tmpdir_env.ensure(dir=True)
        monkeypatch.setenv('XDG_RUNTIME_DIR', str(tmpdir / 'does-not-exist'))
        monkeypatch.setenv('TMPDIR', str(tmpdir_env))

        standarddir._init_dirs()
        assert standarddir.runtime() == str(tmpdir_env / APPNAME)
开发者ID:mehak,项目名称:qutebrowser,代码行数:9,代码来源:test_standarddir.py


示例4: _path_info

def _path_info():
    """Get info about important path names.

    Return:
        A dictionary of descriptive to actual path names.
    """
    return {
        'config': standarddir.config(),
        'data': standarddir.data(),
        'system_data': standarddir.system_data(),
        'cache': standarddir.cache(),
        'download': standarddir.download(),
        'runtime': standarddir.runtime(),
    }
开发者ID:phansch,项目名称:qutebrowser,代码行数:14,代码来源:version.py


示例5: _get_socketname

def _get_socketname(basedir):
    """Get a socketname to use."""
    if utils.is_windows:  # pragma: no cover
        return _get_socketname_windows(basedir)

    parts_to_hash = [getpass.getuser()]
    if basedir is not None:
        parts_to_hash.append(basedir)

    data_to_hash = '-'.join(parts_to_hash).encode('utf-8')
    md5 = hashlib.md5(data_to_hash).hexdigest()

    prefix = 'i-' if utils.is_mac else 'ipc-'
    filename = '{}{}'.format(prefix, md5)
    return os.path.join(standarddir.runtime(), filename)
开发者ID:fiete201,项目名称:qutebrowser,代码行数:15,代码来源:ipc.py


示例6: _get_socketname

def _get_socketname(basedir, legacy=False):
    """Get a socketname to use."""
    if legacy or os.name == "nt":
        return _get_socketname_legacy(basedir)

    parts_to_hash = [getpass.getuser()]
    if basedir is not None:
        parts_to_hash.append(basedir)

    data_to_hash = "-".join(parts_to_hash).encode("utf-8")
    md5 = hashlib.md5(data_to_hash).hexdigest()

    target_dir = standarddir.runtime()

    parts = ["ipc"]
    parts.append(md5)
    return os.path.join(target_dir, "-".join(parts))
开发者ID:derlaft,项目名称:qutebrowser,代码行数:17,代码来源:ipc.py


示例7: _get_socketname

def _get_socketname(basedir):
    """Get a socketname to use."""
    if os.name == 'nt':  # pragma: no cover
        return _get_socketname_windows(basedir)

    parts_to_hash = [getpass.getuser()]
    if basedir is not None:
        parts_to_hash.append(basedir)

    data_to_hash = '-'.join(parts_to_hash).encode('utf-8')
    md5 = hashlib.md5(data_to_hash).hexdigest()

    target_dir = standarddir.runtime()

    parts = ['ipc']
    parts.append(md5)
    return os.path.join(target_dir, '-'.join(parts))
开发者ID:swalladge,项目名称:qutebrowser,代码行数:17,代码来源:ipc.py


示例8: _path_info

def _path_info():
    """Get info about important path names.

    Return:
        A dictionary of descriptive to actual path names.
    """
    info = {
        'config': standarddir.config(),
        'data': standarddir.data(),
        'cache': standarddir.cache(),
        'runtime': standarddir.runtime(),
    }
    if standarddir.config() != standarddir.config(auto=True):
        info['auto config'] = standarddir.config(auto=True)
    if standarddir.data() != standarddir.data(system=True):
        info['system data'] = standarddir.data(system=True)
    return info
开发者ID:nanjekyejoannah,项目名称:qutebrowser,代码行数:17,代码来源:version.py


示例9: run

    def run(self, cmd, *args, env=None, verbose=False):
        try:
            # tempfile.mktemp is deprecated and discouraged, but we use it here
            # to create a FIFO since the only other alternative would be to
            # create a directory and place the FIFO there, which sucks. Since
            # os.mkfifo will raise an exception anyways when the path doesn't
            # exist, it shouldn't be a big issue.
            self._filepath = tempfile.mktemp(prefix="qutebrowser-userscript-", dir=standarddir.runtime())
            os.mkfifo(self._filepath)  # pylint: disable=no-member
        except OSError as e:
            message.error(self._win_id, "Error while creating FIFO: {}".format(e))
            return

        self._reader = _QtFIFOReader(self._filepath)
        self._reader.got_line.connect(self.got_cmd)

        self._run_process(cmd, *args, env=env, verbose=verbose)
开发者ID:jagajaga,项目名称:qutebrowser,代码行数:17,代码来源:userscripts.py


示例10: prepare_run

    def prepare_run(self, *args, **kwargs):
        self._args = args
        self._kwargs = kwargs

        try:
            # tempfile.mktemp is deprecated and discouraged, but we use it here
            # to create a FIFO since the only other alternative would be to
            # create a directory and place the FIFO there, which sucks. Since
            # os.mkfifo will raise an exception anyways when the path doesn't
            # exist, it shouldn't be a big issue.
            self._filepath = tempfile.mktemp(prefix='qutebrowser-userscript-',
                                             dir=standarddir.runtime())
            # pylint: disable=no-member,useless-suppression
            os.mkfifo(self._filepath)
        except OSError as e:
            message.error("Error while creating FIFO: {}".format(e))
            return

        self._reader = _QtFIFOReader(self._filepath)
        self._reader.got_line.connect(self.got_cmd)
开发者ID:michaelbeaumont,项目名称:qutebrowser,代码行数:20,代码来源:userscripts.py


示例11: test_linux_invalid_runtimedir

 def test_linux_invalid_runtimedir(self, monkeypatch, tmpdir):
     """With invalid XDG_RUNTIME_DIR, fall back to TempLocation."""
     monkeypatch.setenv('XDG_RUNTIME_DIR', str(tmpdir / 'does-not-exist'))
     monkeypatch.setenv('TMPDIR', str(tmpdir / 'temp'))
     assert standarddir.runtime() == str(tmpdir / 'temp' / 'qute_test')
开发者ID:michaelbeaumont,项目名称:qutebrowser,代码行数:5,代码来源:test_standarddir.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python urlutils._get_search_url函数代码示例发布时间:2022-05-26
下一篇:
Python standarddir.init函数代码示例发布时间: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