本文整理汇总了Python中psr.sys.Sys.realpath方法的典型用法代码示例。如果您正苦于以下问题:Python Sys.realpath方法的具体用法?Python Sys.realpath怎么用?Python Sys.realpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psr.sys.Sys
的用法示例。
在下文中一共展示了Sys.realpath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onend_cmd
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import realpath [as 别名]
def onend_cmd(self, title, stime, done, outputfile):
""""""
s = Const.LINE_SEP_CHAR*Const.LINE_SEP_LEN
Sys.echo(s, Sys.CLZ_HEAD_LINE)
Sys.wlog([(s, Const.CLZ_HEAD_SEP)])
Sys.pstep(title, stime, done, True)
Sys.echo(s, Sys.CLZ_HEAD_LINE)
Sys.wlog([(s, Const.CLZ_HEAD_SEP)])
if done and outputfile is not None:
Sys.cli_emit_progress(100)
Sys.echo(' '*5+Sys.realpath(outputfile), Sys.Clz.fgB1, False)
Sys.echo(' ('+Sys.getFileSize(outputfile)+')', Sys.Clz.fgB3)
bdata = [(' '*5+Sys.realpath(outputfile), 'io'),(' ('+Sys.getFileSize(outputfile)+')','func')]
Sys.wlog(bdata)
Sys.wlog(Sys.dprint())
示例2: onCommandKey
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import realpath [as 别名]
def onCommandKey(self):
""""""
if int(self.o.length) >= 128 and int(self.o.length) <= 4096 :
self.parser.print_header()
if not self.o.outputfile : self.o.outputfile = self.home+'.kirmah'+Sys.sep+'.default.key'
kg = KeyGen(int(self.o.length))
done = True
if Io.file_exists(self.o.outputfile) and not self.o.force :
Sys.pwarn((('the key file ',(self.o.outputfile, Sys.Clz.fgb3), ' already exists !'),
'if you rewrite this file, all previous files encrypted with the corresponding key will be unrecoverable !'))
done = Sys.pask('Are you sure to rewrite this file')
self.stime = Sys.datetime.now()
if done :
Io.set_data(self.o.outputfile, kg.key)
Sys.pstep('Generate key file', self.stime, done)
if done :
Sys.print(' '*5+Sys.realpath(self.o.outputfile), Sys.Clz.fgB1, True)
else :
self.parser.error_cmd((('invalid option ',('-l, --length', Sys.Clz.fgb3), ' value (', ('128',Sys.Clz.fgb3),' to ', ('4096',Sys.Clz.fgb3),')'),))
示例3: onCommandMerge
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import realpath [as 别名]
def onCommandMerge(self):
""""""
done = True
if not Sys.g.QUIET : self.parser.print_header()
if done :
toPath = None
try :
Sys.ptask()
key = Io.get_data(self.o.keyfile)
km = Kirmah(key)
kcf = None
istar = True
try:
import tarfile
dpath = Sys.dirname(Sys.realpath(self.o.outputfile))+Sys.sep if self.o.outputfile is not None else Sys.dirname(Sys.realpath(self.a[1]))+Sys.sep
if self.o.outputfile is None :
self.o.outputfile = dpath
with tarfile.open(self.a[1], mode='r') as tar:
#~ print(dpath)
tar.extractall(path=dpath)
kcf = None
for tarinfo in tar:
#~ print(tarinfo.name)
if tarinfo.isreg() and tarinfo.name[-4:]=='.kcf':
#~ print(dpath+tarinfo.name)
kcf = dpath+tarinfo.name
if kcf is not None :
km.DIR_OUTBOX = dpath
toPath = km.mergeFile(kcf, self.o.outputfile)
except BadKeyException:
Sys.pwarn((('BadKeyException : ',('wrong key ',Sys.CLZ_WARN_PARAM), ' !'),), False)
done = False
except Exception :
istar = False
toPath = km.mergeFile(self.a[1], self.o.outputfile)
#~ if self.o.outputfile is not None :
#~ Io.rename(toPath, self.o.outputfile)
#~ toPath = self.o.outputfile
except BadKeyException:
Sys.pwarn((('BadKeyException : ',('wrong key ',Sys.CLZ_WARN_PARAM), ' !'),), False)
done = False
except Exception as e :
done = False
if Sys.g.DEBUG :
print(e)
elif not Sys.g.QUIET :
Sys.pwarn((str(e),))
if not done :
if istar :
with tarfile.open(self.a[1], mode='r') as tar:
for tarinfo in tar:
Sys.removeFile(dpath+tarinfo.name)
if not Sys.g.QUIET :
self.onend_cmd('Kirmah Merge', self.stime, done, toPath)