本文整理汇总了Python中psr.sys.Io类的典型用法代码示例。如果您正苦于以下问题:Python Io类的具体用法?Python Io怎么用?Python Io使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Io类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getBackupAddMap
def getBackupAddMap(self):
""""""
data = None
if Io.file_exists(self.addmapPath + Kirmah.EXT):
call = " ".join(
[
Sys.executable,
"kirmah-cli.py",
"dec",
"-qf",
self.addmapPath + Kirmah.EXT,
"-z",
"-r",
"-m",
"-o",
self.addmapPath,
"-k",
self.idxu.index.keyPath,
]
)
print(call)
Sys.sysCall(call)
data = jloads(Io.get_data(self.addmapPath))
Io.removeFile(self.addmapPath)
return data
示例2: onCommandDec
def onCommandDec(self):
""""""
done = True
if self.o.outputfile is None :
self.o.outputfile = self.a[1][:-4] if self.a[1][-4:] == Kirmah.EXT else self.a[1]
if not Sys.g.QUIET : self.parser.print_header()
if Io.file_exists(self.o.outputfile) and not self.o.force:
Sys.pwarn((('the file ',(self.o.outputfile, Sys.Clz.fgb3), ' already exists !'),))
done = Sys.pask('Are you sure to rewrite this file')
self.stime = Sys.datetime.now()
if done :
try :
if (self.o.multiprocess is not None and not represents_int(self.o.multiprocess)) or (not self.o.multiprocess is None and not(int(self.o.multiprocess)>=2 and int(self.o.multiprocess) <=8)) :
self.parser.error_cmd((('invalid option ',('-j, --multiprocess', Sys.Clz.fgb3), ' value (', ('2',Sys.Clz.fgb3),' to ', ('8',Sys.Clz.fgb3),')'),))
nproc = int(self.o.multiprocess) if not self.o.multiprocess is None and int(self.o.multiprocess)>=2 and int(self.o.multiprocess) <=8 else 1
Sys.ptask()
key = Io.get_data(self.o.keyfile)
km = Kirmah(key)
km.decrypt(self.a[1], self.o.outputfile, nproc)
except BadKeyException:
done = False
Sys.pwarn((('BadKeyException : ',('wrong key ',Sys.CLZ_WARN_PARAM), ' !'),), False)
if not Sys.g.QUIET :
self.onend_cmd('Kirmah Decrypt', self.stime, done, self.o.outputfile)
示例3: save
def save(self,path=None,notAssign=False):
""""""
path = path if path is not None else self.path
Io.set_data(path, '# last updated : '+str(Sys.datetime.now())+Const.LF+self.toString())
call = ' '.join(['python3', 'kirmah-cli.py', 'enc', '-qf', path, '-z', '-r', '-m', '-o', path+'.kmh', '-k', self.keyPath ])
Sys.sysCall(call)
Io.removeFile(path)
if not notAssign : self.path = path
示例4: _saveLocalIndex
def _saveLocalIndex(self):
""""""
if not self.idx : self._getId()
if self.idx :
msg = self.ih.getEmail(self.idx, True)
content = b''
for part in msg.walk():
content += part.get_payload(decode=True)
Io.set_data(self.pathIdx, a2b_base64(content), True)
示例5: createDefaultKeyIfNone
def createDefaultKeyIfNone(self):
""""""
kpath = self.getDefaultKeyPath()
if not Io.file_exists(kpath):
if Sys.isUnix():
if not Sys.isdir(conf.DEFVAL_UKEY_PATH):
Sys.mkdir_p(conf.DEFVAL_UKEY_PATH)
Io.set_data(kpath, KeyGen(conf.DEFVAL_UKEY_LENGHT).key)
self.selectKey(kpath)
示例6: getKeyInfos
def getKeyInfos(self, filename=None):
""""""
if filename is None:
filename = self.getDefaultKeyPath()
if not Io.file_exists(filename):
raise FileNotFoundException(filename)
k = Io.get_data(filename)
s = len(k)
m = KeyGen(s).getMark(k)
return k, s, m
示例7: buildIndex
def buildIndex(self, fromPath):
"""Build mail for ImpraIndex
:Returns: 'email.message.Message'
"""
msg = MIMEText(Io.str(b2a_base64(Io.get_data(fromPath, True))), 'plain', 'utf-8')
msg['From'] = self.getHashName('system')+'@'+self.DOMAIN_NAME
msg['To'] = self.getHashName('all')+'@'+self.DOMAIN_NAME
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = Header(self.getHashName('index'),'utf-8')
return msg
示例8: _getIdsList
def _getIdsList(ids):
idslist = None
if isinstance(ids,list):
if len(ids) > 0 and ids[0]!='' and ids[0]!=None:
li = len(ids)-1
if int(ids[0])+li == int(ids[li]):
idslist = Io.str(ids[0]+b':'+ids[li]) if isinstance(ids[0],bytes) else str(ids[0])+':'+str(ids[li])
else :
idslist = Io.str(b','.join(ids)) if isinstance(ids[0],bytes) else ','.join(ids)
elif isinstance(ids, int) and ids > 0:
idslist = Io.str(ids)
return idslist
示例9: encrypt
def encrypt(self, fromPath=None):
""""""
if fromPath is None :
fromPath = self.pathPlain
Sys.pwlog([(' Encrypt Index... ' , Const.CLZ_0, True)])
Io.set_data(fromPath, jdumps(self.dic))
call = ' '.join([Sys.executable, 'kirmah-cli.py', 'enc', '-qfj2' if Sys.isUnix() else '-qf', fromPath, '-z', '-r', '-m', '-o', fromPath+Kirmah.EXT, '-k', self.keyPath ])
#~ print(call)
Sys.sysCall(call)
Io.removeFile(fromPath)
Sys.pwlog([(' done', Const.CLZ_2, True)])
return Io.get_data(fromPath+Kirmah.EXT, True)
示例10: createDefaultKeyIfNone
def createDefaultKeyIfNone(self):
""""""
kpath = self.getDefaultKeyPath()
if not Io.file_exists(kpath):
#if Sys.isUnix() :
if not Sys.isdir(conf.DEFVAL_UKEY_PATH) :
Sys.mkdir_p(conf.DEFVAL_UKEY_PATH)
k = KeyGen(conf.DEFVAL_UKEY_LENGHT)
print(k)
content = k.key
print('content')
Io.set_data(kpath, content)
print('set content')
self.selectKey(kpath)
示例11: __init__
def __init__(self, path, keyPath=None):
""""""
self.path = path
self.dic = {}
self.keyPath = path+'.key' if keyPath is None else keyPath
if not Io.file_exists(self.keyPath) :
kg = KeyGen()
Io.set_data(self.keyPath, kg.key)
if not Io.file_exists(path) :
self.set('profile' , 'default', 'main')
self.set('key' ,kg.key,'default.keys')
self.set('mark' ,kg.mark,'default.keys')
self.set('salt' ,'-*-ImpraStorage-*-','default.keys')
self.save()
self.read()
示例12: update
def update(self):
""""""
self.switchFileAccount(self.conf.profile)
try:
if self.idx != None :
if not isinstance(self.idx,bytes):
self.idx = Io.bytes(self.idx)
self.delids.append(self.idx)
except Exception as e :
Sys.dprint('error : ')
Sys.dprint(e)
self.index.fixDuplicateIds()
#~ self.index.fixAccount('gmail5')
self.index.encrypt()
msgIndex = self.mb.buildIndex(self.pathIdx)
_, self.idx = self.ih.send(msgIndex.as_string(), self.rootBox)
date = self.ih.headerField(self.idx, 'date', True)
self.conf.sets((['uid' , self.idx , 'index'],
['date' , date , 'index'],
['time' , str(Sys.datetime.now()), 'index']))
Sys.pwlog([(' Index updated (' , Const.CLZ_0),
(str(int(self.idx)) , Const.CLZ_2),
(') ' , Const.CLZ_0),
(str(date) , Const.CLZ_7, True)])
try :
self.ih.delete(self.delids, True)
except :
Sys.dprint('error : ')
Sys.dprint(e)
self.ih.clearTrash()
return True
示例13: on_proceed
def on_proceed(self, btn):
""""""
if btn.get_label() == conf.GUI_LABEL_OK :
btn.set_label(conf.GUI_LABEL_PROCEED)
self.PROCEED = False
self.pb.hide()
self.show_log()
else :
if not self.PROCEED :
self.PROCEED = True
self.STOPPED = False
btn.set_sensitive(False)
self.app.setDestFile(self.get('filechooserbutton3').get_filename())
if not Io.file_exists(self.app.dst) or self.warnDialog('file '+self.app.dst+' already exists', 'Overwrite file ?'):
self.pb = self.get('progressbar1')
self.pb.set_fraction(0)
self.pb.show()
self.pb.pulse()
btn.set_sensitive(True)
btn.set_label(conf.GUI_LABEL_CANCEL)
self.clear_log(self.get('checkbutton3'))
self.show_log()
self.launch_thread()
else :
self.on_proceed_end(True)
else :
self.halt_thread()
示例14: selectKey
def selectKey(self, filename):
""""""
print('selectKey : ')
print(filename)
if not Io.file_exists(filename):
raise FileNotFoundException(filename)
self.kpath = filename
示例15: _ids
def _ids(self, box='INBOX', search='ALL', charset=None, byUid=False):
""""""
status, resp = self.cnx.select(box)
if status == self.KO :
self.createBox(box)
self.cnx.select(box)
status, resp = self.cnx.search(charset, '(%s)' % search)
return resplit(' ',Io.str(resp[self.K_HEAD]))