Package: managesieve3
OverviewA pure Python client implementation of “A Protocol for Remotely
Managing Sieve Scripts”, as defined inRFC-5804.  It works with either Python
2.7 or Python 3.3+.Module Contentsclass ManagesieveThe main class for interactive with sieve server.Here are the members of theManagesiveclass.  All of these methods
may raise aServerResponseNoorServerResponseByeexception.  See
RFC-5804 for details on whenNOorBYEis returned by the server.Managesieve(host=None, port=None)IfhostisNone, it defaults to ‘localhost’.  Ifportis
None, it defaults to 4190.  The connection to the server is
immediately made.  This method may raise any exception raised by
thesocketmodule.cmd_authenticate(auth_type, options=None)Send anAUTHENTICATIONrequest to the sieve server, along with
the speficied options, any.  On success, returns None.  If the
authentication fails, aServerResponseNoexception is raised.cmd_capability()Send aCAPABILITYrequest to the sieve server.  Returns a list of
tuples, one per capability returned by the server.cmd_checkscript(contents)Send aCHECKSCRIPTrequest to the sieve server.  If the contents
of the script are valid, returnsNone.  Otherwise, aServerResponseNoexception is raised.cmd_deletescript(name)Send aDELETESCRIPTrequest to the sieve server.  The scriptnameis deleted.  ReturnsNoneon success.  Raises aServerResponseNoif the script cannot be deleted (for example, if
it does not exist or is the currently active script).cmd_getscript(name)Send aGETSCRIPTrequest to the sieve server.  On success, the
contents script namednameis returned.  On error (for example,
if the script does not exist), aServerResponseNoexception is
raised.cmd_havespace(name, size)Send aHAVESPACErequest to the sieve server.nameis the name
of a possibly non-existent script, andsizea size, in bytes.  If
the server is willing to store a script namednameof sizesize, thenNoneis returned.  Otherwise, aServerResponseNoexception is raised.cmd_listscripts()Send aLISTSCRIPTrequest 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 isNone.cmd_logout()Send aLOGOUTrequest to the sieve server.  The user is logged
out, and on successNoneis returned.cmd_noop()Send aNOOPrequest to the sieve server.  This is a protocol
no-op, and may be used to keep the connection alive.Noneis
returned.cmd_putscript(name, contents)Send aPUTSCRIPTrequest to the sieve server.  A script with namenameand contents specified bycontentsis stored on the
server.  On success,Noneis returned.  If an error occurs,
including the script contents being invalid, aServerResponseNoexception is raised.  Note that putting a script to the server does
not change the currently active script.cmd_renamescript(oldname, newname)Send aRENAMESCRIPTrequest to the sieve server.  The script
namedoldnameis renamed tonewname.Noneis returned on
success.cmd_setactive(name)Send aSETACTIVErequest to the sieve server.  The script namednameis set as the active script.  ReturnsNoneon success.cmd_starttls(keyfile=None, certfile=None, cert_reqs=_ssl.CERT_NONE, ssl_version=_ssl.PROTOCOL_SSLv23, ca_certs=None, ciphers=None)Send aSTARTTLSrequest to the sieve server.keyfileandcertfileare currently ignored.  On success, the conenction to
the sieve server is now encrypted.  The return value is the same ascmd_capabilities, which may have changed since the connection was
first opened.Thekeyfile,certfile,cert_reqs,ssl_version,ca_certs,
andcipherparameters have the same meaning as (and are passed
directly to)ssl.wrap_socket.login_plain(username, authuser, password)Logs on to the sieve server, using thePLAINauthentication
scheme.usernameis the user whose account will be accessed.authuseris the name of the user being authenticated, andpasswordis that password forauthuser.ExceptionsBaseExceptionThe base class for all exceptions raised by managesieve3.ServerResponseNoThe sieve server sent an unexpectedNOresponse.  See RFC-5804 for
details.Available fields are:NameDescriptionnameThe 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.ServerResponseByeThe sieve server sent aBYEresponse.  See RFC-5804 for details.Available fields are:NameDescriptionnameThe 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.ServerProtocolErrorThe client code detected a protocol error when talking to the sieve
server.Change log1.1 2016-10-27 Eric V. SmithRemove hack for setting RPM name (issue #4).Always use setuptools (issue #3).Add additional ssl.wrap_socket() parameters to starttls().1.0 2015-06-02 Eric V. SmithInitial release.Implements all RFC-5804 commands.Contains an extensive test suite for command parsing. I really need
to create a dummy server to test the socket handling and STARTTLS.