实现一个RFC-5804管理筛客户机。

managesieve3的Python项目详细描述


概述

“远程协议”的纯python客户端实现 管理筛选脚本”,如RFC-5804中所定义。它可以与任一python一起工作 2.7或python 3.3+。

模块内容

班级经理

与sieve服务器交互的主要类。

这里是managessive类的成员。所有这些方法 可能引发serverresponseNoserverresponseBye异常。见 RFC-5804了解服务器何时返回nobye的详细信息。

managesieve(主机=无,端口=无)

If host is None, it defaults to ‘localhost’. If port is None, it defaults to 4190. The connection to the server is immediately made. This method may raise any exception raised by the socket module.

cmd_authenticate(auth_type,options=none)

Send an AUTHENTICATION request to the sieve server, along with the speficied options, any. On success, returns None. If the authentication fails, a ServerResponseNo exception is raised.

cmd_capability()

Send a CAPABILITY request to the sieve server. Returns a list of tuples, one per capability returned by the server.

cmd_checkscript(内容)

Send a CHECKSCRIPT request to the sieve server. If the contents of the script are valid, returns None. Otherwise, a ServerResponseNo exception is raised.

cmd_deletescript(名称)

Send a DELETESCRIPT request to the sieve server. The script name is deleted. Returns None on success. Raises a ServerResponseNo if the script cannot be deleted (for example, if it does not exist or is the currently active script).

cmd_getscript(名称)

Send a GETSCRIPT request to the sieve server. On success, the contents script named name is returned. On error (for example, if the script does not exist), a ServerResponseNo exception is raised.

cmd_havespace(名称、大小)

Send a HAVESPACE request to the sieve server. name is the name of a possibly non-existent script, and size a size, in bytes. If the server is willing to store a script named name of size size, then None is returned. Otherwise, a ServerResponseNo exception is raised.

cmd_listscripts()

Send a LISTSCRIPT request to the sieve server. On success, a 2-tuple is returned. The first element is a set containing the names of all of the scripts on the server. If a script is active, its name is returned in the second element of the tuple. If no script is active, the second element is None.

cmd_logout()

Send a LOGOUT request to the sieve server. The user is logged out, and on success None is returned.

cmd_noop()

Send a NOOP request to the sieve server. This is a protocol no-op, and may be used to keep the connection alive. None is returned.

cmd_putscript(名称、内容)

Send a PUTSCRIPT request to the sieve server. A script with name name and contents specified by contents is stored on the server. On success, None is returned. If an error occurs, including the script contents being invalid, a ServerResponseNo exception is raised. Note that putting a script to the server does not change the currently active script.

cmd_renamescript(旧名称,新名称)

Send a RENAMESCRIPT request to the sieve server. The script named oldname is renamed to newname. None is returned on success.

cmd_setactive(名称)

Send a SETACTIVE request to the sieve server. The script named name is set as the active script. Returns None on success.

cmd_starttls(keyfile=none,certfile=none,cert_reqs=\u ssl.cert_none,ssl_version=\u ssl.protocol_sslv23,ca_certs=none,ciphers=none)

Send a STARTTLS request to the sieve server. keyfile and certfile are currently ignored. On success, the conenction to the sieve server is now encrypted. The return value is the same as cmd_capabilities, which may have changed since the connection was first opened.

The keyfile, certfile, cert_reqs, ssl_version, ca_certs, and cipher parameters have the same meaning as (and are passed directly to) ssl.wrap_socket.

login_plain(用户名、身份验证用户、密码)

Logs on to the sieve server, using the PLAIN authentication scheme. username is the user whose account will be accessed. authuser is the name of the user being authenticated, and password is that password for authuser.

异常

基本异常

managesive3引发的所有异常的基类。

服务器响应no

sieve服务器发送了意外的no响应。见RFC-5804 细节。

可用字段为:

NameDescription
nameThe name of the RFC-5804 command that was being executed when the server returned a NO response.
codeThe code returned in the NO response. This is a list (possibly of length 1) of the heirarchical response codes.
textThe human readable text error message, if any.
resultsThe textual body of the response, if any.

服务器响应页

sieve服务器发送了一个bye响应。详见RFC-5804。

可用字段为:

NameDescription
nameThe name of the RFC-5804 command that was being executed when the server returned a BYE response.
codeThe code returned in the BYE response. This is a list (possibly of length 1) of the heirarchical response codes.
textThe human readable text error message, if any.
resultsThe textual body of the response, if any.

服务器协议错误

客户端代码在与sieve对话时检测到协议错误 服务器。

更改日志

1.1 2016年10月27日Eric V.Smith

  • 删除设置RPM名称的黑客程序(问题4)。
  • 始终使用设置工具(第3期)。
  • 将其他ssl.wrap_socket()参数添加到starttls()中。

1.0 2015-06-02埃里克v.史密斯

  • 初次发布。
  • 执行所有RFC-5804命令。
  • 包含用于命令分析的扩展测试套件。我真的需要 创建一个虚拟服务器来测试套接字处理和starttls。

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

推荐PyPI第三方库


热门话题
java如何在表被注释到配置之前获取表的元数据?   java滚动条不会出现在JList上   java JOGL监视器GPU内存   java为什么要使用RecyclerView onDraw延迟   java定制Oppo Reno 2 Z CPH1951(手机型号)的固件(闪存文件)   java自定义线程池执行器   java如何解决发布版本中重复的jar条目[com/安卓/volley/R.class]?   java如何使用Bukkit API触发事件?   java在blazemeter jmeter RTE插件中使用ctrl+w输入   C#/Visual Studio的java JDT等价物   java为什么当maxread值很大而收到的消息数量很小时,卡夫卡消费者会无限期消费?   java游戏2。x:包含模板列表的绑定模型   带压缩的java日志旋转   运行时。exec用java运行程序读取它正在做什么