Python System 模块,Console() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用System.Console()

项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def rectangle(self, rect, attr=None, fill=' '):
        '''Fill Rectangle.'''
        pass
        oldtop=self.WindowTop
        oldpos=self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill=fill[:1]*abs(x1-x0)
        else:
            rowfill=' '*abs(x1-x0)
        for y in range(y0, y1):
                System.Console.SetCursorPosition(x0,y)
                self.write_color(rowfill,attr)
        self.pos(*oldpos)
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def install_readline(hook):
    def hook_wrap():
        try:
            res=hook()
        except KeyboardInterrupt,x:   #this exception does not seem to be caught
            res=""
        except EOFError:
            return None
        if res[-1:]=="\n":
            return res[:-1]
        else:
            return res
    class IronPythonWrapper(IronPythonConsole.IConsole):
        def ReadLine(self,autoIndentSize): 
            return hook_wrap()
        def Write(self,text, style):
            System.Console.Write(text)
        def WriteLine(self,text, style): 
            System.Console.WriteLine(text)
    IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
项目:isf    作者:w3h    | 项目源码 | 文件源码
def rectangle(self, rect, attr=None, fill=' '):
        '''Fill Rectangle.'''
        oldtop = self.WindowTop
        oldpos = self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill = fill[:1] * abs(x1 - x0)
        else:
            rowfill = ' ' * abs(x1 - x0)
        for y in range(y0, y1):
                System.Console.SetCursorPosition(x0, y)
                self.write_color(rowfill, attr)
        self.pos(*oldpos)
项目:isf    作者:w3h    | 项目源码 | 文件源码
def install_readline(hook):
    def hook_wrap():
        try:
            res = hook()
        except KeyboardInterrupt as x:   #this exception does not seem to be caught
            res = ""
        except EOFError:
            return None
        if res[-1:] == "\n":
            return res[:-1]
        else:
            return res
    class IronPythonWrapper(IronPythonConsole.IConsole):
        def ReadLine(self, autoIndentSize): 
            return hook_wrap()
        def Write(self, text, style):
            System.Console.Write(text)
        def WriteLine(self, text, style): 
            System.Console.WriteLine(text)
    IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def rectangle(self, rect, attr=None, fill=' '):
        '''Fill Rectangle.'''
        oldtop = self.WindowTop
        oldpos = self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill = fill[:1] * abs(x1 - x0)
        else:
            rowfill = ' ' * abs(x1 - x0)
        for y in range(y0, y1):
            System.Console.SetCursorPosition(x0, y)
            self.write_color(rowfill, attr)
        self.pos(*oldpos)
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def install_readline(hook):
    def hook_wrap():
        try:
            res = hook()
        except KeyboardInterrupt as x:  #this exception does not seem to be caught
            res = ""
        except EOFError:
            return None
        if res[-1:] == "\n":
            return res[:-1]
        else:
            return res

    class IronPythonWrapper(IronPythonConsole.IConsole):
        def ReadLine(self, autoIndentSize):
            return hook_wrap()

        def Write(self, text, style):
            System.Console.Write(text)

        def WriteLine(self, text, style):
            System.Console.WriteLine(text)

    IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
项目:shadowbroker-auto    作者:wrfly    | 项目源码 | 文件源码
def rectangle(self, rect, attr=None, fill=u' '):
        u'''Fill Rectangle.'''
        oldtop = self.WindowTop
        oldpos = self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill = fill[:1] * abs(x1 - x0)
        else:
            rowfill = u' ' * abs(x1 - x0)
        for y in range(y0, y1):
                System.Console.SetCursorPosition(x0, y)
                self.write_color(rowfill, attr)
        self.pos(*oldpos)
项目:shadowbroker-auto    作者:wrfly    | 项目源码 | 文件源码
def install_readline(hook):
    def hook_wrap():
        try:
            res = hook()
        except KeyboardInterrupt,x:   #this exception does not seem to be caught
            res = u""
        except EOFError:
            return None
        if res[-1:] == u"\n":
            return res[:-1]
        else:
            return res
    class IronPythonWrapper(IronPythonConsole.IConsole):
        def ReadLine(self, autoIndentSize): 
            return hook_wrap()
        def Write(self, text, style):
            System.Console.Write(text)
        def WriteLine(self, text, style): 
            System.Console.WriteLine(text)
    IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
