本文整理汇总了Python中psr.sys.Sys.echo方法的典型用法代码示例。如果您正苦于以下问题:Python Sys.echo方法的具体用法?Python Sys.echo怎么用?Python Sys.echo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psr.sys.Sys
的用法示例。
在下文中一共展示了Sys.echo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wait_childs
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def wait_childs(self):
""""""
for r in wait(self.readers):
try:
msg = r.recv()
except EOFError:
self.readers.remove(r)
else:
if len(msg)==3 and msg[self.K_TYPE] in self.TYPE_MSG :
cpid = self.getcpid(msg[self.K_ID])
if msg[self.K_TYPE] == self.MSG_INIT :
if hasattr(self.onstart_bind, '__call__'):
self.onstart_bind(msg[self.K_ID], cpid, msg[self.K_DATA])
elif msg[self.K_TYPE] == self.MSG_PRINT :
if Sys.g.DEBUG :
if not Sys.g.GUI :
for item in msg[self.K_DATA] :
Sys.echo(item[0], Sys.clzdic[item[1]], False, True)
Sys.dprint('')
#~ else :
Sys.wlog(msg[self.K_DATA])
elif msg[self.K_TYPE] == self.MSG_DATA :
if hasattr(self.onrun_bind, '__call__'):
self.onrun_bind(msg[self.K_ID], cpid, msg[self.K_DATA])
elif msg[self.K_TYPE] == self.MSG_END :
if hasattr(self.onend_bind, '__call__'):
self.onend_bind(msg[self.K_ID], cpid, msg[self.K_DATA])
示例2: pheader
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def pheader(self):
self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
self.Cli.printHeaderTitle(self.Cli.conf.PRG_CLI_NAME)
self.Cli.printHeaderPart("account", self.account)
self.Cli.printHeaderPart("index", self.uid)
self.Cli.printHeaderPart("box", self.rootBox)
Sys.echo(self.date, Sys.Clz.fgB7, True, True)
self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
示例3: printHeaderPart
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def printHeaderPart(label,value):
""""""
a, b, c = ' [',':' ,'] '
Sys.echo(a , Sys.CLZ_HEAD_SEP, False)
Sys.echo(label, Sys.CLZ_HEAD_KEY, False)
Sys.echo(b , Sys.CLZ_HEAD_SEP, False)
Sys.echo(value, Sys.CLZ_HEAD_VAL, False)
Sys.echo(c , Sys.CLZ_HEAD_SEP, False)
return [(a,Const.CLZ_HEAD_SEP),(label,Const.CLZ_HEAD_KEY),(b,Const.CLZ_HEAD_SEP),(value,Const.CLZ_HEAD_VAL),(c,Const.CLZ_HEAD_SEP)]
示例4: print_header
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def print_header():
""""""
a = AbstractCli.printLineSep(Const.LINE_SEP_CHAR,Const.LINE_SEP_LEN)
b = AbstractCli.printHeaderTitle(AbstractCli.conf.PRG_CLI_NAME)
c = AbstractCli.printHeaderPart('version' ,AbstractCli.conf.PRG_VERS)
d = AbstractCli.printHeaderPart('author' ,AbstractCli.conf.PRG_AUTHOR)
e = AbstractCli.printHeaderPart('license' ,AbstractCli.conf.PRG_LICENSE)
f = AbstractCli.printHeaderPart('copyright',AbstractCli.conf.PRG_COPY)
Sys.echo(' ', Sys.Clz.OFF)
AbstractCli.printLineSep(Const.LINE_SEP_CHAR,Const.LINE_SEP_LEN)
Sys.wlog(a)
Sys.wlog(b + c + d + e + f )
Sys.wlog(a)
示例5: onCommandGet
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def onCommandGet(self):
""""""
if not len(self.a) > 1:
self.parser.error_cmd((self.a[0] + " command need an id",), True)
else:
vid = self.a[1]
ids = []
for sid in vid.split(","):
seq = sid.split("-")
if len(seq) == 2:
ids.extend(range(int(seq[0]), int(seq[1]) + 1))
else:
ids.append(sid)
for sid in ids:
Sys.clear()
self.pheader()
if self.impst.getFile(sid):
self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
Sys.dprint(" ", end="")
Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
Sys.dprint()
else:
self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
Sys.dprint(" ", end="")
Sys.echo(" == `", Sys.Clz.bg1 + Sys.Clz.fgB7, False)
Sys.echo(str(sid), Sys.Clz.bg1 + Sys.Clz.fgB3, False)
Sys.echo("` KO == ", Sys.Clz.bg1 + Sys.Clz.fgB7)
Sys.dprint()
示例6: onCommandRemove
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def onCommandRemove(self):
""""""
key = self.getMatchKey()
if key is not None:
Sys.clear()
self.pheader()
if self.impst.removeFile(self.a[1]):
self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
Sys.dprint(" ", end="")
Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
else:
self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
Sys.dprint(" ", end="")
Sys.echo(" == can't remove file == ", Sys.Clz.bg3 + Sys.Clz.fgB4)
Sys.dprint()
示例7: onCommandEdit
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def onCommandEdit(self):
""""""
key = self.getMatchKey()
if key is not None:
if self.o.label is not None or self.o.category is not None:
if self.impst.editFile(key, self.o.label, self.o.category):
Sys.clear()
self.pheader()
self.impst.idxu.index.print("ID", [int(self.a[1])])
Sys.dprint("\n ", end="")
Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
Sys.dprint()
else:
self.parser.error_cmd(
(("id ", (self.a[1], Sys.CLZ_ERROR_PARAM), " has not been modified "),), False
)
else:
self.parser.error_cmd(((" command edit need a label or a category "),), True)
示例8: printSection
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def printSection(self, sectionName, withoutSectionName=False):
""""""
if sectionName!='main':
Sys.dprint()
if not withoutSectionName :
Sys.echo('['+sectionName+']', Sys.Clz.fgB3)
else:
Sys.echo('['+sectionName.split('.')[1]+']', Sys.Clz.fgB3)
if sectionName in self.dic :
for k in sorted(self.dic[sectionName]):
k = k.rstrip(' ')
a = ''
Sys.echo(k.ljust(10,' ')+' = ' , Sys.Clz.fgn7, False)
if self.dic[sectionName][k] is not None :
if len(self.dic[sectionName][k]) > 98: a = '…'
if Sys.isUnix() or k is not 'key' :
Sys.echo(self.dic[sectionName][k][:98]+a, Sys.Clz.fgN2)
else:
Sys.echo('key is masked', Sys.Clz.fgb1)
示例9: onend_cmd
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [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())
示例10: onCommandKey
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [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.echo(' '*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),')'),))
示例11: load_profile
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def load_profile(self):
""""""
if self.check_profile(self.o.active_profile):
Sys.dprint(" ", end=" ")
Sys.echo(" == profile `", Sys.Clz.bg2 + Sys.Clz.fgb7, False)
Sys.echo(self.o.active_profile, Sys.Clz.bg2 + Sys.Clz.fgB3, False)
Sys.echo("` loaded == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
Sys.dprint()
self.ini.set("profile", self.o.active_profile)
self.ini.save()
else:
self.check_profile(self.o.active_profile, True)
示例12: onCommandAdd
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def onCommandAdd(self):
""""""
if not len(self.a) > 1:
self.parser.error_cmd((self.a[0] + " command need one argument",), True)
else:
vfile = self.a[1]
if not Io.file_exists(vfile):
if Sys.isdir(vfile):
for f in Sys.listdir(vfile):
if not Sys.isdir(f):
label, ext = Sys.getFileExt(Sys.basename(f))
if self.o.category is None:
self.o.category = ""
done = self.impst.addFile(vfile + Sys.sep + f, label, self.o.category)
if done:
self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
Sys.dprint(" ", end="")
Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
Sys.dprint()
else:
self.parser.error_cmd((self.a[0] + " is not a file or a directory",), True)
else:
if not len(self.a) > 2:
label = Sys.basename(vfile)
else:
label = self.a[2]
if self.o.category is None:
self.o.category = ""
Sys.clear()
self.pheader()
done = self.impst.addFile(vfile, label, self.o.category)
if done:
self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
Sys.dprint(" ", end="")
Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
Sys.dprint()
else:
self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
Sys.dprint(" ", end="")
Sys.echo(" == KO == ", Sys.Clz.bg1 + Sys.Clz.fgb7)
Sys.dprint()
示例13: printHeaderTitle
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def printHeaderTitle(title):
""""""
s = ' == '+title+' == '
Sys.echo(s, Sys.CLZ_HEAD_APP, False, True)
return [(s, Const.CLZ_HEAD_APP)]
示例14: check_profile
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def check_profile(self, profile, activeCheck=False):
""""""
c = (
self.ini.hasSection(profile + ".keys")
and self.check_imap(profile)
and self.ini.has("name", profile + ".infos")
)
if activeCheck:
if c:
Sys.echo(" " + profile + " is ok", Sys.Clz.fgB2)
Sys.echo(" testing...", Sys.Clz.fgB3)
kini = self.ini
conf = ImpraConf(kini, profile)
impst = None
try:
impst = ImpraStorage(self.ini.path, False)
Sys.echo(" done", Sys.Clz.fgB2)
except BadHostException as e:
Sys.echo(" fail ! bad host or port !", Sys.Clz.fgB1)
pass
except BadLoginException as e:
Sys.echo(str(e), Sys.Clz.fgN1)
Sys.echo(" fail ! bad login or password !", Sys.Clz.fgB1)
pass
except Exception as e:
Sys.echo(" fail ! check your configuration !", Sys.Clz.fgB1)
pass
else:
Sys.echo(" profile `", Sys.Clz.fgB1, False)
Sys.echo(profile, Sys.Clz.fgB3, False)
Sys.echo("` is incomplete\n need :", Sys.Clz.fgB1)
if not self.ini.hasSection(profile + ".keys"):
Sys.echo(" " * 4 + "key".ljust(18, " ") + ' (conf -S "' + profile + '" -K)', Sys.Clz.fgB3)
if not self.ini.has("host", profile + ".imap"):
Sys.echo(
" " * 4 + "imap host".ljust(18, " ") + ' (conf -S "' + profile + '" -H hostName)', Sys.Clz.fgB3
)
if not self.ini.has("user", profile + ".imap"):
Sys.echo(
" " * 4 + "imap user".ljust(18, " ") + ' (conf -S "' + profile + '" -U accountName)',
Sys.Clz.fgB3,
)
if not self.ini.has("pass", profile + ".imap"):
Sys.echo(
" " * 4 + "imap password".ljust(18, " ") + ' (conf -S "' + profile + '" -X password)',
Sys.Clz.fgB3,
)
if not self.ini.has("port", profile + ".imap"):
Sys.echo(
" " * 4 + "imap port".ljust(18, " ") + ' (conf -S "' + profile + '" -P port)', Sys.Clz.fgB3
)
if not self.ini.has("name", profile + ".infos"):
if c:
Sys.echo(" think to add your userName :", Sys.Clz.bgB3)
Sys.echo(" " * 4 + "userName".ljust(18, " ") + ' (conf -S "' + profile + '" -N yourName)', Sys.Clz.fgB3)
return c
示例15: onCommandConf
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import echo [as 别名]
def onCommandConf(self):
""""""
if self.o.load is not None or self.o.view is not None or self.o.save is not None:
if self.o.view is not None:
self.o.active_profile = self.o.view
if self.o.load is not None:
self.o.active_profile = self.o.load
if self.o.save is not None:
self.o.active_profile = self.o.save
if self.o.active_profile == None:
if self.ini.has("profile"):
self.o.active_profile = self.ini.get("profile")
else:
self.o.active_profile = "default"
if self.o.load:
self.pheader()
self.load_profile()
elif self.o.view:
self.pheader()
if self.o.view == "all":
sections = self.ini.getSections()
if len(sections) > 0:
ap = self.ini.get("profile")
sep = ""
for p in sections:
if p == ap:
colr = Sys.Clz.fgB1
p = "*" + p
else:
colr = Sys.Clz.fgB3
Sys.echo(sep + p, colr, False)
if sep == "":
sep = ","
Sys.dprint()
else:
Sys.echo(" no profiles", Sys.Clz.fgB1)
else:
print(self.ini.get("profile"))
self.ini.print(self.o.view)
elif self.o.save:
self.pheader()
if (
not self.o.set_host
and not self.o.set_user
and not self.o.set_pass
and not self.o.set_port
and not self.o.set_boxname
and not self.o.set_name
and not self.o.gen_key
and not self.o.set_multi
and not self.o.remove_multi
):
self.parser.error(" no options specified")
else:
if self.o.set_port and not represents_int(self.o.set_port):
self.parser.error(" port must be a number")
self.exit(1)
else:
if self.o.set_boxname:
self.ini.set("box", self.o.set_boxname, self.o.active_profile + ".imap")
if self.o.set_host:
self.ini.set("host", self.o.set_host, self.o.active_profile + ".imap")
if self.o.set_user:
self.ini.set("user", self.o.set_user, self.o.active_profile + ".imap")
if self.o.set_pass:
self.ini.set("pass", self.o.set_pass, self.o.active_profile + ".imap")
if self.o.set_port:
self.ini.set("port", self.o.set_port, self.o.active_profile + ".imap")
if self.o.set_name:
self.ini.set("name", self.o.set_name, self.o.active_profile + ".infos")
if self.ini.has("multi", self.o.active_profile + ".imap"):
m = self.ini.get("multi", self.o.active_profile + ".imap")
else:
m = None
if m is None:
m = []
else:
m = m.split(",")
m = [x for x in m if x]
if self.o.set_multi:
if self.check_imap(self.o.set_multi):
if not self.o.set_multi in m:
m.append(self.o.set_multi)
else:
Sys.dprint()
Sys.echo("imap profile " + self.o.set_multi + " not found", Sys.Clz.fgB1)
Sys.dprint()
elif self.o.remove_multi and self.o.remove_multi in m:
m.remove(self.o.remove_multi)
self.ini.set("multi", ",".join(m), self.o.active_profile + ".imap")
if self.o.gen_key:
kg = KeyGen()
self.ini.set("key", kg.key, self.o.active_profile + ".keys")
#.........这里部分代码省略.........