ensure yahoo imap compatibility
This commit is contained in:
parent
8d502134c0
commit
14424f3d3d
55
impra/cli.py
55
impra/cli.py
|
@ -711,12 +711,19 @@ class Cli:
|
||||||
Clz.print('{', Clz.fgB1, False)
|
Clz.print('{', Clz.fgB1, False)
|
||||||
Clz.print('name', Clz.fgB1, False)
|
Clz.print('name', Clz.fgB1, False)
|
||||||
Clz.print('}', 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('{', Clz.fgB1, False)
|
||||||
Clz.print('name', Clz.fgB1, False)
|
Clz.print('user', Clz.fgB1, False)
|
||||||
Clz.print('} {', Clz.fgB1, False)
|
Clz.print('} {', Clz.fgB1, False)
|
||||||
Clz.print('pass', Clz.fgB1, False)
|
Clz.print('pass', Clz.fgB1, False)
|
||||||
Clz.print('}', 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)
|
Clz.print(' ]', Clz.fgB3)
|
||||||
|
|
||||||
def print_options(self):
|
def print_options(self):
|
||||||
|
@ -784,7 +791,7 @@ class Cli:
|
||||||
|
|
||||||
Clz.print(' '*4+'-S ' , Clz.fgB3, False)
|
Clz.print(' '*4+'-S ' , Clz.fgB3, False)
|
||||||
Clz.print('PROFILE'.ljust(10,' ') , Clz.fgB1, 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('PROFILE'.ljust(10,' ') , Clz.fgB1)
|
||||||
Clz.print(' '*50+'save the specified profile' , Clz.fgB7)
|
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('BOXNAME'.ljust(10,' ') , Clz.fgB1, False)
|
||||||
Clz.print(', --set-box'.ljust(18,' ') , Clz.fgB3, False)
|
Clz.print(', --set-box'.ljust(18,' ') , Clz.fgB3, False)
|
||||||
Clz.print('BOXNAME'.ljust(10,' ') , Clz.fgB1)
|
Clz.print('BOXNAME'.ljust(10,' ') , Clz.fgB1)
|
||||||
|
|
||||||
Clz.print(' '*50+'set imap boxname (default:__impra__)' , Clz.fgB7)
|
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')
|
print('\n')
|
||||||
|
|
||||||
|
|
||||||
|
@ -1060,10 +1078,11 @@ class Cli:
|
||||||
Clz.print('-L ', Clz.fgB3, False)
|
Clz.print('-L ', Clz.fgB3, False)
|
||||||
Clz.print('bobimap ', Clz.fgB1)
|
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(' '*8+'imprastorage ', Clz.fgB7, False)
|
||||||
Clz.print('conf ', Clz.fgB3, 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+'# view config profile bobgmail (current profile doesn\'t change)',Clz.fgn7)
|
||||||
Clz.print(' '*8+'imprastorage ', Clz.fgB7, False)
|
Clz.print(' '*8+'imprastorage ', Clz.fgB7, False)
|
||||||
|
@ -1071,19 +1090,29 @@ class Cli:
|
||||||
Clz.print('-V ', Clz.fgB3, False)
|
Clz.print('-V ', Clz.fgB3, False)
|
||||||
Clz.print('bobgmail ', Clz.fgB1)
|
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+'# 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+'# 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)
|
Clz.print(' '*8+'imprastorage ', Clz.fgB7, False)
|
||||||
Clz.print('conf ', Clz.fgB3, False)
|
Clz.print('conf ', Clz.fgB3, False)
|
||||||
Clz.print('-S ', Clz.fgB3, False)
|
Clz.print('-S ', Clz.fgB3, False)
|
||||||
Clz.print('bobgmail ', Clz.fgB1, False)
|
Clz.print('bobgmail ', Clz.fgB1, False)
|
||||||
Clz.print('-K', Clz.fgB3)
|
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)
|
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
|
||||||
print()
|
print()
|
||||||
|
|
212
impra/core.py
212
impra/core.py
|
@ -285,7 +285,10 @@ class ImpraIndex:
|
||||||
self.id = 1
|
self.id = 1
|
||||||
else :
|
else :
|
||||||
self.dic = self.decrypt(encdata)
|
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 :
|
for k in dicCategory :
|
||||||
if k == "users" :
|
if k == "users" :
|
||||||
for k1 in dicCategory[k]:
|
for k1 in dicCategory[k]:
|
||||||
|
@ -425,18 +428,22 @@ class ImpraIndex:
|
||||||
r = [k for i, k in enumerate(self.dic) if not k.startswith(self.SEP_KEY_INTERN)]
|
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]
|
l = [(k,self.dic[k][self.UID]) for k in r]
|
||||||
l2 = [k[1] for k in l]
|
l2 = [k[1] for k in l]
|
||||||
mxid = max(l2)
|
if len(l2)> 0 :
|
||||||
import collections
|
mxid = max(l2)
|
||||||
l3 = [x for x, y in collections.Counter(l2).items() if y > 1]
|
import collections
|
||||||
d = [k[0] for k in l if any( k[1] == v for v in l3)]
|
l3 = [x for x, y in collections.Counter(l2).items() if y > 1]
|
||||||
for k in d:
|
d = [k[0] for k in l if any( k[1] == v for v in l3)]
|
||||||
mxid += 1
|
for k in d:
|
||||||
print(self.dic[k])
|
mxid += 1
|
||||||
t = list(self.dic[k])
|
print(self.dic[k])
|
||||||
t[self.UID] = mxid
|
t = list(self.dic[k])
|
||||||
print(t)
|
t[self.UID] = mxid
|
||||||
self.dic[k] = tuple(t)
|
print(t)
|
||||||
self.id = mxid+1
|
self.dic[k] = tuple(t)
|
||||||
|
self.id = mxid+1
|
||||||
|
else:
|
||||||
|
self.id = 1
|
||||||
|
d = ()
|
||||||
rt.stop()
|
rt.stop()
|
||||||
return len(d)>0
|
return len(d)>0
|
||||||
|
|
||||||
|
@ -711,8 +718,12 @@ class ImpraStorage:
|
||||||
""""""
|
""""""
|
||||||
from impra.util import DEBUG, DEBUG_LEVEL, DEBUG_NOTICE, DEBUG_WARN, DEBUG_INFO
|
from impra.util import DEBUG, DEBUG_LEVEL, DEBUG_NOTICE, DEBUG_WARN, DEBUG_INFO
|
||||||
rt = RuTime(eval(__CALLER__()),DEBUG_INFO)
|
rt = RuTime(eval(__CALLER__()),DEBUG_INFO)
|
||||||
if self.idx != None :
|
try:
|
||||||
self.ih.delete(self.idx, True)
|
if self.idx != None :
|
||||||
|
self.ih.delete(self.idx, True)
|
||||||
|
except Exception as e :
|
||||||
|
print('error : ')
|
||||||
|
print(e)
|
||||||
#~ if len(self.delids) > 0 :
|
#~ if len(self.delids) > 0 :
|
||||||
#~ for i in self.delids : self.ih.delete(i, True, False)
|
#~ for i in self.delids : self.ih.delete(i, True, False)
|
||||||
#~ Clz.print('\n expunge, waiting server...\n', Clz.fgB1)
|
#~ Clz.print('\n expunge, waiting server...\n', Clz.fgB1)
|
||||||
|
@ -784,106 +795,111 @@ class ImpraStorage:
|
||||||
self.switchFileAccount()
|
self.switchFileAccount()
|
||||||
|
|
||||||
_, ext = splitext(path)
|
_, ext = splitext(path)
|
||||||
try:
|
#~ try:
|
||||||
size = getsize(path)
|
size = getsize(path)
|
||||||
if size > 0 :
|
if size > 0 :
|
||||||
md5 = hash_sha256_file(path)
|
md5 = hash_sha256_file(path)
|
||||||
account = self.ih.conf.user
|
account = self.ih.conf.user
|
||||||
print()
|
print()
|
||||||
Clz.print(' account : ' , Clz.fgn7, False)
|
Clz.print(' account : ' , Clz.fgn7, False)
|
||||||
Clz.print(account , Clz.fgB7)
|
Clz.print(account , Clz.fgB7)
|
||||||
Clz.print(' file : ' , Clz.fgn7, False)
|
Clz.print(' file : ' , Clz.fgn7, False)
|
||||||
Clz.print(path , Clz.fgN1)
|
Clz.print(path , Clz.fgN1)
|
||||||
Clz.print(' hash : ' , Clz.fgn7, False)
|
Clz.print(' hash : ' , Clz.fgn7, False)
|
||||||
Clz.print(md5 , Clz.fgN2)
|
Clz.print(md5 , Clz.fgN2)
|
||||||
print()
|
print()
|
||||||
if not self.index.get(md5) :
|
if not self.index.get(md5) :
|
||||||
|
|
||||||
|
if catg=='' : catg = self.index.getAutoCatg(ext)
|
||||||
|
|
||||||
|
bFlag = ImpraIndex.FILE_BINARY
|
||||||
|
if not is_binary(path):
|
||||||
|
bFlag = ImpraIndex.FILE_CRYPT
|
||||||
|
path = self.encryptTextFile(path)
|
||||||
|
|
||||||
if catg=='' : catg = self.index.getAutoCatg(ext)
|
hlst = self.fsplit.addFile(path,md5)
|
||||||
|
if DEBUG and DEBUG_LEVEL <= DEBUG_NOTICE :
|
||||||
bFlag = ImpraIndex.FILE_BINARY
|
print(hlst['head'])
|
||||||
if not is_binary(path):
|
for v in hlst['data']:
|
||||||
bFlag = ImpraIndex.FILE_CRYPT
|
print(v)
|
||||||
path = self.encryptTextFile(path)
|
|
||||||
|
usr = self.conf.get('name','infos')
|
||||||
hlst = self.fsplit.addFile(path,md5)
|
ownerHash = self.mb.getHashName(usr)
|
||||||
if DEBUG and DEBUG_LEVEL <= DEBUG_NOTICE :
|
self.index.addUser(usr,ownerHash)
|
||||||
print(hlst['head'])
|
|
||||||
for v in hlst['data']:
|
cancel = False
|
||||||
print(v)
|
sendIds = []
|
||||||
|
test = True
|
||||||
usr = self.conf.get('name','infos')
|
for row in hlst['data'] :
|
||||||
ownerHash = self.mb.getHashName(usr)
|
msg = self.mb.build(usr,'all',hlst['head'][2],self.fsplit.DIR_OUTBOX+row[1]+'.ipr')
|
||||||
self.index.addUser(usr,ownerHash)
|
mid = self.ih.send(msg.as_string(), self.rootBox)
|
||||||
|
if mid is not None :
|
||||||
cancel = False
|
#sleep(0.5)
|
||||||
sendIds = []
|
# dont remove
|
||||||
test = True
|
status, resp = self.ih.fetch(mid[1],'(UID BODYSTRUCTURE)', True)
|
||||||
for row in hlst['data'] :
|
if status == self.ih.OK:
|
||||||
msg = self.mb.build(usr,'all',hlst['head'][2],self.fsplit.DIR_OUTBOX+row[1]+'.ipr')
|
sendIds.append((mid[1],row))
|
||||||
mid = self.ih.send(msg.as_string(), self.rootBox)
|
print(' ',end='')
|
||||||
if mid is not None :
|
Clz.print('part ' , Clz.fgn7, False)
|
||||||
# dont remove
|
Clz.print(str(row[0]) , Clz.fgB2, False)
|
||||||
status, resp = self.ih.fetch(mid[1],'(UID BODYSTRUCTURE)', True)
|
Clz.print(' sent as msg ', Clz.fgn7, False)
|
||||||
if status == self.ih.OK:
|
Clz.print(str(mid[1]) , Clz.fgB1)
|
||||||
sendIds.append((mid[1],row))
|
else:
|
||||||
print(' ',end='')
|
print('\n-- error occured when sending part : %s\n-- retrying' % row[0])
|
||||||
Clz.print('part ' , Clz.fgn7, False)
|
|
||||||
Clz.print(str(row[0]) , Clz.fgB2, False)
|
|
||||||
Clz.print(' sent as msg ', Clz.fgn7, False)
|
|
||||||
Clz.print(str(mid[1]) , Clz.fgB1)
|
|
||||||
else:
|
|
||||||
print('\n-- error occured when sending part : %s\n-- retrying' % row[0])
|
|
||||||
|
|
||||||
if not cancel :
|
if not cancel :
|
||||||
|
|
||||||
diff = self.checkSendIds(sendIds,hlst['head'][2])
|
diff = self.checkSendIds(sendIds,hlst['head'][2])
|
||||||
|
#~ print('diff')
|
||||||
|
#~ for mid in diff :
|
||||||
|
#~ if mid > 0:
|
||||||
|
#~ print(mid)
|
||||||
|
#self.ih.delete(str(mid), True, False)
|
||||||
|
if len(diff) > 0 :
|
||||||
for mid in diff :
|
for mid in diff :
|
||||||
if mid > 0:
|
status, resp = self.ih.fetch(str(mid),'(UID BODYSTRUCTURE)', True)
|
||||||
print(mid)
|
if not status == self.ih.OK:
|
||||||
#self.ih.delete(str(mid), True, False)
|
Clz.print(' error when sending, missing parts :', Clz.fgB1)
|
||||||
if len(diff) > 0 :
|
|
||||||
Clz.print(' error when sending, missing parts :', Clz.fgB1)
|
|
||||||
for mid in diff :
|
|
||||||
# bugfix mid would be without +1
|
# bugfix mid would be without +1
|
||||||
k = [ k for k in sendIds if len(k)>0 and int(k[0]) == int(mid+1)]
|
k = [ k for k in sendIds if len(k)>0 and int(k[0]) == int(mid+1)]
|
||||||
if len(k) > 0 :
|
if len(k) > 0 :
|
||||||
|
print(k)
|
||||||
row = k[0][1]
|
row = k[0][1]
|
||||||
msg = self.mb.build(usr,'all',hlst['head'][2],self.fsplit.DIR_OUTBOX+row[1]+'.ipr')
|
msg = self.mb.build(usr,'all',hlst['head'][2],self.fsplit.DIR_OUTBOX+row[1]+'.ipr')
|
||||||
Clz.print(' resending part ' , Clz.fgn7, False)
|
Clz.print(' resending part ' , Clz.fgn7, False)
|
||||||
Clz.print(str(row[0]) , Clz.fgN2)
|
Clz.print(str(row[0]) , Clz.fgN2)
|
||||||
mid = self.ih.send(msg.as_string(), self.rootBox)
|
mid = self.ih.send(msg.as_string(), self.rootBox)
|
||||||
else :
|
else :
|
||||||
print()
|
print()
|
||||||
#Clz.print(' index intall files checked\n', Clz.fgB2)
|
#Clz.print(' index intall files checked\n', Clz.fgB2)
|
||||||
self._setIndexImap()
|
self._setIndexImap()
|
||||||
self.index = self.getIndex(True)
|
self.index = self.getIndex(True)
|
||||||
self.index.add(hlst['head'][3],label,hlst['head'][1],ext,ownerHash,catg,md5,bFlag,size,account)
|
self.index.add(hlst['head'][3],label,hlst['head'][1],ext,ownerHash,catg,md5,bFlag,size,account)
|
||||||
done = self.saveIndex()
|
done = self.saveIndex()
|
||||||
|
|
||||||
else :
|
else :
|
||||||
# clean
|
# clean
|
||||||
for mid, row in sendIds :
|
for mid, row in sendIds :
|
||||||
if cancel : self.ih.delete(mid, True)
|
if cancel : self.ih.delete(mid, True)
|
||||||
if file_exists(self.fsplit.DIR_OUTBOX+row[1]+'.ipr') : remove(self.fsplit.DIR_OUTBOX+row[1]+'.ipr')
|
if file_exists(self.fsplit.DIR_OUTBOX+row[1]+'.ipr') : remove(self.fsplit.DIR_OUTBOX+row[1]+'.ipr')
|
||||||
self.clean()
|
self.clean()
|
||||||
|
|
||||||
else :
|
|
||||||
print(' ',end='')
|
|
||||||
Clz.print(' == file already exist on server as ' , Clz.fgN7+Clz.bg1, False)
|
|
||||||
Clz.print(self.index.dic[md5][ImpraIndex.LABEL] , Clz.bg1+Clz.fgB3, False)
|
|
||||||
Clz.print(' [id:' , Clz.fgN7+Clz.bg1, False)
|
|
||||||
Clz.print(str(self.index.dic[md5][ImpraIndex.UID]) , Clz.bg1+Clz.fgB3, False)
|
|
||||||
Clz.print('] == ' , Clz.fgN7+Clz.bg1)
|
|
||||||
print()
|
|
||||||
else :
|
else :
|
||||||
print(' ',end='')
|
print(' ',end='')
|
||||||
Clz.print(' == files is empty or don\t exists == ' , Clz.bg1+Clz.fgN7)
|
Clz.print(' == file already exist on server as ' , Clz.fgN7+Clz.bg1, False)
|
||||||
|
Clz.print(self.index.dic[md5][ImpraIndex.LABEL] , Clz.bg1+Clz.fgB3, False)
|
||||||
|
Clz.print(' [id:' , Clz.fgN7+Clz.bg1, False)
|
||||||
|
Clz.print(str(self.index.dic[md5][ImpraIndex.UID]) , Clz.bg1+Clz.fgB3, False)
|
||||||
|
Clz.print('] == ' , Clz.fgN7+Clz.bg1)
|
||||||
print()
|
print()
|
||||||
|
else :
|
||||||
|
print(' ',end='')
|
||||||
|
Clz.print(' == files is empty or don\t exists == ' , Clz.bg1+Clz.fgN7)
|
||||||
|
print()
|
||||||
|
|
||||||
except Exception as e :
|
#~ except Exception as e :
|
||||||
print('Erroreuh')
|
#~ print('Erroreuh')
|
||||||
print(e)
|
#~ print(e)
|
||||||
self._setIndexImap()
|
self._setIndexImap()
|
||||||
rt.stop()
|
rt.stop()
|
||||||
return done
|
return done
|
||||||
|
|
|
@ -164,17 +164,21 @@ class ImapHelper:
|
||||||
BOX_BIN = '[Gmail]/Corbeille'
|
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.srv = IMAP4_SSL(conf.host,conf.port)
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
self.srv.login(conf.user,conf.pwd)
|
status, resp = self.srv.login(conf.user,conf.pwd)
|
||||||
self.rootBox = box
|
self.rootBox = box
|
||||||
status, resp = self.srv.select(self.rootBox)
|
if boxBin is None :
|
||||||
if status == self.KO :
|
if search('yahoo.com',conf.host) is not None :
|
||||||
self.createBox(self.rootBox)
|
self.BOX_BIN = 'Trash'
|
||||||
self.srv.select(self.rootBox)
|
if box != None :
|
||||||
|
status, resp = self.srv.select(self.rootBox)
|
||||||
|
if status == self.KO :
|
||||||
|
self.createBox(self.rootBox)
|
||||||
|
self.srv.select(self.rootBox)
|
||||||
rt.stop()
|
rt.stop()
|
||||||
|
|
||||||
def status(self,box='INBOX'):
|
def status(self,box='INBOX'):
|
||||||
|
@ -313,7 +317,7 @@ class ImapHelper:
|
||||||
#~ print(type(mid))
|
#~ print(type(mid))
|
||||||
#~ print(mid)
|
#~ print(mid)
|
||||||
#status, resp = self.srv.store(mid, '+FLAGS', '\\Deleted')
|
#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='')
|
print(' ',end='')
|
||||||
Clz.print(' deleting msg ',Clz.fgN7+Clz.bg1, False)
|
Clz.print(' deleting msg ',Clz.fgN7+Clz.bg1, False)
|
||||||
Clz.print(str(int(mid)) ,Clz.bg1+Clz.fgB3)
|
Clz.print(str(int(mid)) ,Clz.bg1+Clz.fgB3)
|
||||||
|
@ -331,9 +335,9 @@ class ImapHelper:
|
||||||
status = None
|
status = None
|
||||||
if int(mid) > 0 :
|
if int(mid) > 0 :
|
||||||
if byUid:
|
if byUid:
|
||||||
status, resp = self.srv.uid( 'store', mid, '+FLAGS', '\\Deleted' )
|
status, resp = self.srv.uid( 'store', mid, '+FLAGS (\\Deleted)' )
|
||||||
else :
|
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(' flag msg ' , Clz.fgn7, False)
|
||||||
Clz.print(str(int(mid)), Clz.fgB1, False)
|
Clz.print(str(int(mid)), Clz.fgB1, False)
|
||||||
Clz.print(' as deleted', Clz.fgn7)
|
Clz.print(' as deleted', Clz.fgn7)
|
||||||
|
@ -373,7 +377,8 @@ class ImapHelper:
|
||||||
if DEBUG and DEBUG_LEVEL <= DEBUG_NOTICE:
|
if DEBUG and DEBUG_LEVEL <= DEBUG_NOTICE:
|
||||||
print(status)
|
print(status)
|
||||||
print(resp)
|
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()
|
rt.stop()
|
||||||
return mid
|
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