项目:shadowbroker-auto    作者:wrfly    | 项目源码 | 文件源码
def rectangle(self, rect, attr=None, fill=' '):
        '''Fill Rectangle.'''
        pass
        oldtop=self.WindowTop
        oldpos=self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill=fill[:1]*abs(x1-x0)
        else:
            rowfill=' '*abs(x1-x0)
        for y in range(y0, y1):
                System.Console.SetCursorPosition(x0,y)
                self.write_color(rowfill,attr)
        self.pos(*oldpos)
项目:shadowbroker-auto    作者:wrfly    | 项目源码 | 文件源码
def install_readline(hook):
    def hook_wrap():
        try:
            res=hook()
        except KeyboardInterrupt,x:   #this exception does not seem to be caught
            res=""
        except EOFError:
            return None
        if res[-1:]=="\n":
            return res[:-1]
        else:
            return res
    class IronPythonWrapper(IronPythonConsole.IConsole):
        def ReadLine(self,autoIndentSize): 
            return hook_wrap()
        def Write(self,text, style):
            System.Console.Write(text)
        def WriteLine(self,text, style): 
            System.Console.WriteLine(text)
    IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
项目:themole    作者:tiankonguse    | 项目源码 | 文件源码
def rectangle(self, rect, attr=None, fill=' '):
        '''Fill Rectangle.'''
        oldtop = self.WindowTop
        oldpos = self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill = fill[:1] * abs(x1 - x0)
        else:
            rowfill = ' ' * abs(x1 - x0)
        for y in range(y0, y1):
                System.Console.SetCursorPosition(x0, y)
                self.write_color(rowfill, attr)
        self.pos(*oldpos)
项目:themole    作者:tiankonguse    | 项目源码 | 文件源码
def install_readline(hook):
    def hook_wrap():
        try:
            res = hook()
        except KeyboardInterrupt as x:   #this exception does not seem to be caught
            res = ""
        except EOFError:
            return None
        if res[-1:] == "\n":
            return res[:-1]
        else:
            return res
    class IronPythonWrapper(IronPythonConsole.IConsole):
        def ReadLine(self, autoIndentSize): 
            return hook_wrap()
        def Write(self, text, style):
            System.Console.Write(text)
        def WriteLine(self, text, style): 
            System.Console.WriteLine(text)
    IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def __init__(self, newbuffer=0):
        '''Initialize the Console object.

        newbuffer=1 will allocate a new buffer so the old content will be restored
        on exit.
        '''
        self.serial=0
        self.attr = System.Console.ForegroundColor
        self.saveattr = winattr[str(System.Console.ForegroundColor).lower()]
        self.savebg=System.Console.BackgroundColor
        log('initial attr=%s' % self.attr)
        log_sock("%s"%self.saveattr)
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def _get(self):
        top=System.Console.WindowTop
        log_sock("WindowTop:%s"%top,"console")
        return top
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def _set(self,value):
        top=System.Console.WindowTop
        log_sock("Set WindowTop:old:%s,new:%s"%(top,value),"console")
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def pos(self, x=None, y=None):
        '''Move or query the window cursor.'''
        if x is not None:
            System.Console.CursorLeft=x
        else:
            x=System.Console.CursorLeft
        if y is not None:
            System.Console.CursorTop=y
        else:
            y=System.Console.CursorTop
        return x,y
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def home(self):
        '''Move to home.'''
        self.pos(0,0)

# Map ANSI color escape sequences into Windows Console Attributes
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def page(self, attr=None, fill=' '):
        '''Fill the entire screen.'''
        System.Console.Clear()
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def clear_to_end_of_window(self):
        oldtop=self.WindowTop
        lastline=self.WindowTop+System.Console.WindowHeight
        pos=self.pos()
        w,h=self.size()
        length=w-pos[0]+min((lastline-pos[1]-1),5)*w-1
        self.write_color(length*" ")
        self.pos(*pos)
        self.WindowTop=oldtop
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def scroll_window(self, lines):
        '''Scroll the window by the indicated number of lines.'''
        top=self.WindowTop+lines
        if top<0:
            top=0
        if top+System.Console.WindowHeight>System.Console.BufferHeight:
            top=System.Console.BufferHeight
        self.WindowTop=top
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def getkeypress(self):
        '''Return next key press event from the queue, ignoring others.'''
        ck=System.ConsoleKey
        while 1:
            e = System.Console.ReadKey(True)
            if e.Key == System.ConsoleKey.PageDown: #PageDown
                self.scroll_window(12)
            elif e.Key == System.ConsoleKey.PageUp:#PageUp
                self.scroll_window(-12)
            elif str(e.KeyChar)=="\000":#Drop deadkeys
                log_sock("Deadkey: %s"%e)
                return event(self,e)
                pass
            else:
                return event(self,e)
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def size(self, width=None, height=None):
        '''Set/get window size.'''
        sc=System.Console


        if width is not None and height is not None:
            sc.BufferWidth,sc.BufferHeight=width,height
        else:
            return sc.BufferWidth,sc.BufferHeight

        if width is not None and height is not None:
            sc.WindowWidth,sc.WindowHeight=width,height
        else:
            return sc.WindowWidth-1,sc.WindowHeight-1
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def cursor(self, visible=True, size=None):
        '''Set cursor on or off.'''
        System.Console.CursorVisible=visible
