当前位置: 首页>>代码示例>>Python>>正文


Python GNUScreen.gen_all_windows_fast方法代码示例

本文整理汇总了Python中GNUScreen.gen_all_windows_fast方法的典型用法代码示例。如果您正苦于以下问题:Python GNUScreen.gen_all_windows_fast方法的具体用法?Python GNUScreen.gen_all_windows_fast怎么用?Python GNUScreen.gen_all_windows_fast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GNUScreen的用法示例。


在下文中一共展示了GNUScreen.gen_all_windows_fast方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: renumber

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import gen_all_windows_fast [as 别名]
def renumber(session, datadir):
    ss = ScreenSaver(session, '/dev/null', '/dev/null')
    wins = []
    wins_trans = {}
    for (cwin, cgroupid, ctype, ctty, ctitle) in sc.gen_all_windows_fast(session,
            datadir):
        iwin = int(cwin)
        wins.append((iwin, cgroupid, ctype))
        wins_trans[iwin] = iwin

    wins.sort(key=lambda wins: wins[0])
    print wins_trans
    i = 0
    for (win, groupid, ctype) in wins:
        if wins_trans[win] != i:

            #print("win %d(%d)(%s) as %d"%(wins_trans[win],win,group,i))

            ss.number(str(i), str(wins_trans[win]))
            tmp = wins_trans[win]
            try:
                wins_trans[win] = wins_trans[i]
            except:
                wins_trans[win] = -1
            wins_trans[i] = tmp
        i += 1
    print wins_trans
开发者ID:chronidev,项目名称:screen-session,代码行数:29,代码来源:tools.py

示例2: find_pids_in_windows

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import gen_all_windows_fast [as 别名]
def find_pids_in_windows(session, datadir, pids):
    import getpass
    import os
    tty_and_pids = sc._get_tty_pids_ps_with_cache_gen(getpass.getuser())

    #print(tty_and_pids)

    ttys = []
    for (tty, tpids) in tty_and_pids.items():

        #print('%s %s %s'%(pids,tty,tpids))

        for pid in pids:
            if pid in tpids:
                ttys.append(tty)
    wins = []
    for (cwin, cgroupid, ctype, ctty, ctitle) in sc.gen_all_windows_fast(session,
            datadir):
        try:
            ctty = int(os.path.split(ctty)[1])
            if ctty in ttys:
                wins.append(tuple([cwin, ctitle]))
        except Exception:
            pass
    return wins
开发者ID:chronidev,项目名称:screen-session,代码行数:27,代码来源:tools.py

示例3: subwindows

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import gen_all_windows_fast [as 别名]
def subwindows(session, datadir, groupids):
    ss = ScreenSaver(session)
    bAll = False
    try:
        if groupids[0] in ('cg', 'current', '..'):
            groupids[0] = ss.get_group()[0]
            if groupids[0] == "-1":
                bAll = True
        elif groupids[0] in ('cw', 'current-window', '.'):
            groupids[0] = ss.get_number_and_title()[0]
        elif groupids[0] == 'all':
            bAll = True
    except IndexError:
        bAll = True
    group_wins = {}
    group_groups = {}
    excluded_wins = []
    excluded_groups = []
    for (cwin, cgroupid, ctype, ctty, ctitle) in sc.gen_all_windows_fast(session,
            datadir):
        if ctype == 1:  # group
            if cwin in groupids or bAll or ctitle in groupids:
                excluded_groups.append(cwin)
            try:
                group_groups[cgroupid] += [cwin]
            except:
                group_groups[cgroupid] = [cwin]
        else:

              # anything other than group

            if cwin in groupids or bAll or ctitle in groupids:
                excluded_wins.append(cwin)
            else:
                try:
                    group_wins[cgroupid] += [cwin]
                except:
                    group_wins[cgroupid] = [cwin]
    excluded_groups_tmp = []
    while excluded_groups:
        egroup = excluded_groups.pop()
        if egroup not in excluded_groups_tmp:
            excluded_groups_tmp.append(egroup)
        try:
            ngroups = group_groups[egroup]
            if ngroups:
                for g in ngroups:
                    excluded_groups.append(g)
        except:
            pass
    excluded_groups = excluded_groups_tmp
    for egroup in excluded_groups:
        excluded_wins.append(egroup)
        try:
            for w in group_wins[egroup]:
                excluded_wins.append(w)
        except:
            pass
    return (excluded_groups, excluded_wins)
开发者ID:chronidev,项目名称:screen-session,代码行数:61,代码来源:tools.py

示例4: kill_zombie

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import gen_all_windows_fast [as 别名]
def kill_zombie(session,groupids=[]):
    ss=ScreenSaver(session,'/dev/null','/dev/null')
    if groupids:
        windows=subwindows(session,groupids)[1]
    for cwin,cgroupid,ctype,ctty,ctitle in sc.gen_all_windows_fast(session):
        if ctype==-1:
            if groupids:
                if cwin in windows:
                    ss.kill(cwin)
            else:
                ss.kill(cwin)
