跳转到主要内容

XRootDPyFS是XRootD的PyFilesystem接口。

项目描述

https://github.com/inveniosoftware/xrootdpyfs/actions?query=workflow%3ACI.svg?branch=master https://coveralls.io/repos/inveniosoftware/xrootdpyfs/badge.svg?branch=master https://pypip.in/v/xrootdpyfs/badge.svg

XRootDPyFS是XRootD的PyFilesystem接口。

XRootD协议旨在为多种类型的数据存储库提供高性能、可扩展的容错访问。XRootDPyFS在现有的Python接口(pyxrootd)之上添加了一个高级接口,使得例如并行复制目录或递归删除目录变得容易。

有关进一步文档,请参阅https://xrootdpyfs.readthedocs.io/

入门

如果您只想尝试这个库,使用Docker是最简单的。

构建镜像

$ docker build --platform linux/amd64 -t xrootd .

运行容器并启动xrootd

$ docker run --platform linux/amd64 -h xrootdpyfs -it xrootd bash

您将在stdout中看到日志。接下来,在另一个shell中连接容器并启动一个ipython shell

$ docker ps  # find the container id
$ docker exec -it <container-id> bash
[xrootdpyfs@xrootdpyfs code]$ ipython

快速示例

以下是一个使用xrootd PyFilesystem集成的文件列表示例

>>> from xrootdpyfs import XRootDPyFS
>>> fs = XRootDPyFS("root://localhost//tmp/")
>>> fs.listdir("xrootdpyfs")
['test.txt']

或者,使用PyFilesystem打开器(注意需要首先导入xrootdpyfs以确保XRootDPyFS打开器已注册)

>>> import xrootdpyfs
>>> from fs.opener import open_fs
>>> fs = open_fs("root://localhost//tmp/")
>>> fs.listdir("xrootdpyfs")
['test.txt']

读取文件

>>> f = fs.open("xrootdpyfs/test.txt")
>>> f.read()
b'Hello XRootD!\n'
>>> f.close()

使用 readtext() 方法读取文件

>>> fs.readtext("xrootdpyfs/test.txt")
b'Hello XRootD!\n'

写入文件

>>> f = fs.open("xrootdpyfs/hello.txt", "w+")
>>> f.write("World")
>>> f.close()

使用 writetext() 方法写入文件

>>> fs.writetext("xrootdpyfs/test.txt", "World")

开发

开发的最简单方法是构建Docker镜像,并将源代码作为卷挂载,以测试任何代码修改与正在运行的XRootD服务器

$ docker build --platform linux/amd64 -t xrootd --progress=plain .
$ docker run --platform linux/amd64 -h xrootdpyfs -it -v <absolute path to this project>:/code xrootd bash
[xrootdpyfs@xrootdpyfs code]$ xrootd

在另一个shell中

$ docker ps  # find the container id
$ docker exec -it <container-id> bash
[xrootdpyfs@xrootdpyfs code]$ python -m pytest -vvv tests

如果您想测试特定版本的xrootd,请运行

$ docker build --platform linux/amd64 --build-arg xrootd_version=4.12.7 -t xrootd --progress=plain .

文档

文档可在 <http://xrootdpyfs.readthedocs.io/> 获得,或使用Sphinx构建

pip install Sphinx
python setup.py build_sphinx

测试

使用docker运行测试最为方便

$ docker build --platform linux/amd64 -t xrootd . && docker run --platform linux/amd64 -h xrootdpyfs -it xrootd

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码发行版

xrootdpyfs-2.0.0.tar.gz (41.9 kB 查看散列值)

源代码

构建发行版

xrootdpyfs-2.0.0-py2.py3-none-any.whl (21.6 kB 查看散列值)

Python 2 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面