ensure yahoo imap compatibility
This commit is contained in:
parent
8d502134c0
commit
14424f3d3d
53
impra/cli.py
53
impra/cli.py
|
@ -711,12 +711,19 @@ class Cli:
|
|||
Clz.print('{', Clz.fgB1, False)
|
||||
Clz.print('name', Clz.fgB1, False)
|
||||
Clz.print('}', Clz.fgB1, False)
|
||||
Clz.print(', -M ', Clz.fgB3, False)
|
||||
Clz.print(', \\', Clz.fgB3)
|
||||
|
||||
Clz.print(' '*37, Clz.fgb7, False)
|
||||
Clz.print('-M ', Clz.fgB3, False)
|
||||
Clz.print('{', Clz.fgB1, False)
|
||||
Clz.print('name', Clz.fgB1, False)
|
||||
Clz.print('user', Clz.fgB1, False)
|
||||
Clz.print('} {', Clz.fgB1, False)
|
||||
Clz.print('pass', Clz.fgB1, False)
|
||||
Clz.print('}', Clz.fgB1, False)
|
||||
Clz.print(', -R ', Clz.fgB3, False)
|
||||
Clz.print('{', Clz.fgB1, False)
|
||||
Clz.print('user', Clz.fgB1, False)
|
||||
Clz.print('}', Clz.fgB1, False)
|
||||
Clz.print(' ]', Clz.fgB3)
|
||||
|
||||
def print_options(self):
|
||||
|
@ -784,7 +791,7 @@ class Cli:
|
|||
|
||||
Clz.print(' '*4+'-S ' , Clz.fgB3, False)
|
||||
Clz.print('PROFILE'.ljust(10,' ') , Clz.fgB1, False)
|
||||
Clz.print(', --order'.ljust(18,' ') , Clz.fgB3, False)
|
||||
Clz.print(', --save'.ljust(18,' ') , Clz.fgB3, False)
|
||||
Clz.print('PROFILE'.ljust(10,' ') , Clz.fgB1)
|
||||
Clz.print(' '*50+'save the specified profile' , Clz.fgB7)
|
||||
|
||||
|
@ -830,9 +837,20 @@ class Cli:
|
|||
Clz.print('BOXNAME'.ljust(10,' ') , Clz.fgB1, False)
|
||||
Clz.print(', --set-box'.ljust(18,' ') , Clz.fgB3, False)
|
||||
Clz.print('BOXNAME'.ljust(10,' ') , Clz.fgB1)
|
||||
|
||||
Clz.print(' '*50+'set imap boxname (default:__impra__)' , Clz.fgB7)
|
||||
|
||||
Clz.print(' '*4+'-M ' , Clz.fgB3, False)
|
||||
Clz.print('USER PASS'.ljust(10,' ') , Clz.fgB1, False)
|
||||
Clz.print(', --set-multi'.ljust(18,' ') , Clz.fgB3, False)
|
||||
Clz.print('USER PASS'.ljust(10,' ') , Clz.fgB1)
|
||||
Clz.print(' '*50+'add imap multi account' , Clz.fgB7)
|
||||
|
||||
Clz.print(' '*4+'-R ' , Clz.fgB3, False)
|
||||
Clz.print('USER'.ljust(10,' ') , Clz.fgB1, False)
|
||||
Clz.print(', --remove-multi'.ljust(18,' ') , Clz.fgB3, False)
|
||||
Clz.print('USER'.ljust(10,' ') , Clz.fgB1)
|
||||
Clz.print(' '*50+'remove imap multi account' , Clz.fgB7)
|
||||
|
||||
print('\n')
|
||||
|
||||
|
||||
|
@ -1060,10 +1078,11 @@ class Cli:
|
|||
Clz.print('-L ', Clz.fgB3, False)
|
||||
Clz.print('bobimap ', Clz.fgB1)
|
||||
|
||||
Clz.print(' '*8+'# view config current profile',Clz.fgn7)
|
||||
Clz.print(' '*8+'# list all config profile',Clz.fgn7)
|
||||
Clz.print(' '*8+'imprastorage ', Clz.fgB7, False)
|
||||
Clz.print('conf ', Clz.fgB3, False)
|
||||
Clz.print('-V', Clz.fgB3)
|
||||
Clz.print('-V ', Clz.fgB3, False)
|
||||
Clz.print('all ', Clz.fgB1)
|
||||
|
||||
Clz.print(' '*8+'# view config profile bobgmail (current profile doesn\'t change)',Clz.fgn7)
|
||||
Clz.print(' '*8+'imprastorage ', Clz.fgB7, False)
|
||||
|
@ -1071,12 +1090,6 @@ class Cli:
|
|||
Clz.print('-V ', Clz.fgB3, False)
|
||||
Clz.print('bobgmail ', Clz.fgB1)
|
||||
|
||||
Clz.print(' '*8+'# generate a new Key for current profile (carreful with this command if your account has no empty index - ',Clz.fgn7)
|
||||
Clz.print(' '*8+'# all files will be unrecoverable without the appropriate key)',Clz.fgn7)
|
||||
Clz.print(' '*8+'imprastorage ', Clz.fgB7, False)
|
||||
Clz.print('conf ', Clz.fgB3, False)
|
||||
Clz.print('-S -K', Clz.fgB3)
|
||||
|
||||
Clz.print(' '*8+'# generate a new Key for profile bobgmail and set it as current profile (carreful with this command ',Clz.fgn7)
|
||||
Clz.print(' '*8+'# if your account has no empty index - all files will be unrecoverable without the appropriate key)',Clz.fgn7)
|
||||
Clz.print(' '*8+'imprastorage ', Clz.fgB7, False)
|
||||
|
@ -1085,6 +1098,22 @@ class Cli:
|
|||
Clz.print('bobgmail ', Clz.fgB1, False)
|
||||
Clz.print('-K ', Clz.fgB3)
|
||||
|
||||
Clz.print(' '*8+'# add multi account to profile bobgmail (accounts must be on same host)',Clz.fgn7)
|
||||
Clz.print(' '*8+'imprastorage ', Clz.fgB7, False)
|
||||
Clz.print('conf ', Clz.fgB3, False)
|
||||
Clz.print('-S ', Clz.fgB3, False)
|
||||
Clz.print('bobgmail ', Clz.fgB1, False)
|
||||
Clz.print('-M ', Clz.fgB3, False)
|
||||
Clz.print('bob23 passbob23', Clz.fgB1)
|
||||
|
||||
Clz.print(' '*8+'# remove multi account to profile bobgmail',Clz.fgn7)
|
||||
Clz.print(' '*8+'imprastorage ', Clz.fgB7, False)
|
||||
Clz.print('conf ', Clz.fgB3, False)
|
||||
Clz.print('-S ', Clz.fgB3, False)
|
||||
Clz.print('bobgmail ', Clz.fgB1, False)
|
||||
Clz.print('-R ', Clz.fgB3, False)
|
||||
Clz.print('bob23', Clz.fgB1)
|
||||
|
||||
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
|
||||
print()
|
||||
|
||||
|
|
|
@ -285,7 +285,10 @@ class ImpraIndex:
|
|||
self.id = 1
|
||||
else :
|
||||
self.dic = self.decrypt(encdata)
|
||||
self.id = max([self.dic[k][self.UID] for i, k in enumerate(self.dic) if not k.startswith(self.SEP_KEY_INTERN)])+1
|
||||
l = [self.dic[k][self.UID] for i, k in enumerate(self.dic) if not k.startswith(self.SEP_KEY_INTERN)]
|
||||
if len(l) > 0 :
|
||||
self.id = max(l)+1
|
||||
else: self.id = 1
|
||||
for k in dicCategory :
|
||||
if k == "users" :
|
||||
for k1 in dicCategory[k]:
|
||||
|
@ -425,6 +428,7 @@ class ImpraIndex:
|
|||
r = [k for i, k in enumerate(self.dic) if not k.startswith(self.SEP_KEY_INTERN)]
|
||||
l = [(k,self.dic[k][self.UID]) for k in r]
|
||||
l2 = [k[1] for k in l]
|
||||
if len(l2)> 0 :
|
||||
mxid = max(l2)
|
||||
import collections
|
||||
l3 = [x for x, y in collections.Counter(l2).items() if y > 1]
|
||||
|
@ -437,6 +441,9 @@ class ImpraIndex:
|
|||
print(t)
|
||||
self.dic[k] = tuple(t)
|
||||
self.id = mxid+1
|
||||
else:
|
||||
self.id = 1
|
||||
d = ()
|
||||
rt.stop()
|
||||
return len(d)>0
|
||||
|
||||
|
@ -711,8 +718,12 @@ class ImpraStorage:
|
|||
""""""
|
||||
from impra.util import DEBUG, DEBUG_LEVEL, DEBUG_NOTICE, DEBUG_WARN, DEBUG_INFO
|
||||
rt = RuTime(eval(__CALLER__()),DEBUG_INFO)
|
||||
try:
|
||||
if self.idx != None :
|
||||
self.ih.delete(self.idx, True)
|
||||
except Exception as e :
|
||||
print('error : ')
|
||||
print(e)
|
||||
#~ if len(self.delids) > 0 :
|
||||
#~ for i in self.delids : self.ih.delete(i, True, False)
|
||||
#~ Clz.print('\n expunge, waiting server...\n', Clz.fgB1)
|
||||
|
@ -784,7 +795,7 @@ class ImpraStorage:
|
|||
self.switchFileAccount()
|
||||
|
||||
_, ext = splitext(path)
|
||||
try:
|
||||
#~ try:
|
||||
size = getsize(path)
|
||||
if size > 0 :
|
||||
md5 = hash_sha256_file(path)
|
||||
|
@ -823,6 +834,7 @@ class ImpraStorage:
|
|||
msg = self.mb.build(usr,'all',hlst['head'][2],self.fsplit.DIR_OUTBOX+row[1]+'.ipr')
|
||||
mid = self.ih.send(msg.as_string(), self.rootBox)
|
||||
if mid is not None :
|
||||
#sleep(0.5)
|
||||
# dont remove
|
||||
status, resp = self.ih.fetch(mid[1],'(UID BODYSTRUCTURE)', True)
|
||||
if status == self.ih.OK:
|
||||
|
@ -838,16 +850,20 @@ class ImpraStorage:
|
|||
if not cancel :
|
||||
|
||||
diff = self.checkSendIds(sendIds,hlst['head'][2])
|
||||
for mid in diff :
|
||||
if mid > 0:
|
||||
print(mid)
|
||||
#~ print('diff')
|
||||
#~ for mid in diff :
|
||||
#~ if mid > 0:
|
||||
#~ print(mid)
|
||||
#self.ih.delete(str(mid), True, False)
|
||||
if len(diff) > 0 :
|
||||
Clz.print(' error when sending, missing parts :', Clz.fgB1)
|
||||
for mid in diff :
|
||||
status, resp = self.ih.fetch(str(mid),'(UID BODYSTRUCTURE)', True)
|
||||
if not status == self.ih.OK:
|
||||
Clz.print(' error when sending, missing parts :', Clz.fgB1)
|
||||
# bugfix mid would be without +1
|
||||
k = [ k for k in sendIds if len(k)>0 and int(k[0]) == int(mid+1)]
|
||||
if len(k) > 0 :
|
||||
print(k)
|
||||
row = k[0][1]
|
||||
msg = self.mb.build(usr,'all',hlst['head'][2],self.fsplit.DIR_OUTBOX+row[1]+'.ipr')
|
||||
Clz.print(' resending part ' , Clz.fgn7, False)
|
||||
|
@ -881,9 +897,9 @@ class ImpraStorage:
|
|||
Clz.print(' == files is empty or don\t exists == ' , Clz.bg1+Clz.fgN7)
|
||||
print()
|
||||
|
||||
except Exception as e :
|
||||
print('Erroreuh')
|
||||
print(e)
|
||||
#~ except Exception as e :
|
||||
#~ print('Erroreuh')
|
||||
#~ print(e)
|
||||
self._setIndexImap()
|
||||
rt.stop()
|
||||
return done
|
||||
|
|
|
@ -164,13 +164,17 @@ class ImapHelper:
|
|||
BOX_BIN = '[Gmail]/Corbeille'
|
||||
""""""
|
||||
|
||||
def __init__(self, conf, box='INBOX'):
|
||||
def __init__(self, conf, box='INBOX', boxBin=None):
|
||||
""""""
|
||||
rt = RuTime(eval(__CALLER__('conf,"'+box+'"')))
|
||||
rt = RuTime(eval(__CALLER__('conf,"'+str(box)+'"')))
|
||||
self.srv = IMAP4_SSL(conf.host,conf.port)
|
||||
self.conf = conf
|
||||
self.srv.login(conf.user,conf.pwd)
|
||||
status, resp = self.srv.login(conf.user,conf.pwd)
|
||||
self.rootBox = box
|
||||
if boxBin is None :
|
||||
if search('yahoo.com',conf.host) is not None :
|
||||
self.BOX_BIN = 'Trash'
|
||||
if box != None :
|
||||
status, resp = self.srv.select(self.rootBox)
|
||||
if status == self.KO :
|
||||
self.createBox(self.rootBox)
|
||||
|
@ -313,7 +317,7 @@ class ImapHelper:
|
|||
#~ print(type(mid))
|
||||
#~ print(mid)
|
||||
#status, resp = self.srv.store(mid, '+FLAGS', '\\Deleted')
|
||||
status, resp = self.srv.uid('store', mid, '+FLAGS', '\\Deleted' )
|
||||
status, resp = self.srv.uid('store', mid, '+FLAGS (\\Deleted)' )
|
||||
print(' ',end='')
|
||||
Clz.print(' deleting msg ',Clz.fgN7+Clz.bg1, False)
|
||||
Clz.print(str(int(mid)) ,Clz.bg1+Clz.fgB3)
|
||||
|
@ -331,9 +335,9 @@ class ImapHelper:
|
|||
status = None
|
||||
if int(mid) > 0 :
|
||||
if byUid:
|
||||
status, resp = self.srv.uid( 'store', mid, '+FLAGS', '\\Deleted' )
|
||||
status, resp = self.srv.uid( 'store', mid, '+FLAGS (\\Deleted)' )
|
||||
else :
|
||||
status, resp = self.srv.store(mid, '+FLAGS', '\\Deleted')
|
||||
status, resp = self.srv.store(mid, '+FLAGS', 'Deleted')
|
||||
Clz.print(' flag msg ' , Clz.fgn7, False)
|
||||
Clz.print(str(int(mid)), Clz.fgB1, False)
|
||||
Clz.print(' as deleted', Clz.fgn7)
|
||||
|
@ -373,7 +377,8 @@ class ImapHelper:
|
|||
if DEBUG and DEBUG_LEVEL <= DEBUG_NOTICE:
|
||||
print(status)
|
||||
print(resp)
|
||||
mid = str(resp[0],'utf-8')[11:-11].split(' ')
|
||||
m = search(b']', resp[0])
|
||||
mid = str(resp[0],'utf-8')[11:-(len(resp[0])-m.start())].split(' ')
|
||||
rt.stop()
|
||||
return mid
|
||||
|
||||
|
|
116
test.py
116
test.py
|
@ -1,116 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# #
|
||||
# software : ImpraStorage <http://imprastorage.sourceforge.net/> #
|
||||
# version : 0.4 #
|
||||
# date : 2012 #
|
||||
# licence : GPLv3.0 <http://www.gnu.org/licenses/> #
|
||||
# author : a-Sansara <http://www.a-sansara.net/> #
|
||||
# copyright : pluie.org <http://www.pluie.org/> #
|
||||
# #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
#
|
||||
# This file is part of ImpraStorage.
|
||||
#
|
||||
# ImpraStorage is free software (free as in speech) : you can redistribute it
|
||||
# and/or modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
#
|
||||
# ImpraStorage is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with ImpraStorage. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from impra.core import ImpraConf, ImpraStorage
|
||||
from impra.util import IniFile, RuTime, get_file_path, PColor
|
||||
from impra.cli import Cli
|
||||
import sys, os
|
||||
|
||||
if __name__ == '__main__':
|
||||
#~ try :
|
||||
#~ print('\033[1;30mGray like Ghost\033[1;m')
|
||||
#~ print('\033[1;31mRed like Radish\033[1;m')
|
||||
#~ print('\033[1;32mGreen like Grass\033[1;m')
|
||||
#~ print('\033[1;33mYellow like Yolk\033[1;m')
|
||||
#~ print('\033[1;34mBlue like Blood\033[1;m')
|
||||
#~ print('\033[1;35mMagenta like Mimosa\033[1;m')
|
||||
#~ print('\033[1;36mCyan like Caribbean\033[1;m')
|
||||
#~ print('\033[1;37mWhite like Whipped Cream\033[1;m')
|
||||
#~ print('\033[1;38mCrimson like Chianti\033[1;m')
|
||||
#~ print('\033[1;41mHighlighted Red like Radish\033[1;m')
|
||||
#~ print('\033[1;42mHighlighted Green like Grass\033[1;m')
|
||||
#~ print('\033[1;43mHighlighted Brown like Bear\033[1;m')
|
||||
#~ print('\033[1;44mHighlighted Blue like Blood\033[1;m')
|
||||
#~ print('\033[1;45mHighlighted Magenta like Mimosa\033[1;m')
|
||||
#~ print('\033[1;46mHighlighted Cyan like Caribbean\033[1;m')
|
||||
#~ print('\033[1;47mHighlighted Gray like Ghost\033[1;m')
|
||||
#~ print('\033[1;48mHighlighted Crimson like Chianti\033[1;m')
|
||||
from re import finditer as regfinditer
|
||||
data = ' ==> MaClasse.maMethod "mon param","other Param" '
|
||||
qp = (int(a.start()) for a in list(regfinditer('\(', data)))
|
||||
print(data)
|
||||
print([m.start() for m in regfinditer('"', data)])
|
||||
sp = [m.start() for m in regfinditer('\(', data)]
|
||||
ep = [m.start() for m in regfinditer('\)', data)]
|
||||
|
||||
Clz = PColor()
|
||||
if len(sp) > 0 :
|
||||
Clz.print(data[:sp[0]+1], Clz.fgb3, False)
|
||||
Clz.print(data[sp[0]+1:ep[0]], Clz.fgn2, False)
|
||||
Clz.print(data[ep[0]:], Clz.fgb3, False)
|
||||
else: Clz.print(data, Clz.fgb2, False)
|
||||
#~ clz.print(' -- ImpraStorage -- ',clz.BG4+clz.fgB3,False,True)
|
||||
#~ clz.print(' [',clz.fgB0,False)
|
||||
#~ clz.print('account',clz.fgB3,False)
|
||||
#~ clz.print(':',clz.fgB0,False)
|
||||
#~ clz.print('gplslot.001',clz.fgB4,False)
|
||||
#~ clz.print('] ',clz.fgB0)
|
||||
#~ print()
|
||||
#~ clz.print('color0',clz.fgb0)
|
||||
#~ clz.print('color1',clz.fgb1)
|
||||
#~ clz.print('color2',clz.fgb2)
|
||||
#~ clz.print('color3',clz.fgb3)
|
||||
#~ clz.print('color4',clz.fgb4)
|
||||
#~ clz.print('color5',clz.fgb5)
|
||||
#~ clz.print('color6',clz.fgb6)
|
||||
#~ clz.print('color7',clz.fgb7)
|
||||
#~ print()
|
||||
#~ clz.print('color0',clz.fgB0)
|
||||
#~ clz.print('color1',clz.fgB1)
|
||||
#~ clz.print('color2',clz.fgB2)
|
||||
#~ clz.print('color3',clz.fgB3)
|
||||
#~ clz.print('color4',clz.fgB4)
|
||||
#~ clz.print('color5',clz.fgB5)
|
||||
#~ clz.print('color6',clz.fgB6)
|
||||
#~ clz.print('color7',clz.fgB7)
|
||||
#~ print()
|
||||
#~ clz.print('color0',clz.bg0+clz.fgb0)
|
||||
#~ clz.print('color1',clz.bg1+clz.fgb0)
|
||||
#~ clz.print('color2',clz.bg2+clz.fgb0)
|
||||
#~ clz.print('color3',clz.bg3+clz.fgb0)
|
||||
#~ clz.print('color4',clz.bg4+clz.fgb0)
|
||||
#~ clz.print('color5',clz.bg5+clz.fgb0)
|
||||
#~ clz.print('color6',clz.bg6+clz.fgb0)
|
||||
#~ clz.print('color7',clz.bg7+clz.fgb0)
|
||||
#~ print()
|
||||
#~ clz.print('color0',clz.BG0+clz.fgB0)
|
||||
#~ clz.print('color1',clz.BG1+clz.fgB0)
|
||||
#~ clz.print('color2',clz.BG2+clz.fgB0)
|
||||
#~ clz.print('color3',clz.BG3+clz.fgB0)
|
||||
#~ clz.print('color4',clz.BG4+clz.fgB0)
|
||||
#~ clz.print('color5',clz.BG5+clz.fgB0)
|
||||
#~ clz.print('color6',clz.BG6+clz.fgB0)
|
||||
#~ clz.print('color7',clz.BG7+clz.fgB0)
|
||||
#~ print()
|
||||
#Cli(get_file_path(__file__ ))
|
||||
#os.system('echo python imprastorage data -l')
|
||||
|
||||
#~ except Exception as e :
|
||||
#~ print(e)
|
||||
|
||||
#python -O -m compileall impra/*.py
|
Loading…
Reference in New Issue
Block a user