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


Python GNUScreen.cleanup方法代码示例

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


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

示例1: load

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import cleanup [as 别名]
    def load(self):
        if "all" in self.force_start:
            self.primer_arg += "S"
            self.force_start = []
        if "all" in self.scroll:
            self._scrollfile = None
        out('session "%s" loading "%s"' % (self.pid, os.path.join(self.basedir, self.savedir)))

        # check if the saved session exists and get the biggest saved window number and a number of saved windows

        maxnewwindow = 0
        newwindows = 0
        try:
            winlist = list(glob.glob(os.path.join(self.basedir, self.savedir, "win_*")))
            newwindows = len(winlist)
            out("%d new windows" % newwindows)
        except Exception:
            sys.stderr.write("Unable to open winlist.\n")
            return 1

        # keep original numbering, move existing windows

        self.homewindow = self.number()

        if self.exact:
            maxnewwindow = -1
            for w in winlist:
                try:
                    w = int(w.rsplit("_", 1)[1])
                    if w > maxnewwindow:
                        maxnewwindow = w
                except:
                    pass

            out("Biggest new window number: %d" % maxnewwindow)
            if self.enable_layout:
                self.__remove_all_layouts()
            self.__move_all_windows(maxnewwindow + 1, self.group_other, False)

        out("\nLoading windows:")
        self.__load_screen()

        if self.enable_layout:
            out("\nLoading layouts:")
            try:
                self.__load_layouts()
            except:
                sys.stderr.write("Layouts loading failed!\n")
                # raise

        self.__restore_mru()
        sc.cleanup()

        return 0
开发者ID:rlabok,项目名称:screen-session,代码行数:56,代码来源:ScreenSaver.py

示例2: cleanup

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import cleanup [as 别名]
def cleanup():
    cmd = ''
    f = open(sourcefile, 'w')
    for (i, w) in enumerate(win_history):
        if w == "-1":
            w = "-"
        f.write("""select %s
at \"%s\#\" kill
focus
""" % (w, wins[i]))
    f.flush()
    f.close()
    scs.source(sourcefile)
    scs.focusminsize(focusminsize)
    sc.cleanup()
    remove(sourcefile)
开发者ID:chronidev,项目名称:screen-session,代码行数:18,代码来源:regions.py

示例3: prepare_windows

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import cleanup [as 别名]
def prepare_windows(scs):
    global focusminsize
    regions = None
    regions = sc.get_regions(sc.dumpscreen_layout(scs.pid))
    sc.cleanup()
    focusminsize = "%s %s" % (regions.focusminsize_x, regions.focusminsize_x)
    regions_c = len(regions.regions)
    focus_offset = regions.focus_offset
    scs.focusminsize('0 0')
    this_win_history = []
    cmd = ''
    f = open(sourcefile, 'w')
    for i in range(0, regions_c):
        f.write("""screen -t scs-regions-helper %s %s %s %d
focus
""" %
                (subprogram, subprogram_args, inputfile, i))
    f.flush()
    f.close
    scs.source(sourcefile, "screen-session regions")
    remove(sourcefile)

    regions_n = []
    regions_n = sc.get_regions(sc.dumpscreen_layout(scs.pid))
    sc.cleanup()

    for r in (regions.regions)[focus_offset:]:
        this_win_history.append(r[0])
    for r in (regions.regions)[:focus_offset]:
        this_win_history.append(r[0])

    new_windows = []
    for r in (regions_n.regions)[focus_offset:]:
        new_windows.append(r[0])
    for r in (regions_n.regions)[:focus_offset]:
        new_windows.append(r[0])

    return (this_win_history, new_windows, regions_c)
开发者ID:chronidev,项目名称:screen-session,代码行数:40,代码来源:regions.py

示例4: out

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import cleanup [as 别名]
        if ret:
            sys.stderr.write('session saving failed\n')
            scs.Xecho("screen-session saving FAILED")
        else:
            out('compressing...')
            scs.Xecho("screen-session compressing...")
            removeit(os.path.join(home, projectsdir, savedir_real))
            removeit(os.path.join(util.tmpdir, savedir_real))
            archiveme(util.tmpdir, home, projectsdir, savedir_real, util.archiveend,
                      savedir_real + '__tmp/*')
            removeit(os.path.join(home, projectsdir, savedir_tmp))
            removeit(os.path.join(util.tmpdir, savedir_tmp))
            scs.savedir = savedir_real
            savedir = savedir_real
            sc.cleanup()
            out('session "%s"' % scs.pid)
            out('saved as "%s"' % scs.savedir)
            scs.Xecho("screen-session finished saving as \"%s\"" %
                      savedir)
    elif mode == 2:  #mode load

        #cleanup old temporary files and directories

        cleantmp(util.tmpdir, home, projectsdir, util.archiveend, scs.blacklistfile,
                 500)

        # unpack and load

        try:
            unpackme(home, projectsdir, savedir, util.archiveend, util.tmpdir)
