示例#1
0
文件: conio.py 项目: chyser/bin
    def __init__(self):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        object.__init__(self)
        self.origCursor = 1
        self.curCursor = 1
        self.origState = wc.gettextinfo()[4] & 0x00FF
        t = wc.gettextinfo()

        self.sx = 0
        self.sy = 0
        self.ex = t[2]
        self.ey = t[3]
        self.wd = t[2]
        self.ht = t[3]
示例#2
0
文件: conio.py 项目: chyser/bin
    def __init__(self):
        #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        object.__init__(self)
        self.origCursor = 1
        self.curCursor = 1
        self.origState = wc.gettextinfo()[4] & 0x00FF
        t = wc.gettextinfo()

        self.sx = 0
        self.sy = 0
        self.ex = t[2]
        self.ey = t[3]
        self.wd = t[2]
        self.ht = t[3]
示例#3
0
文件: logger.py 项目: chipsec/chipsec
 def log_color ( self, message, record ):
     """ Testing """
     if record.levelno in self.LEVEL_ID:
         old_setting = WConio.gettextinfo()[4] & 0x00FF
         WConio.textcolor( self.LEVEL_ID[record.levelno] )
         return message
     WConio.textcolor( old_setting )
示例#4
0
def writeout(s, o, c=True, replace_lines=0):
    '''Writes out a string to the stdout or appends it to a file'''
    if not o:

        if c:
            s = deutfize(s)

        if replace_lines and sys.platform in WINDOWS:
            try:
                import WConio
                pos = WConio.wherex(), WConio.wherey()
                for i in range(replace_lines):
                    sys.stdout.write(' '*(WConio.gettextinfo()[-3]-1) + '\n')
                WConio.gotoxy(pos[0], pos[1])
            except:
                replace_lines=0

        sys.stdout.write(s)

        if replace_lines and sys.platform in WINDOWS:
            WConio.gotoxy(pos[0], pos[1])

    else:
        with open(o, mode='a', encoding='utf-8') as o_file:
            o_file.write(s)
示例#5
0
def main():

    USB1208LS=MCCDAQ()

    WConio.clrscr() 
    print "Demonstration of cbDIn()\n"\
           "Press any key to quit.\n\n"\
           "You may change a bit by applying a TTL high or\n"\
           "a TTL low to the corresponding pin# on port A.\n"

    print "The first 7 bits are: pin32 to pin 39\n"\
           "0  1  2  3  4  5  6  7\n "
    (a,a,a,a,a,a,a,a,a,a,row)=WConio.gettextinfo() 
    
    USB1208LS.DConfigPort (0, FIRSTPORTB, DIGITALIN)

    while (WConio.kbhit()==False):
        DataValue=USB1208LS.DIn(0, FIRSTPORTB)
        WConio.gotoxy(0,row)  
        print "Port Value: %d         " %DataValue

        # parse DataValue into bit values to indicate on/off status */
        for I in range (8):
            if (DataValue & 2**I):  BitValue = 1
            else:  BitValue = 0
            print "%d " %BitValue,
示例#6
0
 def log_color ( self, message, record ):
     """ Testing """
     if record.levelno in self.LEVEL_ID:
         old_setting = WConio.gettextinfo()[4] & 0x00FF
         WConio.textcolor( self.LEVEL_ID[record.levelno] )
         return message
     WConio.textcolor( old_setting )
示例#7
0
 def log_color(fg_color, text):
     """
     Store current attribute settings
     """
     old_setting = WConio.gettextinfo()[4] & 0x00FF
     WConio.textattr(COLOR_ID[fg_color])
     print text
     WConio.textattr(old_setting)
示例#8
0
 def log_color( fg_color, text ):
     """
     Store current attribute settings
     """
     old_setting = WConio.gettextinfo()[4] & 0x00FF
     WConio.textattr( COLOR_ID[ fg_color ] )
     print text
     WConio.textattr( old_setting )
示例#9
0
def _write_color_nt(fp, text, color):
    """Assumes WConio has been imported at module level."""
    oldcolor = WConio.gettextinfo()[4]
    oldtextcolor = oldcolor & 0x000F
    if ";" in color:
        color = color.split(";", 1)[1]
    WConio.textcolor(WConioColor.get(color, oldtextcolor))
    fp.write(text)
    WConio.textattr(oldcolor)
示例#10
0
    def __init__(self, display_keys=True, display_header=True, outfile=sys.stdout):
        self.display_keys = display_keys
        self.display_header = display_header
        self.interactive = False
        self.print_lines = 0
        self.termrows = 0
        self.outfile = outfile
        # XXX if stdin is not a tty, it seems that the command fails.

        if os.isatty(sys.stdout.fileno()) and os.isatty(sys.stdin.fileno()):
            if sys.platform == 'win32':
                self.termrows = WConio.gettextinfo()[8]
            else:
                self.termrows = int(subprocess.Popen('stty size', shell=True, stdout=subprocess.PIPE).communicate()[0].split()[0])