开发者ID:brendoncrawford,项目名称:screen-session,代码行数:13,代码来源:tools.py

示例5: subwindows

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import gen_all_windows_fast [as 别名]
def subwindows(session,groupids,datafile=None):
    ss=ScreenSaver(session)
    bAll=False
    if groupids[0] in ('cg','current'):
        groupids[0]=ss.get_group()[0]
    elif groupids[0] in ('cw','current-window'):
        groupids[0]=ss.get_number_and_title()[0]
    elif groupids[0]=='all':
        bAll=True
    group_wins={}
    group_groups={}
    excluded_wins=[]
    excluded_groups=[]
    #for cwin,cgroupid,cgroup,ctty,ctype,ctypestr,ctitle,cfilter,cscroll,ctime in sc.gen_all_windows_full(session):
    for cwin,cgroupid,ctype,ctty,ctitle in sc.gen_all_windows_fast(session,datafile):
        if(ctype==1): # group
            if cwin in groupids or bAll or ctitle in groupids:
                excluded_groups.append(cwin)
            try:
                group_groups[cgroupid]+=[cwin]
            except:
                group_groups[cgroupid]=[cwin]
        else: # anything other than group
            if cwin in groupids or ctitle in groupids:
                excluded_wins.append(cwin)
            else:
                try:
                    group_wins[cgroupid]+=[cwin]
                except:
                    group_wins[cgroupid]=[cwin]
    excluded_groups_tmp=[]
    while excluded_groups:
        egroup=excluded_groups.pop()
        if egroup not in excluded_groups_tmp:
            excluded_groups_tmp.append(egroup)
        try:
            ngroups = group_groups[egroup]
            if ngroups:
                for g in ngroups:
                    excluded_groups.append(g)
        except:
            pass
    excluded_groups = excluded_groups_tmp
    for egroup in excluded_groups:
        excluded_wins.append(egroup)
        try:
            for w in group_wins[egroup]:
                excluded_wins.append(w)
        except:
            pass
    return excluded_groups,excluded_wins
开发者ID:brendoncrawford,项目名称:screen-session,代码行数:53,代码来源:tools.py

示例6: sort

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import gen_all_windows_fast [as 别名]
def sort(session, datadir, key=None):
    ss = ScreenSaver(session, '/dev/null', '/dev/null')
    wins = []
    wins_trans = {}
    groups = {}
    cgroup = None
    for (cwin, cgroupid, ctype, ctty, ctitle) in sc.gen_all_windows_fast(session,
            datadir):
        iwin = int(cwin)
        lastval = (groupid, iwin, ctype, ss.title('', iwin))
        try:
            groups[groupid].append(lastval)
        except:
            groups[groupid] = [lastval]
        wins_trans[iwin] = iwin

    i = 0
    for (group, props) in groups.items():
        try:
            props.sort(key=lambda wins: wins[3].lower())
        except:
            print 'FAIL'
            print str(len(props)) + ' : ' + group + ' : ' + str(props)
            pass

        #print( str(len(props))+' : '+group + ' : ' + str(props))

        for (groupid, win, ctype, title) in props:
            if wins_trans[win] != i:

                #print("win %d(%d)(%s) as %d"%(wins_trans[win],win,group,i))

                ss.number(str(i), str(wins_trans[win]))
                tmp = wins_trans[win]
                try:
                    wins_trans[win] = wins_trans[i]
                except:
                    wins_trans[win] = -1
                wins_trans[i] = tmp
            i += 1
    return
开发者ID:chronidev,项目名称:screen-session,代码行数:43,代码来源:tools.py

示例7: make_group_tabs

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import gen_all_windows_fast [as 别名]
def make_group_tabs(session,groupids,bAll=False):
    group_wins={}
    group_groups={}
    excluded_wins=[]
    excluded_groups=[]
    for cwin,cgroupid,ctype,ctty,ctitle in sc.gen_all_windows_fast(session):
        if(ctype==1): # group
            if cwin in groupids or bAll:
                excluded_groups.append(cwin)
            try:
                group_groups[cgroupid]+=[cwin]
            except:
                group_groups[cgroupid]=[cwin]
        else: # anything other than group
            if cwin in groupids:
                excluded_wins.append(cwin)
            else:
                try:
                    group_wins[cgroupid]+=[cwin]
                except:
                    group_wins[cgroupid]=[cwin]
    return group_groups,group_wins,excluded_groups,excluded_wins
开发者ID:brendoncrawford,项目名称:screen-session,代码行数:24,代码来源:tools.py


注:本文中的GNUScreen.gen_all_windows_fast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。