Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips
System : Linux server1.richineiserver.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : fdshops ( 1003)
PHP Version : 8.2.21
Disable Function : NONE
Directory :  /lib/python2.7/site-packages/offlineimap/folder/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python2.7/site-packages/offlineimap/folder/IMAP.pyc
�
��Vc@s�ddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
ddl	mZddlmZdZd	efd
��YZdS(i����N(texc_infoi(t
BaseFolder(timaputiltimaplibutilt	emailutiltOfflineImapError(tglobals(t
MonthNamess
t
IMAPFoldercBsjeZd�Zed�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d&d&d�Zd	�Z
d&d&d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd&d�Zd�Zdd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d �Z#d!�Z$d"�Z%d#�Z&d$�Z'd%�Z(RS('cCs�tj|�}|j|_tt|�j||�|j�|_d|_
||_i|_t
j�|_dg|_|jjjdd�}gtjd|�D]}|r�|^q�|_dS(NsBODY.PEEK[]t
filterheadersts\s*,\s*(RtdequotetdelimtseptsuperRt__init__t
getexpungetexpungetNonetroott
imapservertmessagelisttrandomtRandomtrandomgeneratort
imap_queryt
repositorytaccounttgetconftretsplitR	(tselfRtnameRtfh_confth((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyR+s			cCsWy|j|j�d|�Wn3|jk
rR|j|j�dtd|�nXdS(s�Select this folder when we do not need write access.

        Prefer SELECT to EXAMINE if we can, since some servers
        (Courier) do not stabilize UID validity until the folder is
        selected.
        .. todo: Still valid? Needs verification
        :param: Enforce new SELECT even if we are on that folder already.
        :returns: raises :exc:`OfflineImapError` severity FOLDER on errortforcetreadonlyN(tselecttgetfullnameR$tTrue(RtimapobjR#((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt
__selectro=s	cCstjjS(N(Rtoptionstsinglethreading(R((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytsuggeststhreadsLscCs|jj�dS(N(Rtconnectionwait(R((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt
waitforthreadPscCsH|jjd|jdd�rDtdtjj�dt�d�ndS(Ns
Account %stmaxages)maxage is not supported on IMAP-IMAP synci(tconfigt
getdefaulttaccountnameRRtERRORtREPOR(R((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt	getmaxageSscCsd|jj�S(NtMSGCOPY_(Rtgetname(R((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytgetcopyinstancelimitZscCs�t|d�r|jS|jj�}zg|j|�|jd�\}}|dgkre|dksqtd��t|d�|_|jSWd|jj	|�XdS(s�Retrieve the current connections UIDVALIDITY value

        UIDVALIDITY value will be cached on the first call.
        :returns: The UIDVALIDITY as (long) number.t_uidvaliditytUIDVALIDITYs(response('UIDVALIDITY') returned [None]!i����N(
thasattrR9Rtacquireconnectiont_IMAPFolder__selectrotresponseRtAssertionErrortlongtreleaseconnection(RR(ttyptuidval((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytget_uidvalidity^s
	c	Cst}x�|r�t}|jj�}y5|j|j�tt�\}}|jj|�Wq	tk
r�}|jj|t�|jtj	j
kr�t}q��q	|jj|t��q	Xq	W|dgkr�tSd}x#|D]}tt
|�|�}q�W||j�krtStS(Ni(R'tFalseRR<R%R&RARtseverityR3tFOLDER_RETRYRtmaxR@tgetmessagecount(	RtstatusfoldertretryR(trestypetimapdatatetmaxmsgidtmsgid((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytquickchangedts0		
c
s&���fd�}�j�j�tt�\}}|dgksU|ddkrYdSg}|dkr|jd|�n9|dkr�|jd|dt|d|df�n�j�}|dkr�|jd|�nt|�dkr"d	d
j|��|��}	t	j
|	�SdS(
sNDetermines sequence numbers of messages to be fetched.

        Message sequence numbers (MSNs) are more easily compacted
        into ranges which makes transactions slightly faster.

        Arguments:
        - imapobj: instance of IMAPlib
        - min_date (optional): a time_struct; only fetch messages newer than this
        - min_uid (optional): only fetch messages with UID >= min_uid

        This function should be called with at MOST one of min_date OR
        min_uid set but not BOTH.

        Returns: range(s) for messages or None if no messages
        are to be fetched.csc�jd|�\}}|dkrUtd�j���||ftjj��n|dj�S(s�Actually request the server with the specified conditions.

            Returns: range(s) for messages or None if no messages
            are to be fetched.tOKsRSEARCH in folder [%s]%s failed. Search string was '%s'. Server responded '[%s] %s'iN(tsearchRRt
getrepositoryR3tFOLDERR(tsearch_conditionstres_typetres_data(R(tsearch_condR(s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyRS�sit0sUID %d:*sSINCE %02d-%s-%diis
SMALLER %ds(%s)t s1:*N(R%R&R'RtappendRt
getmaxsizetlentjoinRtuid_sequence(
RR(tmin_datetmin_uidRSRWRMt
conditionstmaxsizet
search_result((R(RYRs;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt_msgs_to_fetch�s$
!	$
cCsi|d6t�d6dd6S(Ntuidtflagsittime(tset(RRg((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytmsglist_item_initializer�sc
Cs�|jj|j|�i|_|jj�}z|j|d|d|�}|sVdS|jd|d�\}}|dkr�td|j	�|||ftj
j��nWd|jj|�Xx�|D]�}|dkr�q�n|jdd�d}tj|�}d	|kr4|jjd
t|�dd�q�t|d	�}	|j|	�|j|	<tj|d�}
tj|d�}tj|�}i|	d
6|
d6|d6|d6|j|	<q�W|jj|j||j��dS(NRaRbs'%s's(FLAGS UID INTERNALDATE)RRsAFETCHING UIDs in folder [%s]%s failed. Server responded '[%s] %s'R[itUIDs!No UID in message with options %stminortFLAGSRgRhRitkeywords(tuitloadmessagelistRRRR<RftfetchRRTR3RURARRRt
flags2hashtwarntstrR@Rktflagsimap2maildirtflagsimap2keywordsRtInternaldate2epochtmessagelistloadedRI(
RRaRbR(tmsgsToFetchRWR>t
messagestrR*RgRhRotrtime((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytcachemessagelist�s@		 


cCs
i|_dS(N(R(R((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytdropmessagelistcachescCs5tt|�j�}|jj�r1tj|�S|S(N(RRtgetvisiblenameRtgetdecodefoldernamesRtdecode_mailbox_name(Rtvname((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyRs
cCs|jS(N(R(R((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytgetmessagelistscCs�|jt|�d�}|ddjtd�}t|�dkrkdt|�d t|�df}n|}|jjd	d
||f�|S(s;Retrieve message with UID from the IMAP server (incl body).

        After this function all CRLFs will be transformed to '
'.

        :returns: the message body or throws and OfflineImapError
                  (probably severity MESSAGE) if e.g. no message with
                  this UID could be found.
        iiis
i�s%s...%si�i���timaps&Returned object from fetching %d: '%s'(t_fetch_from_imapRutreplacetCRLFR^Rptdebug(RRgtdatat
dbg_output((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt
getmessages
'cCs|j|dS(NRi(R(RRg((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytgetmessagetime/scCs|j|dS(NRh(R(RRg((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytgetmessageflags3scCs|j|dS(NRo(R(RRg((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytgetmessagekeywords7scCsLd}ttj|�d@�d}|t|jjdd��7}||fS(sReturns a unique X-OfflineIMAP header

         Generate an 'X-OfflineIMAP' mail header which contains a random
         unique value (which is based on the mail content, and a random
         number). This header allows us to fetch a mail after APPENDing
         it to an IMAP server and thus find out the UID that the server
         assigned it.

        :returns: (headername, headervalue) tuple, consisting of strings
                  headername == 'X-OfflineIMAP' and headervalue will be a
                  random string
        s
X-OfflineIMAPI����t-iI��T(Rutbinasciitcrc32Rtrandint(Rtcontentt
headernametheadervalue((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt__generate_randomheader:s	cCsF|jjdd||f�|j|�}y$|jdd||�dd}Wn4|jk
r�}|jjdd||f�dSX|jjddt|��|d	kr�|jjdd
|�dS|jd�}|jjddt|��t|�dks|ddkr8t	d
|t
|�f��nt|d�S(NR�s/__savemessage_searchforheader called for %s: %sRStHEADERiisl__savemessage_searchforheader: got IMAP error '%s' while attempting to UID SEARCH for message with header %ss8__savemessage_searchforheader got initial matchinguids: R
sW__savemessage_searchforheader: UID SEARCH for message with header %s yielded no resultsR[s0__savemessage_searchforheader: matchinguids now s[While attempting to find UID for message with header %s, got wrong-sized matchinguids of %s(RpR�t_quoteRgterrortreprRR^Rt
ValueErrorRuR@(RR(R�R�tmatchinguidsterr((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt__savemessage_searchforheaderVs("c	Cs�|jjdd||f�|j�rHdt|j�j��}nd}|jdtd|�d�}|ddkr�td	d
j|d�tj	j
��n|d}d}x�|D]�}|dkrt|�td�krtj
d||f|ddtj�r�d}q�q�|dkr�t|�td
�kr�tj
d|dtj�}|rtt|jd��S|jjd|j��q�|jjd|j��q�q�WdS(sg We fetch all new mail headers and search for the right
        X-OfflineImap line by hand. The response from the server has form:
        (
          'OK',
          [
            (
              '185 (RFC822.HEADER {1789}',
              '... mail headers ...'
            ),
            ' UID 2444)',
            (
              '186 (RFC822.HEADER {1789}',
              '... 2nd mail headers ...'
            ),
            ' UID 2445)'
          ]
        )
        We need to locate the UID just after mail headers containing our
        X-OfflineIMAP line.

        Returns UID when found, 0 when not found.R�s,__savemessage_fetchheaders called for %s: %sitFETCHs%d:*s
rfc822.headeriRRsError fetching mail headers: %ss. s(?:^|\r|\n)%s:\s*%s(?:\r|\n)RhR
sUID\s+(\d+)s.Can't parse FETCH response, can't find UID: %ss1Can't parse FETCH response, we awaited string: %s((RpR�R�RHtkeysRgt	bytearrayRR_R3tMESSAGEttypeRRSt
IGNORECASEtinttgroupRtt__repr__(	RR(R�R�tstarttresulttfoundtitemRg((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt__savemessage_fetchheadersqs0	#

$ c
	Cs�|dkr.tj|�}|dkr.dSntj|�}yR|ddkrYt�ntjtj|��}|d |d kr�t�nWn/ttfk
r�|jj	dd|�dSXidd6dd6d	d
6dd6d
d6dd6dd6dd6dd6dd6dd6dd6}|j
dkr7tj}n
tj}t
|dd�\}}d|j||j|j|j|j|j||f}	|	S( skParses mail and returns an INTERNALDATE string

        It will use information in the following order, falling back as an
        attempt fails:
          - rtime parameter
          - Date header of email

        We return None, if we couldn't find a valid date. In this case
        the IMAP server will use the server local time when appening
        (per RFC).

        Note, that imaplib's Time2Internaldate is inherently broken as
        it returns localized date strings which are invalid for IMAP
        servers. However, that function is called for *every* append()
        internally. So we need to either pass in `None` or the correct
        string (in which case Time2Internaldate() will do nothing) to
        append(). The output of this function is designed to work as
        input to the imapobj.append() function.

        TODO: We should probably be returning a bytearray rather than a
        string here, because the IMAP server will expect plain
        ASCII. However, imaplib.Time2INternaldate currently returns a
        string so we go with the same for now.

        :param rtime: epoch timestamp to be used rather than analyzing
                  the email.
        :returns: string in the form of "DD-Mmm-YYYY HH:MM:SS +HHMM"
                  (including double quotes) or `None` in case of failure
                  (which is fine as value for append).ii�iR�s9Message with invalid date %s. Server will use local time.tJanitFebtMaritApritMayitJunitJulitAugitSepi	tOcti
tNovitDecii<s'"%02d-%s-%04d %02d:%02d:%02d %+03d%02d"N(RRtget_message_dateRit	localtimeR�tmktimet
OverflowErrorRpR�ttm_isdsttaltzonettimezonetdivmodttm_mdayttm_monttm_yearttm_hourttm_minttm_sec(
RR�R|t	datetupletdatetuple_checktnum2montzonetoffset_htoffset_mtinternaldate((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt__getmessageinternaldate�s2	
--

cCs�|jjd|||�|dkrH|j|�rH|j||�|S|j||j�}tjdt|�}|j	||�}|j
|d�}|s�d}nd}|jj�}z�x�|rUd|j
k}	|	s(|j|�\}
}|jjdd|
|f�|j|t|
|�}nt|�d	krUd
|d |df}n|}|jjdd
||f�y|j|j��Wn.|jk
r�|jj||||�|SXyz|j|j�tj|�||�\}
}|
dkr3d|||j�|
|f}t|tjj��nd}Wq�|jk
r�}|d8}|jj|t�|jj�}|s�td|||j�t |�|ftjj!�dt#�d�n|jj$|t#�d�q�|j$k
rQ}|jj|t�d}td|||j�t |�|ftjj!�dt#�d�q�Xq�W|j%�\}
}|
dkszt&�|	r|j'd�}|dgks�|dkr�|jj(d�dSt)|dj*d�d�}|dkrf|jj(dt |��qfn_|j+||
|�}|dkrf|jjdd�|j,||
|�}|jj(dd�nWd|r�|jj|�nX|r�|j-|�|j.|<||j.|d<n|jjdd|�|S(sSave the message on the Server

        This backend always assigns a new uid, so the uid arg is ignored.

        This function will update the self.messagelist dict to contain
        the new message after sucessfully saving it.

        See folder/Base for details. Note that savemessage() does not
        check against dryrun settings, so you need to ensure that
        savemessage is never called in a dryrun mode.

        :param rtime: A timestamp to be used as the mail date
        :returns: the UID of the new message as assigned by the server. If the
                  message is saved, but it's UID can not be found, it will
                  return 0. If the message can't be written (folder is
                  read-only for example) it will return -1.R�is(?<!
)
s
message-ids[unknown message-id]itUIDPLUSssavemessage: header is: %s: %si�s%s...%si�i���s$savemessage: date: %s, content: '%s'RRsXSaving msg (%s) in folder '%s', repository '%s' failed (abort). Server responded: %s %s
islSaving msg (%s) in folder '%s', repository '%s' failed (abort). Server responded: %s
Message content was: %ssbSaving msg (%s) folder '%s', repo '%s'failed (error). Server responded: %s
Message content was: %st	APPENDUIDsAServer supports UIDPLUS but got no APPENDUID appending a message.i����R[s_savemessage: Server supports UIDPLUS, but we got no usable uid back. APPENDUID reponse was '%s'sHsavemessage: attempt to get new UID UID failed. Search headers manually.sTsavemessage: Searching mails for new Message-ID failed. Could not determine new UID.NRhs!savemessage: returning new UID %d(/Rptsavemessaget	uidexiststsavemessageflagstdeletemessageheadersR	RtsubR�t#_IMAPFolder__getmessageinternaldatetgetmessageheaderRR<tcapabilitiest"_IMAPFolder__generate_randomheaderR�taddmessageheaderR^R%R&R$t
msgtoreadonlyR\Rtflagsmaildir2imapRTRR3R4tabortRAR'RuR�RRR�tcheckR?t_get_untagged_responseRtR@Rt(_IMAPFolder__savemessage_searchforheadert%_IMAPFolder__savemessage_fetchheadersRkR(RRgR�RhR|tdatetmsg_idt
retry_leftR(tuse_uidplusR�R�R�RBtdattmsgRNtresp((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyR�s�		

$		icCs�|jj�}zddj|j�}|}x�|r+y9|j|j�dt�|jd||�\}}PWq1|jk
r'}|d8}|dkr�d|||j	|f}	t
jj}
t
|	t
jj��n|jj
|t�|jj�}|jjd|||j	|||f�q1Xq1WWd	|jj
|�X|d	gks\|d
kr�t
jj}
d|j�|||f}|d	gkr�d|j�|f}nt
||
��n|S(
s�Fetches data from IMAP server.

        Arguments:
        - imapobj: IMAPlib object
        - uids: message UIDS
        - retry_num: number of retries to make

        Returns: data obtained by this query.s(%s)R[R$Rriis>%s, while fetching msg %r in folder %r. Max retry reached (%d)s8%s. While fetching msg %r in folder %r. Retrying (%d/%d)NRRsJIMAP server '%s' failed to fetch messages UID '%s'.Server responded: %s %ss6IMAP server '%s' does not have a message with UID '%s'(RR<R_RR%R&R'RgR�R RR3R�RARpR�RRT(Rtuidst	retry_numR(tqueryt
fails_leftRWR�RNtmessageRFtreason((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyR��s@
	
*
c	Cs�|j|j��|jd|||�\}}|dkrztjj}d|j�||||f}t||��n|dS(s�Stores data to IMAP server

        Arguments:
        - imapobj: instance of IMAPlib to use
        - uid: message UID
        - field: field name to be stored/updated
        - data: field contents
        tstoreRRsPIMAP server '%s' failed to store %s for message UID '%d'.Server responded: %s %si(R%R&RgRR3R�RT(	RR(RgtfieldR�RWtretdataRFR�((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt_store_to_imap�s	cCs�|jj�}z`y+|j|t|�dtj|��}Wn.|jk
rm|jj||g|�dSXWd|jj	|�X|s�||j
|d<n:tjtj|�d�d}tj
|�|j
|d<dS(s�Change a message's flags to `flags`.

        Note that this function does not check against dryrun settings,
        so you need to ensure that it is never called in a
        dryrun mode.RnNRhi(RR<R�RuRR�R$RptflagstoreadonlyRARRst	imapsplitRv(RRgRhR(R�((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyR��s	 cCs|j|g|�dS(N(taddmessagesflags(RRgRh((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytaddmessageflagsscCs|jd||�dS(Nt+(t!_IMAPFolder__processmessagesflags(RtuidlistRh((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt__addmessagesflags_noconvertscCs|j||�dS(s�This is here for the sake of UIDMaps.py -- deletemessages must
        add flags and get a converted UID, and if we don't have noconvert,
        then UIDMaps will try to convert it twice.N(t'_IMAPFolder__addmessagesflags_noconvert(RR�Rh((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyR�scCs|j|g|�dS(N(tdeletemessagesflags(RRgRh((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytdeletemessageflagsscCs|jd||�dS(NR�(R�(RR�Rh((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyR�scCs�|jj�}z�y|j|j��Wn+|jk
rV|jj|||�dSX|jdtj	|�|dtj
|��}|ddks�tddj|d���|d}Wd|jj
|�Xt|�}x�|D]�}|dkr�q�ntjtj|�d�}d|ko-d|ks6q�n|d}	t|d�}
tj|	�|j|
d	<y|j|
�Wq�tk
r�q�Xq�WxZ|D]R}
|d
kr�|j|
d	c|O<q�|dkr�|j|
d	c|8<q�q�WdS(NR�RniRRsError with store: s. iRlRhR�R�(RR<R%R&R$RpR�RgRR`R�R?R_RAtlistRRsR�R@RvRtremoveR�(Rt	operationR�RhR(trt
needupdateR�t
attributehashtflagstrRg((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt__processmessagesflags_real!s@	-



cCsKd}x>tdt|�|�D]$}|j|||||!|�qWdS(Nidi(txrangeR^t&_IMAPFolder__processmessagesflags_real(RRR�Rht
batch_sizeti((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt__processmessagesflagsKs
	cCs#td||ftjj��dS(syChange the message from existing uid to new_uid

        If the backend supports it. IMAP does not and will throw errors.s7IMAP backend cannot change a messages UID from %d to %dN(RR3R�(RRgtnew_uid((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytchange_message_uidUscCs|j|g�dS(N(t%_IMAPFolder__deletemessages_noconvert(RRg((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt
deletemessage^scCs|j|�dS(N(R
(RR�((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pytdeletemessagesbscCs�t|�sdS|j|td��|jj�}zny|j|j��Wn(|jk
ry|jj	||�dSX|j
r�|j
�ddks�t�nWd|jj|�Xx|D]}|j
|=q�WdS(NtTiRR(R^R�RjRR<R%R&R$RptdeletereadonlyRR?RAR(RR�R(Rg((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt__deletemessages_noconvertes	#
N()t__name__t
__module__RRER=R,R.R5R8RDRQRRfRkR}R~RR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RR�RRRR
(((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyR*sJ							%;	+										EL	�8								*	
				(RR�RtosRitsysRtBaseRtofflineimapRRRRRtofflineimap.imaplib2RR�R(((s;/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.pyt<module>s"

Spamworldpro Mini