示例#11
0
文件: menu.py 项目: cheeriobus/idler
def menu(options, deletepreviouslines=0):
    _sel()
    _otr() # Initialize terminal conditions

    home = WConio.wherey() # Gets original y coordinate
    startup = home - deletepreviouslines - 2
    y = 0
    draw(options, y)
    multiple = []
    escolha = ''
    while escolha != '\r':  #\r = enter
        escolha = WConio.getkey()

        if escolha == 'up':
                if y != 0:
                    y-=1

        if escolha == 'down':
                if y != len(options)-1:
                    y+=1

        if escolha == '+':
            multiple.append(options[y])
            if options[y][-1] != '+':
                options[y] += '+'

        # To do: add option to remove from list

        WConio.gotoxy(0, home)
        draw(options,y)

    _otr()

    for i in range(WConio.wherey(), startup, -1):
        WConio.gotoxy(0, i)
        sys.stdout.write(' '*WConio.gettextinfo()[8])
    WConio.gotoxy(0, startup)

    if len(multiple)>0:
        return multiple
    else:
        return [options[y]]
示例#12
0
    def __init__(self,
                 display_keys=True,
                 display_header=True,
                 outfile=sys.stdout):
        self.display_keys = display_keys
        self.display_header = display_header
        self.interactive = False
        self.print_lines = 0
        self.termrows = 0
        self.outfile = outfile
        # XXX if stdin is not a tty, it seems that the command fails.

        if os.isatty(sys.stdout.fileno()) and os.isatty(sys.stdin.fileno()):
            if sys.platform == 'win32':
                self.termrows = WConio.gettextinfo()[8]
            else:
                self.termrows = int(
                    subprocess.Popen(
                        'stty size', shell=True,
                        stdout=subprocess.PIPE).communicate()[0].split()[0])
示例#13
0
 def emit(self, record):
     WConio = self.WConio
     try:
         msg = self.format(record)
         levelname = record.levelname
         out = sys.__stdout__  # in case redirected by filelogger, etc
         if levelname in msg:
             part1, part2 = msg.split(levelname, 1)
             out.write(part1)
             out.flush()
             saved_color = WConio.gettextinfo()[4]
             WConio.textattr(self.colormap.get(levelname, WConio.LIGHTGREY))
             if levelname == 'CRITICAL': WConio.textbackground(WConio.RED)
             WConio.cputs(levelname)
             WConio.textattr(saved_color)  # restore
             print >> out, part2
         else:
             print >> out, msg
         out.flush()
     except:
         self.handleError(record)
示例#14
0
 def emit(self, record):
     WConio = self.WConio
     try:
         msg = self.format(record)
         levelname = record.levelname
         out = sys.__stdout__  # in case redirected by filelogger, etc
         if levelname in msg:
             part1, part2 = msg.split(levelname, 1)
             out.write(part1)
             out.flush()
             saved_color = WConio.gettextinfo()[4]
             WConio.textattr( self.colormap.get(levelname,
                 WConio.LIGHTGREY) )
             if levelname == 'CRITICAL':  WConio.textbackground(WConio.RED)
             WConio.cputs(levelname)
             WConio.textattr(saved_color)  # restore
             print >> out, part2
         else:
             print >> out, msg
         out.flush()
     except:
         self.handleError(record)
示例#15
0
def main():
    USB1208LS=MCCDAQ()
    
    WConio.clrscr() 
    print "Demonstration of AIn()\n"\
           "Press any key to quit.\n"

    # get the A/D channel to sample 
    Chan = int ( raw_input('Enter the channel to display: ') )

    print "\nThe raw data value on Channel %u is: " %Chan,
    (a,a,a,a,a,a,a,a,a,col,row)=WConio.gettextinfo() 
    print "\nThe voltage on Channel %u        is: " %Chan,
    
    # collect the sample from the channel until a key is pressed 
    while (WConio.kbhit()==False):
        DataValue=USB1208LS.AIn (0, Chan, BIP5VOLTS)
        EngUnits =USB1208LS.ToEngUnits (0, BIP5VOLTS, DataValue)

        WConio.gotoxy(col,row)  
        print "%5d" %DataValue,
        WConio.gotoxy(col,row+1)  
        print "%.2fV" %EngUnits,