开发者ID:chronidev,项目名称:screen-session,代码行数:32,代码来源:screen_saver.py

示例5: nest_layout

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import cleanup [as 别名]
def nest_layout(session, src_layuot, dst_layout):
    src_dumpfile = os.path.join(tmpdir_source, 'nest_layout-dump-%d' % os.getpid())

    if not os.path.exists(tmpdir_source):
        os.makedirs(tmpdir_source)

    scs = ScreenSaver(session)

    print('layouts src: %s dst: %s' % (src_layout, dst_layout))

    regions_file_dst = regions_file = sc.dumpscreen_layout(scs.pid)
    regions_dst = sc.get_regions(regions_file)

    dst_focusminsize = "%s %s" % (regions_dst.focusminsize_x, regions_dst.focusminsize_y)
    dst_rsize = (int(regions_dst.regions[regions_dst.focus_offset][1]),
                int(regions_dst.regions[regions_dst.focus_offset][2]))
    dst_term_size = (int(regions_dst.term_size_x),
                    int(regions_dst.term_size_y))
    scs.layout('select %s' % src_layout, False)

    scs.layout('dump %s' % src_dumpfile, False)

    regions_file_src = sc.dumpscreen_layout(scs.pid)
    regions_src = sc.get_regions(regions_file_src)

    src_term_size = (int(regions_src.term_size_x), int(regions_src.term_size_y))

    print ('dst_rsize: %s' % str(dst_rsize))
    print ('src_term_size: %s' % str(src_term_size))

    scs.layout('select %s' % dst_layout, False)
    
    regions_new = sc.Regions()
    regions_new.focus_offset =  regions_dst.focus_offset + regions_src.focus_offset
    regions_new.term_size_x = regions_dst.term_size_x
    regions_new.term_size_y = regions_dst.term_size_y
    regions_new.focusminsize_x = regions_dst.focusminsize_x
    regions_new.focusminsize_y = regions_dst.focusminsize_y
    regions_new.regions = regions_dst.regions[:regions_dst.focus_offset]

    for (window, sizex, sizey) in regions_src.regions:
        print('SRC REGION' + str((window,sizex,sizey)))
        x = (int(sizex) * dst_rsize[0]) / src_term_size[0]
        y = (int(sizey) * dst_rsize[1]) / src_term_size[1]
        print( '%s * %d / %d = %d' % (sizex, dst_rsize[0], src_term_size[0], x))
        print( '%s * %d / %d = %d' % (sizey, dst_rsize[1], src_term_size[0], y))
        regions_new.regions.append((window, str(x), str(y)))

    regions_new.regions = regions_new.regions + regions_dst.regions[regions_dst.focus_offset+1:]
    
    print('destination regions: '+ str(regions_dst.regions))
    print('source regions: ' + str(regions_src.regions))
    print('new regions: ' + str(regions_new.regions))

    sc.layout_begin(session)
    sc.layout_load_dump(open(src_dumpfile, 'r'))
    sc.layout_load_regions(regions_new, None, dst_term_size[0], dst_term_size[1])
    sc.layout_end()

    remove(src_dumpfile)
    remove(regions_file_dst)
    remove(regions_file_src)
    sc.cleanup()
开发者ID:chronidev,项目名称:screen-session,代码行数:65,代码来源:nest_layout.py

示例6: cleanup

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import cleanup [as 别名]
def cleanup():
    sc.cleanup()
开发者ID:chronidev,项目名称:screen-session,代码行数:4,代码来源:tools.py

