旧ms onedrive api中过时的基于twisted的python异步接口

txOneDrive的Python项目详细描述


txonedrive

deprecation注意:此模块使用过时的api,而不是 保养一段时间,用正式的 onedrive-sdk-python 模块或其他构建在上面的东西。

基于twisted的python异步接口,用于OneDrive API (version 5.0) (以前称为SkyDrive)。

api与 python-onedrive模块 (txonedriveapi类映射到onedriveapiwrapper,txonedrive映射到 onedriveapi)-方法直接从那里的类中重用,因此 有关这些的信息可以在那个项目中找到

与同步python onedrive模块的主要区别在于 方法按事件运行的计划返回twisted延迟对象 循环,允许运行多个操作(如大文件上载) 在一个python进程中并发。

该服务在2014年2月19日之前被称为SkyDrive,当时它被重命名为 一个驱动器这个包同样从txskydrive重命名为txonedrive。

用法示例

以下脚本将打印根OneDrive文件夹的列表,上载 “test.txt”文件,尝试在更新的文件夹列表中找到它,然后 把它取下来。

from twisted.internet import defer, reactor
from txonedrive.api_v5 import txOneDrivePersistent

@defer.inlineCallbacks
def do_stuff():
    api = txOneDrivePersistent.from_conf()

    # Print root directory ("me/skydrive") listing
    print list(e['name'] for e in (yield api.listdir()))

    # Upload "test.txt" file from local current directory
    file_info = yield api.put('test.txt')

    # Find just-uploaded "test.txt" file by name
    file_id = yield api.resolve_path('test.txt')

    # Check that id matches uploaded file
    assert file_info['id'] == file_id

    # Remove the file
    yield api.delete(file_id)

do_stuff().addCallback(lambda ignored: reactor.stop())
reactor.run()

注意,txonedriveapipersistent便利类使用Microsoft 来自“~/.lcrc”文件的LiveConnect身份验证数据,该文件必须 按照更详细的描述创建in python-onedrive docs

安装

如果您错过了此文件开头的弃用通知:

它是Python2.7(而不是3.X)的常规包

使用pip是最好的方法:

% pip install txonedrive

如果没有,请使用:

% easy_install pip
% pip install txonedrive

或者(see also):

% curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
% pip install txonedrive

或者,如果您必须这样做:

% easy_install txonedrive

但是,你真的不应该这么做

当前的git版本可以如下安装:

% pip install 'git+https://github.com/mk-fg/txonedrive.git#egg=txonedrive'

注意,要在系统范围的路径和站点包中安装内容, 通常需要提升权限。使用“install–user”, ~/.pydistutils.cfg 或者virtualenv做 无权限安装到自定义路径中

要求

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Spring安全编程授权   java Android库AAR取决于另一个库   Java/Groovy双精度语句问题   爪哇。查看安卓监视器图形时,release()不会减少我的内存   java无法在子类中使用EventFiringWebDriver对象   java第一个if语句始终为true,但第二个if语句不为true   java如何从作为字符串提供的XML源代码创建可绘制(或XmlResourceParser对象)?   多线程Java并发问题锁和同步方法   java Android Studio注册链接   java ArrayList of ArrayList of String   使用Shadow重新定位的包中的java Kotlin属性不起作用   java在接口org上找不到方法。阿帕奇。伊巴蒂斯。遗嘱执行人。陈述名为prepare的语句处理程序   如何在Java中放大2倍?   java当参数作为RequestBody和RequestParam发送时,sprig控制器无法识别发送的请求