示例#16
0
文件: logger.py 项目: tmaone/chipsec
class ColorLogger(pyLogging.Formatter):
    """Colored Output for Python Logging"""
    def format(self, record):
        message = pyLogging.Formatter.format(self, record)
        message = self.log_color(message, record)
        return message

    if "windows" == platform.system().lower():
        if has_WConio:
            BLACK = WConio.BLACK
            RED = WConio.LIGHTRED
            GREEN = WConio.LIGHTGREEN
            YELLOW = WConio.YELLOW
            BLUE = WConio.LIGHTBLUE
            MAGENTA = WConio.MAGENTA
            CYAN = WConio.CYAN
            WHITE = WConio.WHITE

            LEVEL_ID = {
                pyLogging.DEBUG: GREEN,
                pyLogging.INFO: WHITE,
                pyLogging.WARNING: YELLOW,
                pyLogging.CRITICAL: BLUE,
                pyLogging.ERROR: RED
            }

            def log_color(self, message, record):
                """ Testing """
                if record.levelno in self.LEVEL_ID:
                    WConio.textcolor(self.LEVEL_ID[record.levelno])
                    return message

            old_setting = WConio.gettextinfo()[4] & 0x00FF
            atexit.register(WConio.textcolor, old_setting)

        else:

            def log_color(self, message, record):
                return message

    elif "linux" == platform.system().lower():
        ENDC = '\033[0m'
        BOLD = '\033[1m'
        UNDERLINE = '\033[4m'
        END = 0
        LIGHT = 90
        DARK = 30
        BACKGROUND = 40
        LIGHT_BACKGROUND = 100
        GRAY = 0
        RED = 1
        GREEN = 2
        YELLOW = 3
        BLUE = 4
        PURPLE = 5
        CYAN = 6
        LIGHT_GRAY = 7
        NORMAL = 8
        WHITE = 9
        csi = '\x1b['
        reset = '\x1b[0m'

        LEVEL_ID = {
            pyLogging.DEBUG: GREEN,
            pyLogging.INFO: WHITE,
            pyLogging.WARNING: YELLOW,
            pyLogging.CRITICAL: BLUE,
            pyLogging.ERROR: RED
        }

        def log_color(self, message, record):
            if record.levelno in self.LEVEL_ID:
                color = self.LEVEL_ID[record.levelno]
                params = []
                params.append(str(color + 30))
                message = ''.join(
                    (self.csi, ';'.join(params), 'm', message, self.reset))
            return message

    else:

        def log_color(self, message, record):
            return message
示例#17
0
文件: conio.py 项目: chyser/bin
def getCursorPos():
    #-------------------------------------------------------------------------------
    t = wc.gettextinfo()
    return t[9], t[10]
示例#18
0
文件: conio.py 项目: chyser/bin
def getCursorPos():
#-------------------------------------------------------------------------------
    t = wc.gettextinfo()
    return t[9], t[10]
示例#19
0
import sys
import socket
import string
import os
import io
import time
import random
import urllib2
import re
import WConio
import threading
import sys

#(2,24)
old_setting = WConio.gettextinfo()[4] & 0x00FF
WConio.clrscr()
WConio.settitle("PyBot Control Center")
WConio.gotoxy(2, 2)
WConio.cputs("Welcome to the PyBot Control Center\n\r")
f = open('C:\\PyBot\\connections.txt', 'w')
j = open('C:\\PyBot\\update.txt', 'w')
p = open('C:\\PyBot\\cmd.txt', 'w')
f.write('')
j.write('')
p.write('')
f.close()
j.close()


class GetConnections(threading.Thread):
    def run(self):
示例#20
0
文件: main.py 项目: jtruscott/ld21
hdlr = logging.FileHandler('debug.log')
formatter = logging.Formatter('%(asctime)s %(name)s:%(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr) 
logger.setLevel(logging.DEBUG)

import sys
import os
if 'nt' not in os.name:
    import XConio
    import curses
    import game
    game.start = curses.wrapper(game.start)
import WConio as W
defaultcolor = W.gettextinfo()[4]

import game
try:
    game.start()
except game.GameShutdown:
    W.textmode()
    pass
except KeyboardInterrupt:
    W.textmode()
    raise
except:
    raise
finally:
    logger.debug("Shutting down")
    logging.shutdown()
示例#21
0
import sys
import socket
import string
import os
import io
import time
import random
import urllib2
import re
import WConio
import threading
import sys

#(2,24)
old_setting = WConio.gettextinfo()[4] & 0x00FF
WConio.clrscr()
WConio.settitle("PyBot Control Center")
WConio.gotoxy(2,2)
WConio.cputs("Welcome to the PyBot Control Center\n\r")
f = open('C:\\PyBot\\connections.txt', 'w')
j = open('C:\\PyBot\\update.txt', 'w')
p = open('C:\\PyBot\\cmd.txt', 'w')
f.write('')
j.write('')
p.write('')
f.close()
j.close()

class GetConnections ( threading.Thread ):
    def run ( self ):
	WConio.textcolor(WConio.LIGHTRED)