本文整理汇总了Python中GNUScreen.find_new_session方法的典型用法代码示例。如果您正苦于以下问题:Python GNUScreen.find_new_session方法的具体用法?Python GNUScreen.find_new_session怎么用?Python GNUScreen.find_new_session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GNUScreen
的用法示例。
在下文中一共展示了GNUScreen.find_new_session方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prime
# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import find_new_session [as 别名]
def prime(fifoname):
l1=sc.get_session_list()
cmd='screen -S "MANAGER_NOATTACH" -m -d -c /dev/null python %s %s %s'%(sys.argv[0],'ui',fifoname)
sys.stderr.write(cmd+'\n')
os.popen(cmd)
l2=sc.get_session_list()
sys.stderr.write('searching for target session..\n')
session=sc.find_new_session(l1,l2)
sys.stderr.write('target session = %s\n'%session)
print ('session: %s'%session)
return session
示例2: prime
# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import find_new_session [as 别名]
def prime(fifoname):
l1 = sc.get_session_list()
cmd = SCREEN + \
' -S "GNU_SCREEN_SESSIONS_MANAGER" -m -d -c /dev/null "%s" "%s" "%s" "%s"' % \
(os.getenv('PYTHONBIN'), (sys.argv)[0], 'ui', fifoname)
sys.stderr.write(cmd + "\n")
os.popen(cmd)
l2 = sc.get_session_list()
sys.stderr.write('searching for target session..\n')
session = sc.find_new_session(l1, l2)
sys.stderr.write('target session = %s\n' % session)
print 'session: %s' % session
return session
示例3: eval_command
# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import find_new_session [as 别名]
def eval_command(scs,command,last_session,psession):
command=command.split(' ',1)
mode=command[0]
if len(command)>1:
args=[]
for arg in command[1].split(' '):
args.append(arg)
else:
args=['']
#print2ui('command: %s args: %s'%(command,str(args)))
if mode.startswith('a'): # attach
return tui_attach_session(scs,args[0],psession)
if mode.startswith('d'): # deselect
print2ui('LOGIC: deselecting' )
scs.focus('bottom')
scs.select('-')
scs.focus('top')
return None,'\0'
elif mode=='kill':
if last_session:
print2ui('LOGIC: killing session \"%s\"'%last_session)
scs=ScreenSaver(last_session,'/dev/null','/dev/null')
scs.quit()
elif mode.startswith('q'): # quit
print2ui('LOGIC: quiting...' )
return 'quit',None
elif mode.startswith('h'): # help
usage()
elif mode.startswith('e'): # enter
return 'enter',None
elif mode=='restart': # restart
print2ui('LOGIC: restarting')
return 'restart',None
elif mode.startswith('r'): # refresh
print2ui('LOGIC: refreshing')
elif mode.startswith('l'): # layout
global tui
print2ui('LOGIC: toggling layout')
scs.focus('bottom')
cnum=scs.get_number_and_title()[0]
scs.focus('top')
if tui!=maxtui:
tui+=1
else:
tui=1
reset_tui(scs)
if int(cnum)>1:
scs.focus('bottom')
scs.select(cnum)
scs.focus('top')
elif mode.startswith('w'): # wipe
print2ui('LOGIC: wiping out dead sessions')
scs.wipe()
elif mode.startswith('save'): # save
if args[0]:
arg_out='%s'%args[0]
else:
arg_out='%s'%last_session
print2ui('LOGIC: saving session as %s'%arg_out)
os.popen('screen-session save --force --log /dev/null --in \"%s\" --out \"%s\"'%(last_session,arg_out))
elif mode.startswith('s'): # screen
if args and len(args[0])>0:
arg=" ".join(["%s"%v for v in args])
else:
arg=' '
cmd='screen -d -m %s'%arg
print2ui('LOGIC: creating new session: [%s]'%(cmd.strip()))
l1=sc.get_session_list()
os.popen(cmd)
l2=sc.get_session_list()
newsession=sc.find_new_session(l1,l2)
return tui_attach_session(scs,newsession,psession)
elif mode.startswith('n'): # name
if last_session:
print2ui('LOGIC: renaming session to \"%s\"'%args[0])
if scs.sessionname() == last_session:
scs_target=scs
else:
scs_target=ScreenSaver(last_session,'/dev/null','/dev/null')
nsessionname=scs_target.sessionname(args[0])
print2ui('LOGIC: new sessionname is now [%s]'%nsessionname)
scs.focus('bottom')
cnum=scs.get_number_and_title()[0]
if (psession and psession==last_session):
psession=nsessionname
print2ui('LOGIC: parent session is now [%s]'%nsessionname)
elif nsessionname==scs.sessionname():
print2ui('LOGIC: THIS is session [%s]'%nsessionname)
else:
scs.screen('screen -x \"%s\"'%nsessionname)
scs.title(nsessionname)
if int(cnum)>1:
#print2ui('LOGIC: killing window \"%s\"'%cnum)
scs.kill(cnum)
scs.focus('top')
#.........这里部分代码省略.........
示例4: eval_command
# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import find_new_session [as 别名]
#.........这里部分代码省略.........
cnum = scs.get_number_and_title()[0]
scs.focus('top')
if tui != maxtui:
tui += 1
else:
tui = 1
reset_tui(scs)
if int(cnum) > 1:
scs.focus('bottom')
scs.select(cnum)
scs.focus('top')
elif mode.startswith('L'):
# layout
print2ui('LOGIC: toggling layout')
scs.focus('bottom')
cnum = scs.get_number_and_title()[0]
scs.focus('top')
if tui != 1:
tui -= 1
else:
tui = maxtui
reset_tui(scs)
if int(cnum) > 1:
scs.focus('bottom')
scs.select(cnum)
scs.focus('top')
elif mode.startswith('w'):
# wipe
print2ui('LOGIC: wiping out dead sessions')
menu_tmp_last_selection = -1
scs.wipe()
elif mode.startswith('save') or mode == 'S':
# save
if args[0]:
arg_out = "%s" % args[0]
else:
arg_out = "%s" % last_session
print2ui('LOGIC: saving session as %s' % arg_out)
os.system('screen-session save -S \"%s\" --force --log \"%s\" \"%s\" 1>&- 2>&-' %
(last_session, fifoname2, arg_out))
elif mode.startswith('s'):
# screen
if args and len(args[0]) > 0:
arg = (" ").join(["%s" % v for v in args])
else:
arg = " "
cmd = SCREEN + ' -d -m %s' % arg
print2ui('LOGIC: creating a new session: [%s]' % cmd.strip())
l1 = sc.get_session_list()
os.popen(cmd)
l2 = sc.get_session_list()
newsession = sc.find_new_session(l1, l2)
menu_tmp_last_selection = newsession
print2ui('LOGIC: "%s"' % menu_tmp_last_selection)
return tui_attach_session(scs, newsession, psession)
elif mode.startswith('n'):
# name
if last_session:
print2ui('LOGIC: renaming session to \"%s\"' % args[0])
if scs.sessionname() == last_session:
scs_target = scs
else:
scs_target = ScreenSaver(last_session, '/dev/null',
'/dev/null')
nsessionname = scs_target.sessionname(args[0])
print2ui('LOGIC: new sessionname is now [%s]' % nsessionname)
scs.focus('bottom')
cnum = scs.get_number_and_title()[0]
if psession and psession == last_session:
psession = nsessionname
print2ui('LOGIC: parent session is now [%s]' %
nsessionname)
elif nsessionname == scs.sessionname():
print2ui('LOGIC: THIS is session [%s]' % nsessionname)
else:
scs.screen(SCREEN + ' -x \"%s\"' % nsessionname)
scs.title(nsessionname)
if int(cnum) > 1:
#print2ui('LOGIC: killing window \"%s\"'%cnum)
scs.kill(cnum)
scs.focus('top')
return (None, nsessionname, psession)
elif mode == 'pid':
return ('pid', int(args[0]))
else:
print2ui('LOGIC: no such command')