项目:PyMal    作者:cysinfo    | 项目源码 | 文件源码
def bell(self):
        System.Console.Beep()
项目:isf    作者:w3h    | 项目源码 | 文件源码
def __init__(self, newbuffer=0):
        '''Initialize the Console object.

        newbuffer=1 will allocate a new buffer so the old content will be restored
        on exit.
        '''
        self.serial = 0
        self.attr = System.Console.ForegroundColor
        self.saveattr = winattr[str(System.Console.ForegroundColor).lower()]
        self.savebg = System.Console.BackgroundColor
        log('initial attr=%s' % self.attr)
项目:isf    作者:w3h    | 项目源码 | 文件源码
def _get(self):
        top = System.Console.WindowTop
        log("WindowTop:%s"%top)
        return top
项目:isf    作者:w3h    | 项目源码 | 文件源码
def _set(self, value):
        top = System.Console.WindowTop
        log("Set WindowTop:old:%s,new:%s"%(top, value))
项目:isf    作者:w3h    | 项目源码 | 文件源码
def pos(self, x=None, y=None):
        '''Move or query the window cursor.'''
        if x is not None:
            System.Console.CursorLeft=x
        else:
            x = System.Console.CursorLeft
        if y is not None:
            System.Console.CursorTop=y
        else:
            y = System.Console.CursorTop
        return x, y
项目:isf    作者:w3h    | 项目源码 | 文件源码
def home(self):
        '''Move to home.'''
        self.pos(0, 0)

# Map ANSI color escape sequences into Windows Console Attributes
项目:isf    作者:w3h    | 项目源码 | 文件源码
def page(self, attr=None, fill=' '):
        '''Fill the entire screen.'''
        System.Console.Clear()
项目:isf    作者:w3h    | 项目源码 | 文件源码
def clear_to_end_of_window(self):
        oldtop = self.WindowTop
        lastline = self.WindowTop+System.Console.WindowHeight
        pos = self.pos()
        w, h = self.size()
        length = w - pos[0] + min((lastline - pos[1] - 1), 5) * w - 1
        self.write_color(length * " ")
        self.pos(*pos)
        self.WindowTop = oldtop
项目:isf    作者:w3h    | 项目源码 | 文件源码
def scroll_window(self, lines):
        '''Scroll the window by the indicated number of lines.'''
        top = self.WindowTop + lines
        if top < 0:
            top = 0
        if top + System.Console.WindowHeight > System.Console.BufferHeight:
            top = System.Console.BufferHeight
        self.WindowTop = top
项目:isf    作者:w3h    | 项目源码 | 文件源码
def getkeypress(self):
        '''Return next key press event from the queue, ignoring others.'''
        ck = System.ConsoleKey
        while 1:
            e = System.Console.ReadKey(True)
            if e.Key == System.ConsoleKey.PageDown: #PageDown
                self.scroll_window(12)
            elif e.Key == System.ConsoleKey.PageUp:#PageUp
                self.scroll_window(-12)
            elif str(e.KeyChar) == "\000":#Drop deadkeys
                log("Deadkey: %s"%e)
                return event(self, e)
            else:
                return event(self, e)
项目:isf    作者:w3h    | 项目源码 | 文件源码
def size(self, width=None, height=None):
        '''Set/get window size.'''
        sc = System.Console
        if width is not None and height is not None:
            sc.BufferWidth, sc.BufferHeight = width,height
        else:
            return sc.BufferWidth, sc.BufferHeight

        if width is not None and height is not None:
            sc.WindowWidth, sc.WindowHeight = width,height
        else:
            return sc.WindowWidth - 1, sc.WindowHeight - 1
