本文整理汇总了Python中psr.sys.Io.removeFile方法的典型用法代码示例。如果您正苦于以下问题:Python Io.removeFile方法的具体用法?Python Io.removeFile怎么用?Python Io.removeFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psr.sys.Io
的用法示例。
在下文中一共展示了Io.removeFile方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getBackupAddMap
# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import removeFile [as 别名]
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: save
# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import removeFile [as 别名]
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
示例3: encrypt
# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import removeFile [as 别名]
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)
示例4: read
# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import removeFile [as 别名]
def read(self):
""""""
try:
call = ' '.join([Sys.executable, 'kirmah-cli.py', 'dec', '-qf', self.path+'.kmh', '-z', '-r', '-m', '-o', self.path, '-k', self.keyPath ])
Sys.sysCall(call)
with Io.rfile(self.path, False) as fi:
csection = 'main'
self.dic[csection] = {}
for l in fi:
l = l.rstrip().lstrip()
if len(l) > 0 and not l[0]=='#' :
d = regsplit(' *= *', l , 1)
if len(d)> 1:
self.dic[csection][d[0]] = d[1] if d[1] is not None else ''
elif len(l)>0 and l[0]=='[':
csection = l.strip('[]')
self.dic[csection] = {}
Io.removeFile(self.path)
except IOError :
pass
示例5: decrypt
# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import removeFile [as 别名]
def decrypt(self, fromPath=None):
""""""
done = False
try :
if fromPath is None :
fromPath = self.path
toPath = fromPath[:-len(Kirmah.EXT)] if fromPath.endswith(Kirmah.EXT) else fromPath+'.dump'
if Io.file_exists(fromPath) :
Sys.pwlog([(' Decrypt Index... ' , Const.CLZ_0, True)])
call = ' '.join([Sys.executable, 'kirmah-cli.py', 'dec', '-qfj2' if Sys.isUnix() else '-qf', fromPath, '-z', '-r', '-m', '-o', toPath, '-k', self.keyPath ])
print(call)
Sys.sysCall(call)
data = jloads(Io.get_data(toPath))
Io.removeFile(toPath)
else :
data = {}
done = True
except ValueError as e:
raise BadKeyException(e)
Sys.pwlog([(' done'if done else ' ko' , Const.CLZ_2 if done else Const.CLZ_1, True)])
return data
示例6: backupAddMap
# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import removeFile [as 别名]
def backupAddMap(self, data):
""""""
Io.set_data(self.addmapPath, jdumps(data))
call = " ".join(
[
Sys.executable,
"kirmah-cli.py",
"enc",
"-qf",
self.addmapPath,
"-z",
"-r",
"-m",
"-o",
self.addmapPath + Kirmah.EXT,
"-k",
self.idxu.index.keyPath,
]
)
print(call)
Sys.sysCall(call)
Io.removeFile(self.addmapPath)
示例7: onCommandSplit
# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import removeFile [as 别名]
def onCommandSplit(self):
""""""
done = True
Sys.cli_emit_progress(1)
if not self.o.parts is None and not(int(self.o.parts)>=12 and int(self.o.parts) <=62) :
self.parser.error_cmd((('invalid option ',('-p, --parts', Sys.Clz.fgb3), ' value (', ('12',Sys.Clz.fgb3),' to ', ('62',Sys.Clz.fgb3),')'),))
else : self.o.parts = int(self.o.parts)
if not Sys.g.QUIET : self.parser.print_header()
if self.o.outputfile is not None :
if self.o.outputfile[-5:]!='.tark' : self.o.outputfile += '.tark'
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 :
Sys.ptask()
Sys.cli_emit_progress(2)
key = Io.get_data(self.o.keyfile)
km = Kirmah(key)
hlst = km.ck.getHashList(Sys.basename(self.a[1]), self.o.parts, True)
Sys.cli_emit_progress(3)
kcf = km.splitFile(self.a[1], hlst)
t = int(Sys.time())
times = (t,t)
p = 85
Sys.cli_emit_progress(p)
Io.touch(kcf, times)
frav = 0.24
for row in hlst['data']:
p += frav
Io.touch(row[1]+km.EXT,times)
Sys.cli_emit_progress(p)
if self.o.outputfile is not None :
d = Sys.datetime.now()
if Sys.g.DEBUG : Sys.wlog(Sys.dprint())
Sys.ptask('Preparing tark file')
hlst['data'] = sorted(hlst['data'], key=lambda lst: lst[4])
with tarfile.open(self.o.outputfile, mode='w') as tar:
tar.add(kcf, arcname=Sys.basename(kcf))
p = 90
for row in hlst['data']:
tar.add(row[1]+km.EXT, arcname=Sys.basename(row[1]+km.EXT))
p += frav
Sys.cli_emit_progress(p)
Sys.pstep('Packing destination file', d, True)
d = Sys.datetime.now()
Sys.ptask('Finalize')
for row in hlst['data']:
Io.removeFile(row[1]+km.EXT)
p += frav
Sys.cli_emit_progress(p)
Io.removeFile(kcf)
Sys.pstep('Cleaning', d, True)
except Exception as e :
done = False
if Sys.g.DEBUG :
print('split exception')
print(e)
#~ raise e
elif not Sys.g.QUIET :
Sys.pwarn((str(e),))
if not Sys.g.QUIET:
Sys.cli_emit_progress(100)
self.onend_cmd('Kirmah Split', self.stime, done, self.o.outputfile)
示例8: delete
# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import removeFile [as 别名]
def delete(self):
Io.removeFile(self.path)
self.dic = {}
示例9: removeLocal
# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import removeFile [as 别名]
def removeLocal(self):
""""""
self.conf.rem('*','index')
self.conf.save()
self.idx = None
Io.removeFile(self.pathIdx)
示例10: sendFile
# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import removeFile [as 别名]
def sendFile(self, data, retry=False):
""""""
done = None
key = None
if data is not None:
key, label, ext, count, catg, hlst, usr, ownerHash, sha256, size = data
self.idxu.index.addUser(usr, ownerHash)
account = self.idxu.switchFileAccount()
sendIds = []
cancel = False
d = None
Sys.cli_emit_progress(0)
Sys.sleep(0.2)
if not retry:
Sys.pwlog(
[
(" Sending... ", Const.CLZ_7),
(" (", Const.CLZ_0),
(
" ~" + Sys.readableBytes(Sys.getsize(self.outbox + hlst["data"][0][1] + Kirmah.EXT)),
Const.CLZ_3,
),
(" per msg ) ", Const.CLZ_0, True),
]
)
else:
Sys.pwlog(
[
(" Retry sending last file... ", Const.CLZ_0),
(label + ext, Const.CLZ_7),
(" (" + catg + ")", Const.CLZ_3, True),
]
)
ignore = False
for i, row in enumerate(hlst["data"]):
""""""
if retry:
if not Io.file_exists(self.outbox + row[1] + Kirmah.EXT):
continue
elif not ignore:
Sys.pwlog([(" Ignoring file 1 to " + str(i), Const.CLZ_1, True)])
ignore = True
d = Sys.datetime.now()
msg = self.idxu.mb.build(usr, "all", hlst["head"][2], self.outbox + row[1] + Kirmah.EXT)
try:
mid = self.idxu.ih.send(msg.as_string(), self.rootBox)
except Exception as e:
Sys.pwarn((("addFile : ", (str(e), Sys.CLZ_WARN_PARAM), " !"),))
Sys.echo("waiting 5 s and retry")
Sys.sleep(5)
# force reconnect
self.impst.idxu.switchFileAccount(account, True)
# retry
mid = self.idxu.ih.send(msg.as_string(), self.rootBox)
finally:
if not mid is None:
status, resp = self.idxu.ih.fetch(mid[1], "(UID BODYSTRUCTURE)", True)
if status == self.idxu.ih.OK:
sendIds.append((mid[1], row))
Sys.pwlog(
[
(" part ", Const.CLZ_0),
(str(row[0]).rjust(2, "0"), Const.CLZ_2),
(" sent as msg ", Const.CLZ_0),
(str(mid[1]).rjust(5, "0"), Const.CLZ_1),
(" (", Const.CLZ_7),
(str(int(row[4]) + 1).rjust(2, "0"), Const.CLZ_2),
("/", Const.CLZ_7),
(str(count), Const.CLZ_3),
(") in ", Const.CLZ_7),
(Sys.getDelta(d), Const.CLZ_4, True),
]
)
Sys.cli_emit_progress(int((i + 1) * 100 / len(hlst["data"])))
Sys.removeFile(self.outbox + row[1] + Kirmah.EXT)
else:
Sys.pwarn((("error occured when sending part ", (row[0], Sys.Clz.fgb3), " !"),))
diff = self.checkSendIds(sendIds, hlst["head"][2])
if len(sendIds) == count or retry:
self.idxu.get(True)
self.idxu.index.add(key, label, hlst["head"][1], ext, ownerHash, catg, sha256, size, account)
done = self.idxu.update()
Io.removeFile(self.addmapPath + Kirmah.EXT)
# resending missing parts
else:
Sys.pwarn((("TODO => must resending ", ("missing", Sys.CLZ_WARN_PARAM), " parts"),))
print(diff)
# clean
for mid, row in sendIds:
if Io.file_exists(self.outbox + row[1] + Kirmah.EXT):
Sys.removeFile(self.outbox + row[1] + Kirmah.EXT)
#.........这里部分代码省略.........