本文整理汇总了Python中WConio.cputs方法的典型用法代码示例。如果您正苦于以下问题:Python WConio.cputs方法的具体用法?Python WConio.cputs怎么用?Python WConio.cputs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WConio
的用法示例。
在下文中一共展示了WConio.cputs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: robust_write
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def robust_write(self, command = ''):
"""Write to the RCS with robust exception handling."""
try:
self.write(command)
except DisconnectError:
global servo_mode
servo_mode = IDLE
# Blank screen due to device disconnect.
WConio.textattr(0xb0)
WConio.clrscr()
WConio.gotoxy(10, 10)
WConio.cputs('USB-RCS has been disconnected during write. '
'Trying to reconnect. ')
self.robust_reconnect()
usb = rcs.robust_read('U')
firmware_version = usb[2]
display_once(firmware_version)
except Exception, e:
WConio.textattr(0xc0)
WConio.clrscr()
WConio.gotoxy(0, 10)
print "Unexpected exception in robust_write: ", type(e)
print
print e
print
raw_input("Press enter to exit ->")
exit()
示例2: run
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def run ( self ):
time.sleep(3)
oldLen = 0
while 1:
newLen = len(l)
WConio.textcolor(WConio.LIGHTCYAN)
posX = WConio.wherex()
posY = WConio.wherey()
WConio.gotoxy(0,4)
if newLen < oldLen:
for n in range(oldLen+1):
WConio.cputs(" \n\r")
else:
for n in range(len(l)+1):
WConio.cputs(" \n\r")
WConio.gotoxy(0,4)
for i in range(len(l)):
try:
print str(i) + ': ' + str(l[i][2])
except:
print str(i) + ': ' + str(l[i][1][0])
if posX > 16:
WConio.gotoxy(posX,22)
else:
WConio.gotoxy(17,22)
oldLen = len(l)
time.sleep(3)
示例3: get_rcs
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def get_rcs():
"""Connect to the RCS on a user selected port."""
while True:
WConio.cputs('Available Ports\nSEL Comm Port\n--- ---------\n')
ports = ['Quit'] + port_list()
for i, v in enumerate(ports):
WConio.cputs('%3d %s\n'%(i, v))
sel_str = raw_input('Select a comm port or 0 to Quit -->')
try:
sel = int(sel_str)
ports[sel]
except Exception:
WConio.cputs('\nAcceptable values are 0 to %d.\n'%i)
else:
if sel == 0:
exit()
elif sel > 0:
try:
rcs = Robust_Feusb(ports[sel])
except OpenError, e:
WConio.cputs(str(e)+'\n')
else:
return rcs
else:
WConio.cputs('\nAcceptable values are 0 to %d.\n'%i)
示例4: display_suggestion
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def display_suggestion(msg):
global old_matches
matches = []
if not msg or not msg.strip():
if old_matches != matches:
W.gotoxy(0, C.height - 2)
W.clreol()
old_matches = matches
return
msg = msg.split()[0]
for command in commands:
if command.command.startswith(msg) and not command.hide:
matches.append(command)
if matches:
#limit our match count
matches = matches[:5]
if old_matches != matches:
old_matches = matches
W.gotoxy(0, C.height - 2)
W.clreol()
targetwidth = C.width / len(matches)
W.textcolor(W.DARKGREY)
for command in matches:
W.cputs(('%s (%s)' % (command.command, format_time(command.time, command.time_variable))).center(targetwidth))
return matches
示例5: put
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def put(x, y, s, fgc=None, bgc=None):
#-------------------------------------------------------------------------------
wc.gotoxy(x, y)
if bgc:
wc.textbackground(bgc)
if fgc:
wc.textcolor(fgc)
wc.cputs(s)
示例6: put_at
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def put_at(x, y, msg, color=None):
if color:
W.textcolor(color)
if len(msg) + x > C.width:
log.debug('put_at: truncating %s by %i', msg, len(msg) + x - C.width)
msg = msg[:C.width - x - 1]
W.gotoxy(x, y)
W.cputs(msg)
示例7: status
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def status(self, y, s):
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
wc.gotoxy(0, y)
wc.movetext(0, y, self.ex, self.ey -1, 0, y+1)
wc.gotoxy(0, y)
wc.textbackground(7)
wc.textcolor(15)
wc.clreol()
wc.cputs(s)
示例8: draw_box_text
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def draw_box_text(box, text=None):
if text is None:
text = box.text
W.textbackground(box.interior_background_color)
for line in text:
W.textcolor(line.color)
if line.right_justify:
W.gotoxy(box.left + box.width - line.x - len(line.text), box.top + line.y)
else:
W.gotoxy(box.left + line.x, box.top + line.y)
W.cputs(line.text)
示例9: display_bar
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def display_bar(xcol, yrow, color, division, width):
"""Display a bar of 'color' and 'width', with two sections at 'division'."""
full_cells, cell_frac = divmod(int(width * division * 3), 3)
if division < 0:
display_string = SPACE * width
elif full_cells == width:
display_string = FULL_BAR * width
elif cell_frac == 0:
display_string = FULL_BAR * full_cells + SPACE * (width - full_cells)
elif cell_frac == 1:
display_string = FULL_BAR * full_cells + HALF_BAR + SPACE * (width - full_cells - 1)
else:
display_string = FULL_BAR * (full_cells + 1) + SPACE * (width - full_cells - 1)
WConio.gotoxy(xcol, yrow)
WConio.textattr(color)
WConio.cputs(display_string)
示例10: run
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def run ( self ):
WConio.textcolor(WConio.LIGHTRED)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = ''
port = 8888
s.bind((host, port))
s.listen(1)
IPs = []
WConio.gotoxy(0,25)
WConio.cputs("Awaiting Connections...")
WConio.gotoxy(19,23)
while 1:
conn, addr = s.accept()
WConio.gotoxy(0,25)
WConio.cputs("Connection Recieved -- Adding to File")
WConio.gotoxy(19,23)
f = open('C:\\PyBot\\connections.txt', 'a')
f.write(addr[0] + '\n')
f.close()
示例11: robust_reconnect
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def robust_reconnect(self):
"""Reconnect with exception handling."""
recon_count = 0
while True:
time.sleep(0.500)
try:
self.reconnect()
except OpenError:
recon_count += 1
WConio.gotoxy(20, 14)
WConio.cputs(' Reconnect retry attempts: %5i '%
recon_count)
except Exception, e:
WConio.gotoxy(5, 16)
print "Unexpected exception during reconnect:", type(e)
print e
raw_input("Press enter to exit ->")
exit()
else:
return
示例12: emit
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
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)
示例13: robust_read
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def robust_read(self, command = None, count = 1):
"""Read from the RCS with robust exception handling."""
global servo_mode
while True:
try:
return self.read(command, count)
except DisconnectError:
servo_mode = IDLE
# Blank screen due to device disconnect.
WConio.textattr(0xb0)
WConio.clrscr()
WConio.gotoxy(10, 10)
WConio.cputs('USB-RCS has been disconnected during read. '
'Trying to reconnect. ')
self.robust_reconnect()
usb = rcs.robust_read('U')
firmware_version = usb[2]
display_once(firmware_version)
except ReadTimeoutError, e:
servo_mode = IDLE
# Blank screen due to device disconnect.
WConio.textattr(0xc0)
WConio.clrscr()
WConio.gotoxy(10, 10)
WConio.cputs('USB-RCS read timeout: '
'Communications is not responding as expected.')
WConio.gotoxy(10, 12)
raw_input("Unplug the USB-RCS.")
while self.status() != DISCONNECTED:
time.sleep(0.500)
WConio.gotoxy(10, 12)
WConio.cputs("Now, plug-in the USB-RCS.")
self.robust_reconnect()
usb = rcs.robust_read('U')
firmware_version = usb[2]
display_once(firmware_version)
except Exception, e:
WConio.textattr(0xc0)
WConio.clrscr()
WConio.gotoxy(0, 10)
print "Unexpected exception in robust_read: ", type(e)
print e
raw_input("Press enter to exit ->")
exit()
示例14: prompt_hbar
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
def prompt_hbar():
W.textcolor(W.WHITE)
W.gotoxy(0, C.height-3)
#print C.Characters.box_single.horiz * C.width
W.cputs(C.Characters.box_single.horiz * C.width)
示例15: raw_input
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import cputs [as 别名]
#(2,24)
old_setting = WConio.gettextinfo()[4] & 0x00FF
WConio.clrscr()
WConio.textcolor(WConio.LIGHTRED)
WConio.settitle("PyBot Control Center")
WConio.gotoxy(2,2)
print "Welcome to the Pybot Control Center"
global l
global key
key = "this is the best key in the world, you'll never guess it :D 4&#*%:J"
l = []
WConio.cputs( "\n username: " )
user = raw_input()
WConio.cputs( " password: " )
gpw = raw_input()
print ""
try:
conn = mdb.connect('184.168.194.11','goldenboy',
'[email protected]','goldenboy')
cursor = conn.cursor()
cursor.execute("SELECT Password FROM Users WHERE Username = '" + user + "';")
data = cursor.fetchone()
if str(data) != "None":
if str(data[0]) == gpw:
print "Authorized - Welcome " + user
time.sleep(2)