项目:isf    作者:w3h    | 项目源码 | 文件源码
def cursor(self, visible=True, size=None):
        '''Set cursor on or off.'''
        System.Console.CursorVisible = visible
项目:isf    作者:w3h    | 项目源码 | 文件源码
def bell(self):
        System.Console.Beep()
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def __init__(self, newbuffer=0):
        '''Initialize the Console object.

        newbuffer=1 will allocate a new buffer so the old content will be restored
        on exit.
        '''
        self.serial = 0
        self.attr = System.Console.ForegroundColor
        self.saveattr = winattr[str(System.Console.ForegroundColor).lower()]
        self.savebg = System.Console.BackgroundColor
        log('initial attr=%s' % self.attr)
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def _get(self):
        top = System.Console.WindowTop
        log("WindowTop:%s" % top)
        return top
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def _set(self, value):
        top = System.Console.WindowTop
        log("Set WindowTop:old:%s,new:%s" % (top, value))
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def pos(self, x=None, y=None):
        '''Move or query the window cursor.'''
        if x is not None:
            System.Console.CursorLeft = x
        else:
            x = System.Console.CursorLeft
        if y is not None:
            System.Console.CursorTop = y
        else:
            y = System.Console.CursorTop
        return x, y
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def home(self):
        '''Move to home.'''
        self.pos(0, 0)

# Map ANSI color escape sequences into Windows Console Attributes
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def page(self, attr=None, fill=' '):
        '''Fill the entire screen.'''
        System.Console.Clear()
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def clear_to_end_of_window(self):
        oldtop = self.WindowTop
        lastline = self.WindowTop + System.Console.WindowHeight
        pos = self.pos()
        w, h = self.size()
        length = w - pos[0] + min((lastline - pos[1] - 1), 5) * w - 1
        self.write_color(length * " ")
        self.pos(*pos)
        self.WindowTop = oldtop
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def scroll_window(self, lines):
        '''Scroll the window by the indicated number of lines.'''
        top = self.WindowTop + lines
        if top < 0:
            top = 0
        if top + System.Console.WindowHeight > System.Console.BufferHeight:
            top = System.Console.BufferHeight
        self.WindowTop = top
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def getkeypress(self):
        '''Return next key press event from the queue, ignoring others.'''
        ck = System.ConsoleKey
        while 1:
            e = System.Console.ReadKey(True)
            if e.Key == System.ConsoleKey.PageDown:  #PageDown
                self.scroll_window(12)
            elif e.Key == System.ConsoleKey.PageUp:  #PageUp
                self.scroll_window(-12)
            elif str(e.KeyChar) == "\000":  #Drop deadkeys
                log("Deadkey: %s" % e)
                return event(self, e)
            else:
                return event(self, e)
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def size(self, width=None, height=None):
        '''Set/get window size.'''
        sc = System.Console
        if width is not None and height is not None:
            sc.BufferWidth, sc.BufferHeight = width, height
        else:
            return sc.BufferWidth, sc.BufferHeight

        if width is not None and height is not None:
            sc.WindowWidth, sc.WindowHeight = width, height
        else:
            return sc.WindowWidth - 1, sc.WindowHeight - 1
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def cursor(self, visible=True, size=None):
        '''Set cursor on or off.'''
        System.Console.CursorVisible = visible
项目:OWASP-ZSC-API    作者:viraintel    | 项目源码 | 文件源码
def bell(self):
        System.Console.Beep()
项目:shadowbroker-auto    作者:wrfly    | 项目源码 | 文件源码
def __init__(self, newbuffer=0):
        u'''Initialize the Console object.

        newbuffer=1 will allocate a new buffer so the old content will be restored
        on exit.
        '''
        self.serial = 0
        self.attr = System.Console.ForegroundColor
        self.saveattr = winattr[str(System.Console.ForegroundColor).lower()]
        self.savebg = System.Console.BackgroundColor
        log(u'initial attr=%s' % self.attr)
项目:shadowbroker-auto    作者:wrfly    | 项目源码 | 文件源码
def _get(self):
        top = System.Console.WindowTop
        log(u"WindowTop:%s"%top)
        return top