本文整理汇总了Python中psr.sys.Sys.isUnix方法的典型用法代码示例。如果您正苦于以下问题:Python Sys.isUnix方法的具体用法?Python Sys.isUnix怎么用?Python Sys.isUnix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psr.sys.Sys
的用法示例。
在下文中一共展示了Sys.isUnix方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createDefaultKeyIfNone
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import isUnix [as 别名]
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)
示例2: encrypt
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import isUnix [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)
示例3: printSection
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import isUnix [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)
示例4: decrypt
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import isUnix [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
示例5: __init__
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import isUnix [as 别名]
def __init__(self, path, remote=False, rwargs=None, thread=None, loglvl=Const.LOG_ALL):
""""""
AbstractCli.__init__(self, conf, self)
Cli.HOME = conf.DEFVAL_USER_PATH
Cli.DIRKEY = Cli.HOME+'.'+conf.PRG_NAME.lower()+Sys.sep
if not Sys.isUnix() :
Cli.CHQ = '"'
Cli.HOME = 'C:'+Sys.sep+conf.PRG_NAME.lower()+Sys.sep
Cli.DIRKEY = self.HOME+'keys'+Sys.sep
Sys.mkdir_p(Cli.DIRKEY)
gpData = OptionGroup(self.parser, '')
gpData = OptionGroup(self.parser, '')
gpConf = OptionGroup(self.parser, '')
gpData.add_option('-c', '--category' , action='store', metavar='CATG ')
gpData.add_option('-u', '--user' , action='store', metavar='OWNER ')
gpData.add_option('-l', '--label' , action='store', metavar='LABEL ')
gpData.add_option('-o', '--order' , action='store', metavar='ORDER ' , default='ID')
gpData.add_option('-O', '--order-inv' , action='store', metavar='ORDER_INVERSE ')
gpData.add_option('-a', '--account' , action='store', metavar='ACCOUNT ')
self.parser.add_option_group(gpData)
gpConf.add_option('-V', '--view' , action='store' )
gpConf.add_option('-L', '--load' , action='store' )
gpConf.add_option('-S', '--save' , action='store' )
gpConf.add_option('-C', '--check' , action='store' )
gpConf.add_option('-H', '--set-host' , action='store', metavar='HOST ')
gpConf.add_option('-U', '--set-user' , action='store', metavar='USER ')
gpConf.add_option('-X', '--set-pass' , action='store', metavar='PASS ')
gpConf.add_option('-P', '--set-port' , action='store', metavar='PORT ')
gpConf.add_option('-N', '--set-name' , action='store', metavar='NAME ')
gpConf.add_option('-M', '--set-multi' , action='store', metavar='PROFILE ')
gpConf.add_option('-R', '--remove-multi' , action='store', metavar='PROFILE ')
gpConf.add_option('-B', '--set-boxname' , action='store', metavar='BOXNAME ')
gpConf.add_option('-K', '--gen-key' , action='store_true', default=False)
self.parser.add_option_group(gpConf)
# rewrite argv sended by remote
if rwargs is not None :
import sys
sys.argv = rwargs
(o, a) = self.parser.parse_args()
Sys.g.QUIET = o.quiet
Sys.g.THREAD_CLI = thread
Sys.g.GUI = thread is not None
init(conf.PRG_NAME, o.debug, remote, not o.no_color, loglvl)
Const.LINE_SEP_LEN = 120
if not a:
try :
if not o.help or not o.version:
self.parser.error_cmd(('no command specified',), True)
else :
Sys.clear()
Cli.print_help()
except :
if not o.version :
self.parser.error_cmd(('no command specified',), True)
else :
Cli.print_header()
else:
if a[0] == 'help':
Sys.clear()
Cli.print_help()
elif a[0] in ['add','conf','import','info', 'edit','export','get','list','remove','search'] :
app = CliApp(self.HOME, path, self.parser, Cli, a, o)
if a[0]=='add':
app.onCommandAdd()
elif a[0]=='conf':
app.onCommandConf()
elif a[0]=='info':
app.onCommandInfo()
elif a[0]=='import':
app.onCommandImport()
elif a[0]=='edit':
app.onCommandEdit()
elif a[0]=='export':
app.onCommandExport()
elif a[0]=='get':
app.onCommandGet()
elif a[0]=='list':
app.onCommandList()
elif a[0]=='remove':
app.onCommandRemove()
elif a[0]=='search':
app.onCommandSearch()
Sys.dprint('PUT END SIGNAL')
if Sys.g.LOG_QUEUE is not None :
Sys.g.LOG_QUEUE.put(Sys.g.SIGNAL_STOP)
else :
#.........这里部分代码省略.........
示例6: print
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import isUnix [as 别名]
def print(self,order='ID', matchIds=None):
"""Print index content as formated bloc"""
#~ Sys.clear()
#~ Cli.print_header()
#~ AbstractCli.printLineSep(Const.LINE_SEP_CHAR,Const.LINE_SEP_LEN)
inv = order.startswith('-')
if inv : order = order[1:]
orderIndex = self.COLS.index(order)
if orderIndex is None : orderIndex = self.COLS.index('ID')
d = sorted([(self.dic.get(k),k) for i, k in enumerate(self.dic) if not k.startswith(self.SEP_KEY_INTERN)], reverse=inv, key=lambda lst:lst[0][orderIndex])
sizeid = 1+Sys.ceil(len(str(len(d))))
if sizeid < 3 : sizeid = 3
addsize = abs(3 - sizeid);
sort = '^' if inv else '_' #'ↆ'
space = (4+addsize, 8, 38, 10, 3, 5, 11, 24-addsize, 13)
for i, s in enumerate(self.COLS[:-1]):
symb, c = sort if order == s else ' ', Sys.Clz.BG4+Sys.Clz.fgB7 if order != s else Sys.Clz.BG7+Sys.Clz.fgB4
Sys.echo ((' '+s+symb).ljust(space[i],' ') , c, False, False)
Sys.echo('', c)
Sys.echo(Const.LINE_SEP_CHAR*Const.LINE_SEP_LEN, Sys.CLZ_HEAD_LINE)
a = ''
tsize = 0
psize = 0
acc = {}
wrap = '… ' if Sys.isUnix() else '/ '
for v,k in d :
if matchIds==None or v[self.UID] in matchIds:
if v[self.SIZE] == '' : v[self.SIZE] = 0
a = ''
Sys.echo(str(v[self.UID]).rjust(sizeid+1,' ') , Sys.Clz.bg1+Sys.Clz.fgB7, False)
Sys.echo(' '+str(k).ljust(9,' ')[0:6]+wrap , Sys.Clz.fgN2, False)
if len(v[self.LABEL])>36 : a = wrap
try:
Sys.echo(str(v[self.LABEL][:36]+a).ljust(38,' ') , Sys.Clz.fgN7, False)
except:
pass
j = 0
for c in v[self.LABEL][:36] :
try:
Sys.echo(str(c) , Sys.Clz.fgN7, False, False)
except:
Sys.echo('?' , Sys.Clz.fgN7, False, False)
j += 1
Sys.echo(''.ljust(38-j,' ') , Sys.Clz.fgN7, False, False)
a = ''
Sys.echo(Sys.readableBytes(v[self.SIZE])[:9].rjust(9,' ')+' '*2 , Sys.Clz.fgN5, False)
Sys.echo(str(v[self.PARTS]).rjust(2 ,'0') +' '*2 , Sys.Clz.fgN1, False)
Sys.echo(str(v[self.EXT][:6]).ljust(7,' ') , Sys.Clz.fgn3, False)
Sys.echo(self.getUser(str(v[self.USER])).ljust(11 ,' ') , Sys.Clz.fgn7, False)
#~ Sys.echo(str(v[self.CATG]).ljust(30 ,' ') , Clz.fgN3)
if len(v[self.CATG])>22 : a = wrap
Sys.echo(str(v[self.CATG][:22]+a).ljust(24 ,' ') , Sys.Clz.fgN3, False)
a = ''
if len(v)-2==self.ACCOUNT:
if v[self.ACCOUNT] in self.acclist :
if len(self.acclist[v[self.ACCOUNT]])>11 : a = '…'
Sys.echo(str(self.acclist[v[self.ACCOUNT]][:11]+a).ljust(12 ,' ') , Sys.Clz.fgN4)
else :
Sys.echo(str(v[self.ACCOUNT][:11]+'!').ljust(12 ,' ') , Sys.Clz.fgN4)
if v[self.ACCOUNT] in acc :
acc[v[self.ACCOUNT]] += int(v[self.SIZE])
else : acc[v[self.ACCOUNT]] = int(v[self.SIZE])
else: Sys.dprint()
psize += int(v[self.SIZE])
tsize += int(v[self.SIZE])
if len(d)==0:
Sys.echo(' empty', Sys.Clz.fgB1)
Sys.echo(Const.LINE_SEP_CHAR*Const.LINE_SEP_LEN, Sys.CLZ_HEAD_LINE)
c = Sys.Clz.fgB2
if psize != tsize : c = Sys.Clz.fgB7
Sys.echo(' size : ', Sys.Clz.fgB3, False)
Sys.echo(Sys.readableBytes(psize)[:9].rjust(9,' '), c, False)
if psize != tsize :
Sys.echo(' / ', Sys.Clz.fgB3, False)
Sys.echo(Sys.readableBytes(tsize), Sys.Clz.fgB2, False)
Sys.dprint()
Sys.echo(Const.LINE_SEP_CHAR*Const.LINE_SEP_LEN, Sys.CLZ_HEAD_LINE)
示例7: on_start
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import isUnix [as 别名]
def on_start(self):
""""""
Sys.g.GUI_PRINT_STDOUT = False
Sys.g.GUI = True
init(conf.PRG_NAME, False, Sys.getpid(), True, Const.LOG_ALL)
self.conf = ImpraConf(KiniFile('impra2.ini'))
self.populate_profiles()
self.populate_config()
self.taskLabel = ImpraThread.TASK_LABEL
self.taskStock = ImpraThread.TASK_STOCK
self.progressbar = self.get('progressbar1')
self.textview = self.get('textview1')
try :
self.textview.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 1.0))
self.textview.modify_font(Pango.font_description_from_string ('DejaVu Sans Mono Book 11' if Sys.isUnix() else 'Lucida Conosle 11'))
except :
pass
self.textbuffer = self.textview.get_buffer()
self.tags = self.buildTxtTags(self.textbuffer)
self.initWidgetByThread('impra-1', self.textview, self.textbuffer, self.progressbar, self.tags)
self.initWidgetByThread('MainThread', self.textview, self.textbuffer, self.progressbar, self.tags)
self.tree = self.get('treeview1')
self.tree.connect('row-activated', self.on_row_select)
self.tree.get_selection().connect('changed', self.on_tree_selection_changed)
self.launch_thread(self.on_ended)
self.searchCatg = self.get('comboboxtext1')
self.searchUser = self.get('comboboxtext4')
self.searchAccount = self.get('comboboxtext5')
self.filterIds = None
self.index = None
self.taskList = {}
self.threads_work = [False, False]
示例8: exit
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import isUnix [as 别名]
def exit(code):
""""""
if Sys.isUnix() : Sys.exit(code)