旧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
安装
如果您错过了此文件开头的弃用通知:
- 不要将此项目用于任何新项目,请使用官方 onedrive-sdk-python 相反
它是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做 无权限安装到自定义路径中
要求
- Python 2.7 (not 3.X)
- Twisted(核心,web,至少12.2.0)
- python-onedrive