示例7: run

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import cleanup [as 别名]
def run(session, requirecleanup_win, requirecleanup_lay, curwin, curlay,
        height, select_other = False):
    global lock_and_com_file, mru_file
    lltmpdir = os.path.join(tmpdir, '___layoutlist')
    try:
        os.makedirs(lltmpdir)
    except:
        pass

    signal.signal(signal.SIGINT, handler)
    session = session.split('.', 1)[0]

    ret = 0
    ss = ScreenSaver(session)
    wnum = os.getenv('WINDOW')
    if requirecleanup_lay:
        lnum = ss.get_layout_number()[0]
    else:
        lnum = None

    mru_file = os.path.join(lltmpdir, '%s_MRU' % session)
    if select_other:
        mru_layouts = pickle.load(open(mru_file, 'r'))
        num, title = mru_layouts[1]
        tmp = mru_layouts[0]
        mru_layouts[0] = mru_layouts[1]
        mru_layouts[1] = tmp
        ss.command_at(False, 'eval "layout select %s" "layout title"' %
                      num)
        pickle.dump(mru_layouts, open(mru_file, 'w'))
        return ret
    if NO_END:
        lock_and_com_file = os.path.join(lltmpdir, '%s' %
                session)
        f = open(lock_and_com_file, 'w')
        f.write(str(os.getpid()) + '\n')
        if requirecleanup_win and not requirecleanup_lay:
            f.write(wnum + '\n')
        else:
            f.write('-1\n')
        if requirecleanup_lay:
            f.write(lnum + '\n')
        else:
            f.write('-1\n')
        f.close()

    try:
        try:
            layinfo = list(sc.gen_layout_info(ss, sc.dumpscreen_layout_info(ss)))
        finally:
            sc.cleanup()
    except:
        sys.stderr.write('Layouts dumping error.\n')
        return 1
    screen = curses.initscr()
    (laytable, pos_start) = create_table(ss, screen, curlay, layinfo,
            lnum, height)
    try:
        curses.start_color()
    except:
        curses.endwin()
        sys.stderr.write('start_color() failed!\n')
        return 1

    curses.noecho()

    #screen.notimeout(1)

    try:
        choice = menu_table(
            ss,
            screen,
            lnum,
            curwin,
            curlay,
            layinfo,
            laytable,
            pos_start[0],
            pos_start[1],
            height,
            )
        if requirecleanup_lay and choice == lnum:
            choice = curlay
    except Exception:
        import traceback
        traceback.print_exc(file=sys.stderr)
        choice = curlay
        ret = 1
    curses.endwin()
    if NO_END:
        from util import remove
        remove(lock_and_com_file)
    if requirecleanup_lay:
        ss.command_at(False,
                      'eval "layout select %s" "layout remove %s" "at \"%s\#\" kill" "layout title"' %
                      (choice, lnum, wnum))
    elif requirecleanup_win:
        ss.command_at(False,
                      'eval "select %s" "layout select %s" "at \"%s\#\" kill" "layout title"' %
                      (curwin, choice, wnum))
#.........这里部分代码省略.........
开发者ID:chronidev,项目名称:screen-session,代码行数:103,代码来源:layoutlist_agent.py

示例8: menu_table

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import cleanup [as 别名]

#.........这里部分代码省略.........
            not searching_num:
            if laytable_c:
                current_view = 'n'
                pos_x = pos_x_c
                pos_y = pos_y_c
                pos_x_c = pos_y_c = layinfo_c = laytable_c = None
            (y, x) = screen.getmaxyx()
            searching_title = False
            searching_num = False
            try:
                try:
                    try:
                        if NO_END:
                            f = open(lock_and_com_file, 'r')
                            from string import strip as str_strip

                            #pid,cwin,clay,MAXTITLELEN,height = map( str_strip,f.readlines() )

                            nd = map(str_strip, f.readlines())
                            curwin = nd[3]
                            sel_num = curlay = nd[4]
                            MAXTITLELEN = int(nd[5])
                            height = int(nd[6])
                            f.close()
                            screen.erase()
                            mru_add(curlay)
                    except:
                        pass
                    layinfo = list(sc.gen_layout_info(ss, sc.dumpscreen_layout_info(ss)))
                    (laytable, pos_start) = create_table(ss, screen,
                            curlay, layinfo, tmplay, height)
                    errormsg = 'Refreshed'
                finally:
                    sc.cleanup()
            except:
                errormsg = 'Layouts dumping error.'
        elif searching_title and x == ord('\n'):
            searching_title = False
            n_search_title = search_title
            findNext = True
        elif x == 27:

                      # Escape key

            searching_num = False
            searching_title = False
            search_num = None
            search_title = None
            errormsg = 'Canceled'
            n_search_title = search_title
        elif x == curses.KEY_BACKSPACE:
            try:
                if len(search_num) == 0:
                    raise Exception
                search_num = search_num[:-1]
            except:
                searching_num = False
                pass
            try:
                if len(search_title) == 0:
                    raise Exception
                search_title = search_title[:-1]
            except:
                searching_title = False
                pass
        elif searching_title:
开发者ID:chronidev,项目名称:screen-session,代码行数:70,代码来源:layoutlist_agent.py


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